Remarks: Processing Mazes
From Maze
(Difference between revisions)
(Added paragraph stub for a new Processing port.) | |||
| Line 7: | Line 7: | ||
The first Processing version of 10 PRINT was written to take advantage of the increased resolution of contemporary screens. It does this by making the thickness and ends of the lines into variables that can be changed while the program runs. The lines of the maze can range from 0.5 to 10 pixels wide and the lines can terminate with a rounded or square end. Like 10 PRINT, it maintains the grid of lines at 40 x 25 units, but unlike 10 PRINT it doesn't add each grid unit in sequence from left to right and top to bottom. In this new high-resolution version, the entire grid is refreshed in unison. Without thinking about it, we set used the default Processing colors to create white lines and a black background. In hindsight, this imbued the program with a distinct feel from the original lower-contrast blues of the C64. The result is shown in figures ?? to ??. | The first Processing version of 10 PRINT was written to take advantage of the increased resolution of contemporary screens. It does this by making the thickness and ends of the lines into variables that can be changed while the program runs. The lines of the maze can range from 0.5 to 10 pixels wide and the lines can terminate with a rounded or square end. Like 10 PRINT, it maintains the grid of lines at 40 x 25 units, but unlike 10 PRINT it doesn't add each grid unit in sequence from left to right and top to bottom. In this new high-resolution version, the entire grid is refreshed in unison. Without thinking about it, we set used the default Processing colors to create white lines and a black background. In hindsight, this imbued the program with a distinct feel from the original lower-contrast blues of the C64. The result is shown in figures ?? to ??. | ||
| + | [NOTE 9 July. Add the second Processing port, which includes making the maze move up the screen, changing the symbol to black and white boxes to show how the effect is lost, change the weight of the random number. Note which can be rewritten for the C64 and which are unique to Processing.] | ||
| + | |||
The line endings are a subtle, but crucial change within this program. In the original 10 PRINT image (see fig ??), notice how each line terminates into a point. This is required because each of the 40 x 25 tiles that comprise the maze are constrained to an 8 x 8 pixel area. This maze is created by tiling the lines, each constrained within a a 64 pixel square. In the Processing program, each line is free to extend beyond the boundaries that define a line. The screen in Processing is a continuous surface of pixels, each of which can be addressed precisely with an x- and y-coordinate rather than a tile position. The 10 PRINT program is comprised of 320 x 200 pixels, but the actual controllable resolution is 40 x 25, for a total of 1000 elements. A Processing version of the program can utilize all of the pixels on a contemporary screen which makes it possible to access millions of pixels. For example, a standard 1080p screen, provides 2,073,600 pixels to control. | The line endings are a subtle, but crucial change within this program. In the original 10 PRINT image (see fig ??), notice how each line terminates into a point. This is required because each of the 40 x 25 tiles that comprise the maze are constrained to an 8 x 8 pixel area. This maze is created by tiling the lines, each constrained within a a 64 pixel square. In the Processing program, each line is free to extend beyond the boundaries that define a line. The screen in Processing is a continuous surface of pixels, each of which can be addressed precisely with an x- and y-coordinate rather than a tile position. The 10 PRINT program is comprised of 320 x 200 pixels, but the actual controllable resolution is 40 x 25, for a total of 1000 elements. A Processing version of the program can utilize all of the pixels on a contemporary screen which makes it possible to access millions of pixels. For example, a standard 1080p screen, provides 2,073,600 pixels to control. | ||
| − | With this enhanced resolution in mind, we wrote a third version of 10 PRINT in Processing that took more liberties with the original program. The number of rows and columns in the grid were variable, the direction of the line defined its color (black or white), each line was defined as a quadrilateral to give more flexibility of the shape, and a third color was used for the background. Each time the code is run, the size of the grid unit is defined at random as a power of 2 (2, 4, 8, 16, or 32) and the thickness of the lines are set randomly to 2, 4, or 8. Figures ?? to ?? show some of the varied results. With the ability to further define the graphics, the code became longer than the C64 one-liner: | + | With this enhanced resolution in mind, we wrote a third version of 10 PRINT in Processing that took more liberties with the original program. The number of rows and columns in the grid were variable, the direction of the line defined its color (black or white), each line was defined as a quadrilateral to give more flexibility of the shape, and a third color was used for the background. Each time the code is run, the size of the grid unit is defined at random as a power of 2 (2, 4, 8, 16, or 32) and the thickness of the lines are set randomly to 2, 4, or 8. Figures ?? and ?? show some of the varied results. With the ability to further define the graphics, the code became longer than the C64 one-liner: |
size(1020, 680); | size(1020, 680); | ||
noStroke(); | noStroke(); | ||
background(0, 0, 255); | background(0, 0, 255); | ||
| + | int unit = height / (rows + 4); | ||
int rows = int(pow(2, int(random(1, 6)))); // 2, 4, 8, 16, 32 | int rows = int(pow(2, int(random(1, 6)))); // 2, 4, 8, 16, 32 | ||
int thickness = int(pow(2, int(random(1, 4)))); // 2, 4, 8 | int thickness = int(pow(2, int(random(1, 4)))); // 2, 4, 8 | ||
| − | int unit = height / (rows + 4); | ||
int uthick = unit / thickness; | int uthick = unit / thickness; | ||
int uthicker = unit + uthick; | int uthicker = unit + uthick; | ||
| Line 34: | Line 36: | ||
The decision to display one direction of lines as white and the other as black triggers our evolved perception to create depth within this two-dimensional image. Our eyes inform us that there is a light source that is reflecting off one directional edge and creating a shadow on the other. The angle at which the lines terminate in this program enhance the affect by occlusion and terminating at the edge. This creates an isometric perspective which further enhances the perceived dimensionality in the image. These effects work well in some of the randomly determined configurations and are subverted by others. | The decision to display one direction of lines as white and the other as black triggers our evolved perception to create depth within this two-dimensional image. Our eyes inform us that there is a light source that is reflecting off one directional edge and creating a shadow on the other. The angle at which the lines terminate in this program enhance the affect by occlusion and terminating at the edge. This creates an isometric perspective which further enhances the perceived dimensionality in the image. These effects work well in some of the randomly determined configurations and are subverted by others. | ||
| + | After some reflection, we realized that despite all of the random options in the newly defined program, the line weight remains constant throughout. To check the visual effect of selecting a random line weight, we simply moved the code lines 6-8 to the beginning of the for loop. The result is shown in figures ?? and ??. At this stage, the program has moved significantly away from its parent and has emerged as a qualitatively unique algorithm. | ||
| + | |||
| + | |||
[[File:P5-10PRINT-03.png|400px|thumb|center|]] | [[File:P5-10PRINT-03.png|400px|thumb|center|]] | ||
[[File:P5-10PRINT-01.png|400px|thumb|center|]] | [[File:P5-10PRINT-01.png|400px|thumb|center|]] | ||
| Line 40: | Line 45: | ||
[[File:P5-10PRINT-105.png|400px|thumb|center|]] | [[File:P5-10PRINT-105.png|400px|thumb|center|]] | ||
[[File:P5-10PRINT-212.png|400px|thumb|center|]] | [[File:P5-10PRINT-212.png|400px|thumb|center|]] | ||
| − | [[File:P5-10PRINT-951.png|400px|thumb|center|]] | + | |
| + | [[File:P5-10PRINT-XXX.png|400px|thumb|center|]] | ||
