help (serpentining)

edited May 2015 in How To...

could someone help me get started on this project?

  1. Make a row of 20 squares. Make their fill colour gradually change from white to black, slowly over time.

  2. Now make them go back to white, slowly over time.

  3. Now make it look as though the change occurs as a "wave" of white moving through the row of boxes, from left to right (and then wraps). (If this sounds weird, don't worry, I'll explain at the board.)

  4. CHALLENGE: Now, instead of a single row, make it a 20x20 grid of squares! The "ripple" propagates through the grid, one row at a time: left to right in row 1, then right to left in row 2, etc. This is called "serpentining", for reasons which may or may not be obvious :)



  • make a basic sketch with setup() and draw()

    make a for-loop and paint rects in a row

  • edited May 2015
    void setup() {
      for (int j = 0; j < 20; j=j+1) {

    i got this what should be the next code?

  • edited May 2015

    Make their fill colour gradually change from white to black,

    use a variable to do so

    color myFill = color (0);

  • edited May 2015

    you need a function draw() (as I have written before)

    and have the for-loop in draw()

    use background(0); at the beginning of draw()

  • edited May 2015

    just read the assignment and make it step by step...

    to format your code in your post properly:

    • go back, edit your post

    • leave 2 empty lines before and after

    • select the code

    • hit ctrl-o

  • come back when you have a question

  • the tasks

    1. we discussed - the var starts with 255 and gets -- . All rects same color.

    2. when it becomes zero instead of -- use ++; can you think of a better way? Once we add -1, once we add 1. All rects same color.

    3. Now, All rects different color. Store color in an array, each rect has it's own color. Start it off with different colors like 0,10,20....

    4. "serpentining" is what a road does that goes up a steep mountain. Hint: to fill the grid use a double (nested) for-loop.


Sign In or Register to comment.