Activity 4

advertisement
PROGRAMMING MODULE – ACTIVITY 4
OBJECTIVES
Design and code a picture with balloons and a present using basic DrScheme drawing commands.
Practice technical reading skills
Practice plotting points and calculating values based on patterns, algebra and geometry concepts.
PREPARATION
1. Review activity 2 where you plotted points on graph paper from the completed code for the person picture.
2. Look at the sample balloon picture that I did. Look at pictures by other students to get ideas on creative attributes.
3. Label a sheet of graph paper with your name, period, date, and the title “BALLOONS”
4. Label grid numbers on that graph paper per sample in activity 2.
5. Open up Scheme and start a canvas that has proportion of 4 by 3. (Ratio 4 : 3) with the horizontal length larger then 500
pixels. Remember, to solve proportion problems set up an equation with the widths on the top and heights on the
bottom. One of the dimensions will be a variable. Cross multiply to solve the equation. Ask for help if needed.
DO: List 3 dimensions you could use in your journal. Show the calculations.
 STEP ONE
1.
2.
3.



4.
5.
6.



Document the description of this segment of code by adding a comment with 2 semi-colons in front.
Define a name for this section
Draw a black rectangle the size of your canvas.
The coordinate of the position will be (0, 0) since you are starting at the top left corner. Remember that this is opposite
what you do in math for the y-coordinate because you are working on a monitor,
not the Cartesian plane.
(0,0)
The horizontal length of the rectangle will be the first parameter in the start
command that started your canvas.
The vertical height of the rectangle will be the second parameter in the start
command that started your canvas.
On graph paper plot where you would like to start the grass. Record the height of
your rectangle on the graph paper by counting the lines.
(0, 450)
Draw a horizontal line on graph paper to show the location of the grass.
Draw a green rectangle to represent the grass.
The position will be the coordinates of the top left corner of the grass.
The horizontal length will be the same as in the black rectangle for the length
The height will be the difference between the vertical size of the canvas and the
y-coordinate of the position of the start of the grass.
Subtract 480 and 450 (- 480 450) = 30
Sample Code:
;;Define a constant for black background with green grass on bottom
(define BACKGROUND
(and
(draw-solid-rect (make-posn 0 0) 640 480 'black)
(draw-solid-rect (make-posn 0 450) 640 30 'green))
Note: Do NOT use 30 as the height of the grass. Change the value!
You may use 640 by 480 for the canvas size.
7.
8.
Click EXECUTE to see if your code worked.
Look at the feedback on the Interaction window if there was an error.
9.
DO: Write down any error message you have in your journal.
10. See if you can debug yourself by looking at the BOOK of ERRORS with possible solutions.
11. Compare your code with the sample.
12. If you can’t find the error type the sample code, study, and try again.
 STEP TWO – Activity 3
Note: The directions will not be as detailed as in the first step.
You need to look at the sample code, think and apply previous learning.
1.
2.
3.
4.
5.
6.
Draw 3 – 5 circles on your graph paper where you would like your balloons
Plot the center coordinates of each point
Use the commands draw-circle and draw-solid-disk to create the balloons, which takes 3 parameters:
The position for the first parameter is the center of the circle you plotted.
The next parameter is the radius. Count the lines to calculate an estimated size.
Pick a color from ‘red, ‘blue, ‘yellow, ‘green, or ‘white and add as the 3 rd parameter.
DO: In your journal answer: Why can’t you use ‘black for the color of a circle?
(150, 200)
(320, 150)
(450, 250)
Sample Code:
(define BALLOONS
(and
(draw-circle (make-posn 150 200) 40 'red)
(draw-circle (make-posn 150 200) 39 'red)
Note: The first circle is repeated 3 times to add thickness.
(draw-circle (make-posn 150 200) 38 'red)
The radius is decreased by one. Try variations!
(draw-solid-disk (make-posn 320 150) 50 'yellow)
(draw-solid-disk (make-posn 450 250) 40 'blue)))
Note: Do NOT use the same
positions or dimensions that I used. Change the value!
DO: In your journal
1. Write a command that will draw a green circle with a radius of 70 pixels at the coordinates
(100, 200).
2. Write a command that will draw a red circle inside the previous circle from question 2 with a radius
that is 10 pixels smaller.
3. Write a command that will draw a blue circle inside the previous circle with a radius that is reduced
using the same pattern established in question 2.
4. What 2 parameters are changing, and what parameter is remaining constant?
5. Record how this pattern can be applied to create creative balloon designs.

1.
2.
3.
4.
5.
STEP THREE
Draw lines from the center bottom of each balloon to represent the strings on your graph paper; estimate the length.
Under each set of balloon code, add a command to draw a solid line, which takes 3 parameters.
The first parameter is one of the end points.
The X-coordinate of the point will stay the same as the X-coordinate of the circle the string is connected to.
The Y-coordinate of the point will be the sum of the radius and the Y-coordinate of the circle above.
Sample Code:
6. To create the second end
;;Defines a constant for 3 balloons with strings
point of the line add whatever
(define BALLOONS
length you would like the string
(and
to the y-coordinate of the first
point.
(draw-circle (make-posn 150 200) 40 'red)
(draw-circle (make-posn 150 200) 39 'red)
(draw-circle (make-posn 150 200) 38 'red)
(draw-solid-line (make-posn 150 240) (make-posn 150 350) 'white)
(draw-solid-disk (make-posn 320 150) 50 'yellow)
(draw-solid-line (make-posn 320 200) (make-posn 320 300) 'white)
(draw-solid-disk (make-posn 450 250) 40 'blue)
(draw-solid-line (make-posn 450 290) (make-posn 450 380) 'white)))
7.
Step 3 - String
Repeat that process with each balloon.
 STEP FOUR
1. On graph paper draw a sketch of a present with ribbons.
Note: A challenge would be to draw a perspective as learned in the graphics
module.
2. Draw a rectangle for the box.
3. Draw lines to add the ribbons.
4. Decorate the box if you would like.
;;Defines a constant for present with a ribbon
(define PRESENT
(and
… You are on your own now since you know the commands.
.. )))
DO: In your journal tell what the Boolean operator “and” does in each definition.

STEP FIVE
1. Draw a bow using the drawing commands.
2. Define a constant for that bow per samples.
3. Add anything else you would like to enhance your picture.
4. Review the CODE CHART handout for reference as needed.
DO: Raise hand to get your final picture softcopy graded. After approved, print a final copy for your
journal portfolio binder.
NEXT LESSONS
 ACTIVITY 5: Add your Balloon graphic to a web page with a description of how you created your
graphics. Create a list of errors and a description of how you debugged these errors.
 PROJECT: Create a web page and add to your portfolio of all your programmed graphics and code.
Download