So the Jar of Sparkly things has been updated to include color changing, a couple of different fields, and different ways for the particles to move. The latest is that not only is this a runnable jar file, but I also created an Android App. It’s not quite the same due to my device not being able to handle a simple triple nested for loop (it took eight minutes to run through one frame of this on my Galaxy S5!). But here it is in action!
If you compare the way they look, you’ll notice that the dots in the android version are drawn using a bunch of circles that fade out from white, to their color, then to black. Here is a screen shot of the the same particles, but drawn on the field in the runnable jar:
Being able to plot the field around the dot instead of drawing the dot gives a very nice glowing effect. It is pretty hard on the computer though. With 1/4 resolution my computer runs this at 20 frames per second. The problem is in the triple nested loop. If you read the earlier post about the math involved in calculating an Electric Field, you’ll know that the field is calculated by running every pixel against every point. So at 320 x 180 pixels, and 20 points, there are 1.1 million calculations going on per frame. That’s pretty far out, and I’m guessing that is just to much to run on an Android device.
What was done in the android device was just drawing 20 circles that fade out from the point, and the colors are added together on the canvas. This drastically cuts down on the number of calculations. This makes the number of calculations 50 dots x 20 radius,which is only 1,000 calculations (relatively speaking). So it runs much smoother and can handle much more particles. However if there is a way any one knows about that can allow me to do something like what was done in the PC version, please let me know.
OH! and don’t forget to download them both right here: