Remarks: Processing Mazes
From Maze
(Difference between revisions)
| Line 4: | Line 4: | ||
When the C64 was launched in 1982, it was a powerful home computer for creating computers graphics. Contemporary hardware is an interesting place to re-imagine the 10 PRINT algorithm because it has changed substantially from its predecessors. For this exploration into re-imaging 10 PRINT, we used Processing, a programming system first designed in 2001. It's built on top of Java, one of the dominant modern programming languages, but Processing is specialized for making graphics and simplifies some of the native Java syntax. Java was first introduced in 1995 and is most similar to C++, which originated in 1983. C++ is an object-oriented programming language built on top of C, a procedural language that originated in the early 1970s. | When the C64 was launched in 1982, it was a powerful home computer for creating computers graphics. Contemporary hardware is an interesting place to re-imagine the 10 PRINT algorithm because it has changed substantially from its predecessors. For this exploration into re-imaging 10 PRINT, we used Processing, a programming system first designed in 2001. It's built on top of Java, one of the dominant modern programming languages, but Processing is specialized for making graphics and simplifies some of the native Java syntax. Java was first introduced in 1995 and is most similar to C++, which originated in 1983. C++ is an object-oriented programming language built on top of C, a procedural language that originated in the early 1970s. | ||
| + | |||
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 the new high-resolution version, the entire maze is refreshed in unison. Without thinking carefully about it, we used the default Processing colors to create white lines and a black background. In hindsight, this imbued the program with a distinct mood 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 the new high-resolution version, the entire maze is refreshed in unison. Without thinking carefully about it, we used the default Processing colors to create white lines and a black background. In hindsight, this imbued the program with a distinct mood from the original lower-contrast blues of the C64. The result is shown in figures ?? to ??. | ||
| Line 17: | Line 18: | ||
10 PRINT CHR$(32+(INT(RND(1)+.5)*81)); : GOTO 10 | 10 PRINT CHR$(32+(INT(RND(1)+.5)*81)); : GOTO 10 | ||
| + | |||
After writing this first variable program in Processing to focus entirely on the image of the maze, it became clear that watching the maze build one unit at a time on the C64 is a major component of the program. This behavior doesn't naturally work with Processing because the entire screen updates as a whole, rather than character by character. Processing uses a technique called double-buffering. This means the graphics are drawn to an off-screen image buffer stored in RAM. When the image is finished, it's pushed to the computer's screen. For programs that feature animation or interaction, the result is a new image being written and drawn to the screen about sixty times a second. Unlike in BASIC, the lines of Processing program aren't assigned numbers; each line is run in order from top to bottom and according to some higher level rules. This becomes more clear when we look at this program written in Processing by Ben Fry, the co-founder of Processing, to approximate the behavior of our 10 PRINT program on the C64: | After writing this first variable program in Processing to focus entirely on the image of the maze, it became clear that watching the maze build one unit at a time on the C64 is a major component of the program. This behavior doesn't naturally work with Processing because the entire screen updates as a whole, rather than character by character. Processing uses a technique called double-buffering. This means the graphics are drawn to an off-screen image buffer stored in RAM. When the image is finished, it's pushed to the computer's screen. For programs that feature animation or interaction, the result is a new image being written and drawn to the screen about sixty times a second. Unlike in BASIC, the lines of Processing program aren't assigned numbers; each line is run in order from top to bottom and according to some higher level rules. This becomes more clear when we look at this program written in Processing by Ben Fry, the co-founder of Processing, to approximate the behavior of our 10 PRINT program on the C64: | ||
| Line 63: | Line 65: | ||
After evaluating the similarities and differences between the C64 and Processing programs, we realized that 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. | After evaluating the similarities and differences between the C64 and Processing programs, we realized that 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 ?? and ?? 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: | ||
