Difference between revisions of "CSC103 Homework 5 2012"
(→Hints on how to start with this sketch) |
(→Submission) |
||
Line 45: | Line 45: | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
+ | <onlydft> | ||
+ | <code><pre> | ||
+ | void setup() { | ||
+ | size( 500, 500 ); | ||
+ | smooth(); | ||
+ | } | ||
+ | |||
+ | void draw() { | ||
+ | background( 200 ); | ||
+ | |||
+ | for ( int x=0; x < 500; x = x+20 ) { | ||
+ | fill( x/2, 255-x, 0 ); | ||
+ | rect( 0, x, 500, 20 ); | ||
+ | fill( 250, 200, 8 ); | ||
+ | if ( mouseY < x ) { | ||
+ | ellipse( 20, x+10, 20, 20 ); | ||
+ | } | ||
+ | else { | ||
+ | ellipse( 500-20, x+10, 20, 20 ); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </pre></code> | ||
+ | </onlydft> | ||
[[Category:CSC103]][[Category:Homework]] | [[Category:CSC103]][[Category:Homework]] |
Revision as of 18:08, 29 February 2012
--D. Thiebaut 16:55, 29 February 2012 (EST)
This homework is due on March 7th, 2012, at 9:00 a.m. in class. You can (and are encouraged) to work on this homework in pairs. If you work in pairs, you must find time to work together, and not allow one person to work on the program on his or her own.
Processing Sketch
- Run the video above. This is what your sketch needs to do.
Requirements
- Your sketch must generate the rectangles that we see in the back of the sketch.
- The rectangles must touch
- The rectangles must be of varying color
- The number of rectangles is up to you. At least 10.
- Your sketch must display two columns of circles.
- The circles should fit inside the rectangles. They can be smaller than the width of the rectangles
- The circles can be of any color you want, but not the same color as the rectangle underneath them.
- There should be two columns of circles, one to the left, one to the right.
- The length of the left column should be controlled by the position of the mouse.
- Similarly for the right column of circles.
- The left column must grow from the bottom up
- The right column from the top down.
Hints on how to start with this sketch
Here is how I would recommend you start:
- generate rectangles that are stacked up one on top of the other. You know how to generate a stack of circles (from the lab), so you should be able to generate a stack of rectangle. By the way, the solutions for all the challenges from the Processing lab have been added at the bottom of the lab. Check them out!
- Look at the sketch where you had to change the color of the circles in the lab. Use this method to change the color of the rectangles. You do not have to make them go from green to red, as in the video. Figure out something that makes them go from one color to another. Avoid white...
- Then generate a column of orange circles in the middle of the window, as you did in the lab.
- Adjust the dimensions of the circles so that they each fall inside a rectangle.
- Adjust the locations of the circles so that they are close to the left of the window.
- Generate another column of circles and put them on the right side of the window.
- Once everything works well, make the display of the left column dependent on the location of the mouse.
- Adjust that solution so that it also controls the right-side column.
- You're done!
Submission
- Details of how to submit your program will be given later... stay tuned.