CSC-151-02: A Procedure is Worth a Thousand Pictures Jennelle Nystrom, Colin Tremblay and Julia Daniels DESIGN STATEMENT Our series explores the effects of donut shapes and colors on an image. Though the shape we use is constant, the location of each selection and its thickness vary. At times, the donuts overlap; at other values they are more spread out. Each instance creates an interesting composition that either focuses on balance or movement. When the donuts overlap, the shapes they combine to produce and the contrast between background and foreground colors lead to fascinating juxtapositions between the positive and negative space. When rendered with the turtles, the donuts take on a new role in the play of positive and negative space. If the value n is divisible by 4, the turtles draw on the areas outside the donuts, meaning the rings now function as the negative space on the turtle graphic. In cases where n is even but not divisible by four, the turtles draw inside the donuts and the area outside the donuts is filled in. The turtle polygons are only visible through the positive shapes of the donuts, treating the viewer to a glimpse of the shape beyond and generating curiosity at what lies behind the donuts. Our image no longer relies on color-blends in the donuts and background space. We believe that the solid color is more powerful and visually coherent than a blend or a gradient. As for the aspect ratio, we believe our image looks the best on a square or nearly square canvas. Though image-series will work just as well on rectangular canvases, a square makes the donuts perfect circles, which we think is more visually pleasing. TECHNIQUE STATEMENT Our first step in the image process is selecting the target shapes. To make sure they are in varying locations, we built lists of different height and width positions. These lists both have a prime number of values to increase the number of combinations we can make. We also built a list of different thickness ratios to make each target a different thickness. The next step is to select from these lists. Instead of just using n as a modulus, which would return only one value each time it is called, we wrote a locally-bound procedure called “choose” that adds a value of our choosing to n to make sure the same element of a list is not selected twice with the same value of n. After, we implemented the “choose” procedure to build two new lists, lpos and tpos, that contain possible left and top values for our donuts and vary with each different value of n. Therefore, our first algorithmic technique is storing data in lists. After we've generated lists of possible positions, we wrote another locally-bound procedure, select-circle, that calls image-select-donut! With different values of our lists lpos, tpos and thickness based on v, which corresponds to the value we list-ref from each list. For example, if v=0, we take the first value of lpos, tpos and thickness and use them to create a new donut selection. The height and width of the new donut is based on a ratio of the image-width or height and a predetermined value, r, to make the selection scalable. Within our select-circle procedure, we also included a conditional that teleports a turtle to the center of the ring if n is even. Though we never move this turtle within the circle-generator procedure, it is used in our final call to image-series. Once all the procedures and lists for circle-generator are locally bound, the body of the procedure calls select-circle five times using for-each. When circle-generator is called, five donut shapes will be selected. This process utilizes our second algorithmic technique, which involves using GIMP context tools to select the donuts. After circle-generator was written and working, we began our image-series procedure. When image-series is called with n, width and height, it first creates a new image with image-width width and image-height height. It then fills the background of this image with the rgb-color “beige,” which we chose for its neutrality and relative harmony with other colors. Once these initial steps are complete, image-series evaluates n using a modulo of n and 3 to determine if n is divisible by 3. If the remainder is zero (and thus n is divisible by 3), image-series proceeds to call circle-generator three times with values of n/2, n and n+41 to create three sets of five donuts in varied locations. Writing this part of the code was especially difficult for us because we needed to find a way to left-section circle-generator, which originally had three parameters: image, turtles and n. To solve the issue, we cons image onto turtles. We were then able to reduce circle-generator down to two parameters, but kept it equally functional by immediately taking the car and cdr of the list “image-turtles” to separate the image from the list of turtles. This allowed us to left-section circle-generator, making it easier for us to apply it to our list of n values. If n is not divisible by 3, image-series proceeds to call circle-generator only once, selecting five donuts. After it has either these 5 or 15 donuts selected, it proceeds to the cond portion of the code. If n is odd and greater than 500, image-series fills the selected donuts with a color selected by modulating through our list colors2, which is a list of all named colors other than beige that has been reversed to make it different from the list colors, which appears later in our code. If n is not odd and greater than 500, image-series proceeds to the next cond statement and evaluates if n is odd and less than 500. If this test returns true, image-series performs a process similar to when n is odd and greater than 500, but this time it inverts the selection first to fill the background of the image and leave the donuts beige. If n is not odd, image-series proceeds to the next cond statement, which uses a technique similar to image-series's first “if statement,” and implements a modulo to determine if n is divisible by 4. If n is, image-series selects the inverse of the image (the space outside the circles and in their centers) and commands the turtles positioned in the donuts' centers (from running the circle-generator procedure with an even value of n) to run turtle-spin-polygon!, a procedure from our “Producing Playful Polygons” Assignment. To this procedure, we added color as a parameter so that we could call it using the blend procedure from our “Exploring Colors” assignment. The blend procedure takes a color determined by modulating through the list colors (a list of all named colors other than beige) and blends it with its complement in 5 steps. The 5 colors between the color selected and its complement become the colors of our 5 spun polygons from turtle-spin-polygon!. Our initial concern with using turtle graphics was that they would not scale. We treated this issue by making the side-lengths of our spun polygons vary by a ratio of image-width and 500. We chose 500 because we believe our best images are rendered on 500x500 canvases. The one drawback of this technique is that the turtles will not scale with height, but it is sufficient in scaling the turtles when the image is square or close to square. Our final algorithmic technique, therefore, is writing instructions for turtle graphics. If n is even and not divisible by four, image-series proceeds to the else section of our cond statement. If it reaches this part of the procedure, it spins the turtles using the same technique above while the donuts are selected so that the lines produced by the turtles only show up within the donuts. After doing so, it inverts the selection and fills the background and the centers of the donuts with a color chosen from colors2. Image-series then deselects everything and displays the finished image. The three main algorithmic techniques we used were the GIMP context tools, turtle graphics and storing data in lists. We know our procedure will produce at least 1000 distinct images vary the position of each donut and the color and type of each image. We also use lists of prime numbers to ensure that we will not get repetitive combinations. Three values of n which produce especially captivating images are 8, 18 and 549. REVISIONS The first main change in our strategy was deciding not to implement fractals. We chose against them because they did not seem particularly interesting and did not have a lot of room for interesting variability. We kept our original idea of using donuts that vary by size, position and thickness, but produced them in a new way, with our circle-generator procedure. We also stuck to our original intention of modulating through lists to increase variability, and much of our procedure relies on this technique. Like our original proposal suggested, our final procedure uses color-blends but has them selecting the colors of the turtle shapes instead of the background color. As for selecting colors, we still modulate through a list of colors, but use already named colors instead of individual components to make sure our colors are visually appealing and not too random. Finally, we use turtles as we proposed but use only turtle-spin-polygon because it goes better with our circular donut shapes. The locations of our turtles are still based on n, but in an indirect manner as they are more closely tied to the donuts than they are to the n value.