emailconfirmed
1,824
edits
|  (add code) | No edit summary | ||
| Line 4: | Line 4: | ||
| <br style="clear:both"> | <br style="clear:both"> | ||
| ==== Robot Code ==== | |||
| <pre style="font-size:smaller" > | <pre style="font-size:smaller" > | ||
| Line 77: | Line 79: | ||
|      rect(0, 0, 20, 150) |      rect(0, 0, 20, 150) | ||
|      popMatrix() |      popMatrix() | ||
| </pre> | |||
| ==== While and If Else Code ==== | |||
| <pre> | |||
| d = 5 | |||
| size(200, 200) | |||
| colorMode(HSB, 1) | |||
| background(0) | |||
| strokeWeight(d-1) | |||
| x = 0 | |||
| # go all the way | |||
| while x < 200: | |||
|     # increase by strokeweight | |||
|     x = x + d | |||
|     # color based on x-position | |||
|     if x < 50: | |||
|         stroke(0, 1, 1) | |||
|     elif x < 100: | |||
|         stroke(0.2, 1, 1) | |||
|     elif x < 150: | |||
|         stroke(0.3, 1, 1) | |||
|     else: | |||
|         stroke(0.4, 1, 1) | |||
|     line(x, 0, x, 200) | |||
| </pre> | </pre> | ||