Virus Spread Simulator

Guys I found, forked and tweaked a virus spread simulator, just trying to deal with self isolation right now. I made this into a tutorial, the simulator is up on my site so you can try it out - using Processing.js but also works with Processing, and Processing for Android.

Check it out here: https://www.circusscientist.com/virus-spread-simulator-with-processing-js/

Credit where credit is due, the original is by Vinay Raghavan

4 Likes

We can also use OpenProcessing.org/sketch/create and others in order to deploy to the web. :globe_with_meridians:

By default it runs p5js sketches; but we can easily switch to Pjs engine on its right-side panel. :bulb:

Then we can copy’n’paste both the original & your remix source code there and click the play icon :arrow_forward::

  1. CircusScientist.com/spread/spread.pde
  2. raw.GitHubUserContent.com/vinaysraghavan/movingDots/master/movingDots.pde
1 Like

Hi @tomjuggler
I still am confused about Processing.js

I promise, the only part that is remotely challenging is processing.js, and only because it has been a bit neglected by the official Processing IDE.

Why has it been neglected? Wasn´t it just replaced with P5.js

P5.js is based on JavaScript, there are differences in how that works compared with other modes, like Java, Android and Processing.js (which, to be fair, is compiled to JavaScript in the end)

By all means, use P5, but you are going to have to change a few things in your Java code to get it to run. See https://github.com/processing/p5.js/wiki/Processing-transition

It’s great to hear that OpenProcessing has a Pjs engine now, is this new or did I just miss it? I used to use that site when it was all about applets, remember those?

I think I sent a reply to the wrong person here, about P5.js… Sorry about that

that was for @noel sorry

OpenProcessing.org from its very start has always & never stopped offering hosting for Pjs’s Java syntax sketches!

Flavor p5.js is its latest addition and, b/c Pjs has been abandoned by the Processing Foundation in favor of p5.js, it’s become its default engine.

@noel

p5.js implements the Processing API in JavaScript – you program it using JavaScript syntax.

Processing.js – http://processingjs.org/ – is a transpiler. It runs in JavaScript, but you program it in the Processing (Java mode) syntax, which it converts into JS behind the scenes. (Keep in mind that originally, Processing (Java) itself ran in the browser using the fairly ubiquitous Java applet plugins. Then, gradually, it didn’t.) So for people familiar with the Processing Java desktop mode, they can take their code, paste it into a Processing.js, and under the hood it magically becomes JavaScript and runs (90%, with caveats and tweaks, of course).

The last Processing.js release was 1.6.6 ~2017, but the website was last updated in 2014, which contributes to the impression that it is old. Even more, the key thing is that the mode plugin doesn’t ship with Processing 3, and the version in contributions manager is only compatible with Processing 2. That makes it feel “neglected” for those that want to write Java-mode-for-the-web on the desktop – you have to install Processing 2 to use it.

1 Like

Just a little reminder that we can also target the Pjs library using straight JS syntax (or any other language which can be transpiled to JS) besides Java. :open_mouth:

I’ve done that using CoffeeScript syntax transpiled to JS at the link below: :coffee:
GoSubRoutine.GitHub.io/Ball-in-the-Chamber/pjs-cs/
https://github.com/GoSubRoutine/Ball-in-the-Chamber/tree/master/pjs-cs

BtW, both the original “.coffee” and the corresponding transpiled “.js” files are side-by-side. :innocent:

2 Likes

Hi @tomjuggler, I ran the virus spread sim and got lucky :upside_down_face: non of the dots got infected. Check out this screen shot

1 Like

Wish we were all that lucky… Stay home and keep safe!