From static frames to animation – JavaScript, Java & Processing; coding Art ….

As part of my research, I endeavored to build a frame and tile itevenly…as you would a column in a upscale restaurant, or as Billy-Buster tiled his lesser-known below-ground pool in the hilltop paradise above San Simeon. Drawing squares, keeping track of their quantity, position and spacing proved unweildy. So back to the drawing board I turned. The first task was to completely fill a window with squares, evenly spaced, uniformed – no holes. My first breakthrough was a rectangular grid – from the drawing board I found that instead of looping to keep track of the squares (their origins in CGI coordinates space, their quantity, when to drop down a row, when to stop building them…) oy! I located a KISS-simple solution in the following functions and abstract data types:

Click to see it transform.
Some tweaks to a nested-for loop, appropriate “pops” nee popMatrix(); and the careful application of a “random” number generator to produce cool-colored tiles —but not TOO cool — experiment yielded a random range in Green and Blue to give the tiles a watery sheen, sans magenta, indigo, dark purple and the like. For personal intersest and further research I added a mouse event that slows down the animation, eliminates the thin black borders on each tile and zooms in on the whole operation.
At long last “Random dynamic & cool tiles” is up for public consumption:
I could see a pool in Laguna, LA, Vegas or Laughlin with swanky, swarthy, light-up tiles in a pool or on a wall of it’s club …. Bill R. Hearst would be pleased…I like to think so.
Next – I thought about Neil Degrasse Tyson. He says that the “snow” we see on the “TV channels in-between TV channels,” (something our Millennial friends may never fully appreciate…) is ACTUALLY a visual representation of the background radiation that’s permeated the Universe since the Big Bang. UHF & VHF cathode-ray displays pick up this noise and spit out the “ssshhhhhhhh” and the black, white & gray snow we may’ve found on Channel 1 or 3. Mostly, it was annoying and caused us to quickly dial up to CBS, PBS, NBC, FOX or ABC to see what was cookin’….but in the context of nostalgia, the scientific implication of looking back seven trillion years; this “snow” is worth an emulation. Using similar logic I fashioned version 1. The snow doesn’t dance around the screen, but the small circular “flakes” and the way they appear to move based on random gray-scale shadings is a nice start. It looks like they move – kinda.
^^^^I slowed the frame rate down to avoid headaches.
After random “cool” I had to attempt random “warm” –this graphic reminds me of a HollyWood or Vegas marquee. Bright lights seize attention; underscoring the glitz and glamour purported to be found within. The difference is that I think the bulbs this animation emulates are controlled in strict, looping sequences as opposed to my random flashes of “bright” colors controlled by logic.
This animation reminds me of the “Sushi”scene from “Defending Your Life” — Albert Brooks’ barmate proudly states that his life accomplishment was coining the phrase “All Nude. (You know those strip clubs out by LAX? ….“) You needn’t be a fan of his quirky brand of humor to get huge kick out this classic.
That said, I FINALLY got the computer graphic programs to not only display but animate! The “random- (random number generators are not TRULY random, but they are close)-ness” of the algorithms give the displays a kind of innate ability for the computers to create something of THEIR OWN — MY LOGIC & Design—> the computers’ brushstrokes.
All of the “sketches” (as they call them) on my new OpenProcessing Profile are completely original – designed, built, tested, tweaked and deployed by this writer. If you visit my new page & graphics, the source code is easily visible. Feel free to reproduce it yourself, or make changes/improvements to it. You will find that all of them are optimized –nee “code-golfed.” I designed these algorithms to use the fewest lines of code, fewest commands and simplest logic to add a layer of mathematical elegance to the aesthetic of each sketch. Please feel free to download my source code…just plz note that all of them are intellectual property- if you plan to use them in a public/educational or commercial setting…just ask! chris@tapper7.com
More coming soon….plus a litany of fresh podcasts – “I swear it by the old gods & the new.” -t []

The Binary Power Series and Java 1.8 ….

A numeric depiction of 18.44 Quintillion

Series follow a specific pattern and obey explicit, ineffable rules, like prime numbers….
1, 3, 5, 7, 11, 13, 17, 19, 23…. Or a times-table such as 9…. 18, 27, 36, 45, 54, 63, 72, 81, 90, 99. You get the idea, right? (I hope so or you’ll find this post incredibly boring).
Computers store information in bits. A bit is one memory cell that is known by the CPU to be TRUE or FALSE, one or zero. In the parlance of electrical engineering, this equates to either “very very low voltage” or “hardly any voltage at all.”
A byte is eight bits: 0000 0000 thru 1111 1111; 1-256

Consider 0000, 0001, 0010, 0011, 0100, 0101, 0111, 1111 -OR- (in English) one, two, three, four five six, seven, eight. To be literal, it’s actually zero through seven, but let’s not get muddy the waters or scare off any readers due to the “maths.” You don’t need to know much math to understand this information…. So a computer needs half of one byte in order to express “seven” to the world “1111.”

Eight bits comprises two to the eighth power (256) possible binary combos. That’s enough to create a color palette acceptable to the human eye, In RGB-space, three eight-bit numbers (0,0,0) being “K” or Black and (255,255,255) being White – or is it vice-versa? You can always go to www.org for quick reference on non-abstract, “code flavors” such as the above assertion. Ok, so three SETs of 256 bits can broadcast “Game of Thrones” on your laptop screen adequaetely. This is what makes 64-bit machines so exciting…64 is a small number….2^64 (which is the definition of a 64-bit sys) ACTUALLY equals about 18.5 QUINTILLION, or 18.5 x a trillion x a trillion. To give you an idea of size…if you started counting as fast as you could from the time you could speak…or comprehend it and count in your head; if you lived an avg. lifespan (~72.9 yrs) you’d be spitting out “one billion” with your last dying breath. A 64-bit system can express and count to a billion in fractions of a millisecond. So what concerns us about this TODAY?
With big data (all the rage) comes big numbers, so I’ve been thinking about them and toying with the limits of large number calculation and output using my laptop’s on-board calculator…it can express a google correctly using a semi-correct scientific notation: “1.e+100” –by that, Microsoft means to say “a one followed by 100 zeroes.” I have no way of knowing HOW they arrive at a correct answer to 10^100 considering that the largest unsigned long integer that can be stored in one memory cell by a 64-bit system is stated above..”a 1 followed by 19 numbers” … this means the Calculator App you use combines multiple long integers and uses extra memory to store anything above 2^64 = 18,446,744,073,709,551,616.

Using the Netbeans IDE, I created a program that asks the user to provide a number to act as a power of two. It then calculates and prints the subsequent results to the screen. Integers are preffered because they are fast, accurate and take up very little memory: 16 bits or 2 bytes, which can express numbers on the range of (-32678 to +32678). Integers (or “ints”) can ONLY BE WHOLE NUMBERS, that is, 1.5 is not an int, nor is e or pie or the square root of two.

Program output for common cases:
How many iterations of the Binary Power Series would you like to see calculated and printed?
0
Ok - you're the boss. No iterations--> no output
How many iterations of the Binary Power Series would you like to see calculated and printed?
1
Binary Power Series 2 to the power of 0 = 1
BUILD SUCCESSFUL (total time: 6 seconds)
How many iterations of the Binary Power Series would you like to see calculated and printed?
2
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
BUILD SUCCESSFUL (total time: 4 seconds)
How many iterations of the Binary Power Series would you like to see calculated and printed?
4
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
Binary Power Series 2 to the power of 2 = 4
Binary Power Series 2 to the power of 3 = 8
BUILD SUCCESSFUL (total time: 6 seconds)
How many iterations of the Binary Power Series would you like to see calculated and printed?
8
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
Binary Power Series 2 to the power of 2 = 4
Binary Power Series 2 to the power of 3 = 8
Binary Power Series 2 to the power of 4 = 16
Binary Power Series 2 to the power of 5 = 32
Binary Power Series 2 to the power of 6 = 64
Binary Power Series 2 to the power of 7 = 128
BUILD SUCCESSFUL (total time: 15 seconds)

How many iterations of the Binary Power Series would you like to see calculated and printed?
16
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
Binary Power Series 2 to the power of 2 = 4
Binary Power Series 2 to the power of 3 = 8
Binary Power Series 2 to the power of 4 = 16
Binary Power Series 2 to the power of 5 = 32
Binary Power Series 2 to the power of 6 = 64
Binary Power Series 2 to the power of 7 = 128
Binary Power Series 2 to the power of 8 = 256
Binary Power Series 2 to the power of 9 = 512
Binary Power Series 2 to the power of 10 = 1024
Binary Power Series 2 to the power of 11 = 2048
Binary Power Series 2 to the power of 12 = 4096
Binary Power Series 2 to the power of 13 = 8192
Binary Power Series 2 to the power of 14 = 16384
Binary Power Series 2 to the power of 15 = 32768
BUILD SUCCESSFUL (total time: 3 seconds)
How many iterations of the Binary Power Series would you like to see calculated and printed?
32
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
Binary Power Series 2 to the power of 2 = 4
Binary Power Series 2 to the power of 3 = 8
Binary Power Series 2 to the power of 4 = 16
Binary Power Series 2 to the power of 5 = 32
Binary Power Series 2 to the power of 6 = 64
Binary Power Series 2 to the power of 7 = 128
Binary Power Series 2 to the power of 8 = 256
Binary Power Series 2 to the power of 9 = 512
Binary Power Series 2 to the power of 10 = 1024
Binary Power Series 2 to the power of 11 = 2048
Binary Power Series 2 to the power of 12 = 4096
Binary Power Series 2 to the power of 13 = 8192
Binary Power Series 2 to the power of 14 = 16384
Binary Power Series 2 to the power of 15 = 32768
Binary Power Series 2 to the power of 16 = 65536
Binary Power Series 2 to the power of 17 = 131072
Binary Power Series 2 to the power of 18 = 262144
Binary Power Series 2 to the power of 19 = 524288
Binary Power Series 2 to the power of 20 = 1048576
Binary Power Series 2 to the power of 21 = 2097152
Binary Power Series 2 to the power of 22 = 4194304
Binary Power Series 2 to the power of 23 = 8388608
Binary Power Series 2 to the power of 24 = 16777216
Binary Power Series 2 to the power of 25 = 33554432
Binary Power Series 2 to the power of 26 = 67108864
Binary Power Series 2 to the power of 27 = 134217728
Binary Power Series 2 to the power of 28 = 268435456
Binary Power Series 2 to the power of 29 = 536870912
Binary Power Series 2 to the power of 30 = 1073741824
Binary Power Series 2 to the power of 31 = 2147483648
BUILD SUCCESSFUL (total time: 4 seconds)

….now let’s see what happens when we get close to 64 iterations:

How many iterations of the Binary Power Series would you like to see calculated and printed?
63
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
Binary Power Series 2 to the power of 2 = 4
Binary Power Series 2 to the power of 3 = 8
Binary Power Series 2 to the power of 4 = 16
Binary Power Series 2 to the power of 5 = 32
Binary Power Series 2 to the power of 6 = 64
Binary Power Series 2 to the power of 7 = 128
Binary Power Series 2 to the power of 8 = 256
Binary Power Series 2 to the power of 9 = 512
Binary Power Series 2 to the power of 10 = 1024
Binary Power Series 2 to the power of 11 = 2048
Binary Power Series 2 to the power of 12 = 4096
Binary Power Series 2 to the power of 13 = 8192
Binary Power Series 2 to the power of 14 = 16384
Binary Power Series 2 to the power of 15 = 32768
Binary Power Series 2 to the power of 16 = 65536
Binary Power Series 2 to the power of 17 = 131072
Binary Power Series 2 to the power of 18 = 262144
Binary Power Series 2 to the power of 19 = 524288
Binary Power Series 2 to the power of 20 = 1048576
Binary Power Series 2 to the power of 21 = 2097152
Binary Power Series 2 to the power of 22 = 4194304
Binary Power Series 2 to the power of 23 = 8388608
Binary Power Series 2 to the power of 24 = 16777216
Binary Power Series 2 to the power of 25 = 33554432
Binary Power Series 2 to the power of 26 = 67108864
Binary Power Series 2 to the power of 27 = 134217728
Binary Power Series 2 to the power of 28 = 268435456
Binary Power Series 2 to the power of 29 = 536870912
Binary Power Series 2 to the power of 30 = 1073741824
Binary Power Series 2 to the power of 31 = 2147483648
Binary Power Series 2 to the power of 32 = 4294967296
Binary Power Series 2 to the power of 33 = 8589934592
Binary Power Series 2 to the power of 34 = 17179869184
Binary Power Series 2 to the power of 35 = 34359738368
Binary Power Series 2 to the power of 36 = 68719476736
Binary Power Series 2 to the power of 37 = 137438953472
Binary Power Series 2 to the power of 38 = 274877906944
Binary Power Series 2 to the power of 39 = 549755813888
Binary Power Series 2 to the power of 40 = 1099511627776
Binary Power Series 2 to the power of 41 = 2199023255552
Binary Power Series 2 to the power of 42 = 4398046511104
Binary Power Series 2 to the power of 43 = 8796093022208
Binary Power Series 2 to the power of 44 = 17592186044416
Binary Power Series 2 to the power of 45 = 35184372088832
Binary Power Series 2 to the power of 46 = 70368744177664
Binary Power Series 2 to the power of 47 = 140737488355328
Binary Power Series 2 to the power of 48 = 281474976710656
Binary Power Series 2 to the power of 49 = 562949953421312
Binary Power Series 2 to the power of 50 = 1125899906842624
Binary Power Series 2 to the power of 51 = 2251799813685248
Binary Power Series 2 to the power of 52 = 4503599627370496
Binary Power Series 2 to the power of 53 = 9007199254740992
Binary Power Series 2 to the power of 54 = 18014398509481984
Binary Power Series 2 to the power of 55 = 36028797018963968
Binary Power Series 2 to the power of 56 = 72057594037927936
Binary Power Series 2 to the power of 57 = 144115188075855872
Binary Power Series 2 to the power of 58 = 288230376151711744
Binary Power Series 2 to the power of 59 = 576460752303423488
Binary Power Series 2 to the power of 60 = 1152921504606846976
Binary Power Series 2 to the power of 61 = 2305843009213693952
Binary Power Series 2 to the power of 62 = 4611686018427387904

Sixty-four is the borderline on accuracy using unsigned long integers (as stated above) so I coded it’s calculation and warning appropriately:

How many iterations of the Binary Power Series would you like to see calculated and printed?
64
Binary Power Series 2 to the power of 0 = 1
Binary Power Series 2 to the power of 1 = 2
Binary Power Series 2 to the power of 2 = 4
Binary Power Series 2 to the power of 3 = 8
Binary Power Series 2 to the power of 4 = 16
Binary Power Series 2 to the power of 5 = 32
Binary Power Series 2 to the power of 6 = 64
Binary Power Series 2 to the power of 7 = 128
Binary Power Series 2 to the power of 8 = 256
Binary Power Series 2 to the power of 9 = 512
Binary Power Series 2 to the power of 10 = 1024
Binary Power Series 2 to the power of 11 = 2048
Binary Power Series 2 to the power of 12 = 4096
Binary Power Series 2 to the power of 13 = 8192
Binary Power Series 2 to the power of 14 = 16384
Binary Power Series 2 to the power of 15 = 32768
Binary Power Series 2 to the power of 16 = 65536
Binary Power Series 2 to the power of 17 = 131072
Binary Power Series 2 to the power of 18 = 262144
Binary Power Series 2 to the power of 19 = 524288
Binary Power Series 2 to the power of 20 = 1048576
Binary Power Series 2 to the power of 21 = 2097152
Binary Power Series 2 to the power of 22 = 4194304
Binary Power Series 2 to the power of 23 = 8388608
Binary Power Series 2 to the power of 24 = 16777216
Binary Power Series 2 to the power of 25 = 33554432
Binary Power Series 2 to the power of 26 = 67108864
Binary Power Series 2 to the power of 27 = 134217728
Binary Power Series 2 to the power of 28 = 268435456
Binary Power Series 2 to the power of 29 = 536870912
Binary Power Series 2 to the power of 30 = 1073741824
Binary Power Series 2 to the power of 31 = 2147483648
Binary Power Series 2 to the power of 32 = 4294967296
Binary Power Series 2 to the power of 33 = 8589934592
Binary Power Series 2 to the power of 34 = 17179869184
Binary Power Series 2 to the power of 35 = 34359738368
Binary Power Series 2 to the power of 36 = 68719476736
Binary Power Series 2 to the power of 37 = 137438953472
Binary Power Series 2 to the power of 38 = 274877906944
Binary Power Series 2 to the power of 39 = 549755813888
Binary Power Series 2 to the power of 40 = 1099511627776
Binary Power Series 2 to the power of 41 = 2199023255552
Binary Power Series 2 to the power of 42 = 4398046511104
Binary Power Series 2 to the power of 43 = 8796093022208
Binary Power Series 2 to the power of 44 = 17592186044416
Binary Power Series 2 to the power of 45 = 35184372088832
Binary Power Series 2 to the power of 46 = 70368744177664
Binary Power Series 2 to the power of 47 = 140737488355328
Binary Power Series 2 to the power of 48 = 281474976710656
Binary Power Series 2 to the power of 49 = 562949953421312
Binary Power Series 2 to the power of 50 = 1125899906842624
Binary Power Series 2 to the power of 51 = 2251799813685248
Binary Power Series 2 to the power of 52 = 4503599627370496
Binary Power Series 2 to the power of 53 = 9007199254740992
Binary Power Series 2 to the power of 54 = 18014398509481984
Binary Power Series 2 to the power of 55 = 36028797018963968
Binary Power Series 2 to the power of 56 = 72057594037927936
Binary Power Series 2 to the power of 57 = 144115188075855872
Binary Power Series 2 to the power of 58 = 288230376151711744
Binary Power Series 2 to the power of 59 = 576460752303423488
Binary Power Series 2 to the power of 60 = 1152921504606846976
Binary Power Series 2 to the power of 61 = 2305843009213693952
Binary Power Series 2 to the power of 62 = 4611686018427387904
Binary Power Series 2 to the power of 63 = -9223372036854775808
The longest integer that can be expressed correctly is 4611686018427387904
appx. 4.61 QUINTILLION (4.61E18)
***Requests for over 64 iterations return bad data***
BUILD SUCCESSFUL (total time: 3 seconds)

Note that the 64th iteration (array in location 63 is NEGATIVE…this is obviously not the correct answer. I capped the size of the long int array at 65 memory cells, hence …while it WILL compile (using the std gcc compiler) it will throw an exception and kill the program for values OVER 64:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 65
Here is the source code I wrote if you’d like to try out my logic, tweak it, or scope-out my old-school design style (it is only lightly code-golfed; the abbreviations the kids use today make for confusing code. I try to use Object-Oriented variable identifiers to make definitive and concise use of comments as well as a style I learned from my days as a Cal Poly CSC Code-monkey:

/* Author: Chris "Tapper" Welke
* dist under the GNU Public License.
* This program tests the upper limit of numbers (long ints)
* of the NetBeans IDE v8.0.2 via the rapid geometric growth
* inherent to The Binary Power Series (BPS). 1, 2, 4, 8, 16 ....
* Two to the 64th power is the highest integer in the series
* it can calculate correctly unaided by extra memory/variables/logic
* Last stable build at Self-Similarity Studios & Tapper7.com,
* Los Angeles, CA 5/15/2015
*/
package series;
import java.util.Scanner;
class BPSeries{
protected static String Name = "Binary Power Series ";
protected static int Base = 2;
public static int gIN(){/**
* This fxn gets and sets the number of BPS iterations from the user
* a warning is displayed for n = 64 and an exception is thrown for n > 64
*/
int userInput;
System.out.println("How many iterations of the " + Name + "would you like to see calculated and printed?");
Scanner in = new Scanner(System.in);
userInput = in.nextInt();
return userInput;
}//end UI gIN
public static void main(String[] arg){
//getNset user-defined number of iterations:
int sIts = BPSeries.gIN();
//declare and allocate space for the cells
int cellKit = 65; //throw exception for >64 pwrs of 2
long[] sCells = new long[cellKit];
int pwr = 0; //initialize superscript
int i = 1; //initialize cell iterator
sCells[0] = 0; //null
sCells[1] = 1; //set cell one to 1 since n^0 = 1 for all n
switch(sIts){
case 0:
System.out.println("Ok - you're the boss. No iterations--> no output");
break;
case 1:
System.out.println(BPSeries.Name + BPSeries.Base + " to the power of " +pwr+ " = "+sCells[i]);
i++; pwr++;
break;
default:
System.out.println(BPSeries.Name + BPSeries.Base +" to the power of 0 = 1");
sCells[3]=(sCells[2]*BPSeries.Base);
i++; pwr++;
while (i<=sIts){ sCells[i]= (sCells[i-1] * BPSeries.Base); System.out.println(BPSeries.Name + BPSeries.Base + " to the power of "+pwr+" = "+sCells[i]); i++; pwr++; }//end while if(sIts>63){//exception notification/handling for 64 bit chipset
System.out.println("The longest integer that can be expressed correctly is "+ sCells[63]);
System.out.println("appx. 4.61 QUINTILLION (4.61E18)");
System.out.println("***Requests for over 64 iterations return bad data***");
}//endIF
}//end switch
}//end main
}//end BPS

A graphical analysis and more tests will follow this discussion; as well as highlights from
The Doheny Blues Festival, which begins tomorrow, I will review Boz Scaggs and hopefully Los Lobos too. Come get your tap on w/ me this weekend. Boz Scaggs!!! []

Today’s algorithm and number-musings sponsored by: