For this assignment you will do some graphics programming using a simple graphics library included with DrScheme, the "viewport graphics library". The documentation for this library is contained in the manual "PLT Miscellaneous Libraries: Reference Manual", which is part of DrScheme's built in documentation. The fastest way to get to this online documentation is to start DrScheme, go to the Help menu and click on the first menu item, "Help Desk", and then use the Help Desk's search box to search for the string "viewport graphics". You can also read this documentation over the Internet at the following URL: This assignment has three problems. The first two problems have you draw "recursive," fractal images and for the third problem you will draw an iterative, "bitmapped" image. 1.) Write a Scheme program that draws a "Sierpinski triangle". This is a fairly simple fractal image. It is defined by taking a triangle, dividing the triangle into four sub-triangles (by bisecting each of the three sides of the original triangle) and then recursing on three of the four sub-triangles (the three which have a vertex in common with the original triangle). Click repeatedly on either of the triangles below to watch how a Sierpinski triangle is built up (these are drawn by a Java applet). 2.) Write a Scheme program that draws a "C-curve". A C-curve is a slightly more complicated fractal than a Sierpinki triangle. A C-curve is defined by starting with a line segment, and then replacing the line segment with two line segments in such a way that the two new line segments, along with the original line segment, make up an isosceles right triangle with the original line segment as the hypotenuse and the two new line segments as the legs. After the original line segment is replaced by the two new line segments, we recurse on each of the two new line segments. Click repeatedly on the line segment below to see how a C-curve is built up. After each click, the green segments are the segments that were replaced to get the next stage of the development of the C-curve.
3.) In this problem you will draw an image that is defined pixel by pixel in an iterative manner. The image will be drawn in a 400 by 400 pixel graphics window. Your program will set every pixel in the graphics window to either black or white. Here is an algorithm for deciding the color of any given pixel. First, choose a square region in the mathematical xy-plane. This square region is determined by choosing three numbers, the x and y coordinates of the upper left hand corner of the square region and the dimension of the sides of the square. Denote these three numbers by
The images drawn by this algorithm depend on the choices of the three parameters
x^2+y^2 , use the expression sqrt(x^2+y^2) .
4.) To help you get started with graphics programming in Scheme using the viewport graphics library, here is a Scheme program, koch-curve.scm, that draws a fractal called a Koch Curve. A Koch Curve is defined by starting with a line segment, dividing the line segment into three equal length pieces, and then replacing the middle piece with two line segments in such a way that the two new line segments, along with the replaced piece, make up an equilateral triangle. After the middle piece is replaced by the two new line segments, we recurse on each of the four remaining line segments. Click repeatedly on the line segment below to see how a Koch Curve is built up. |