top of page
  • Writer's pictureYang Xu

Self - Portrait



1. What are possible arguments for rect()? Come up with 2 sets.

2. Draw a rectangle in the middle of the screen that is half the width and half the height of the canvas. Write it so that you can change the size of the canvas and the rectangle will stay in the center and maintain its size relationship to the canvas.

3. Re-draw the rectangle using line(). Challenge: Write it so that you can easily change the location and size relationship with the canvas.

4. Move a circle from the middle of the screen to the right side of the screen.

a. Add 3 more, 1 moving left, 1 moving up, 1 moving down.

b. Add 4 more, 1 moving towards each of the 4 corners of the canvas.

c. Make one of your circles move 10 times faster than the other circles.

d. Challenge: Re-write 4b. so if I change the width of the canvas, the circles still go to the corners without having to change any other code.

5. Challenge: Move a circle towards the mouse. Hint: Use mouseX + mouseY.

6. Challenge: Move your rectangle from Q3 towards the mouse.

24 views0 comments

Recent Posts

See All
bottom of page