From a256aa20c993adf244c394b2121104004d7439a2 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sat, 8 Feb 2020 13:30:37 -0800 Subject: Add sixteen.js blogpost --- src/blog/sixteen.html | 406 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 406 insertions(+) create mode 100644 src/blog/sixteen.html (limited to 'src') diff --git a/src/blog/sixteen.html b/src/blog/sixteen.html new file mode 100644 index 0000000..0c98c35 --- /dev/null +++ b/src/blog/sixteen.html @@ -0,0 +1,406 @@ +title: An experiment in programmatic and artistic constraints +date: February 8, 2020 13:29 +--- +

+

+ +

+Write a piece of JavaScript that defines a function named s that + +

+

+ +

+The source code defining s will be visually displayed on a 16x16 +grid. 32 times a second, it will be separately called for each x, +y coordinate of the grid, initially with a t parameter +equal to 0, and incrementing by one with each series of calls. +

+ +

+The result of each call to s will determine the shade of the +character in the corresponding grid location. +

+ +

In code:

+
+var step = 0
+_frame = function() {
+    for (var row = 0; row < 16; row++) {
+        for (var column = 0; column < 16; column++) {
+            var shade = s(row, column, step)
+            var cell = display.children[row].children[column]
+            cell.style.color = `rgb(${shade}, ${shade}, ${shade})`
+        }
+    }
+    step++
+}
+setInterval(_frame, 31.25)
+
+ +

An example

+ +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + -- cgit v1.2.3