emailconfirmed
1,824
edits
|  (add code) |  (syntax hilighting) | ||
| (One intermediate revision by the same user not shown) | |||
| Line 5: | Line 5: | ||
| <br style="clear:both"> | <br style="clear:both"> | ||
| < | ==== Robot Code ==== | ||
| <source lang="python"> | |||
| """ | """ | ||
| Line 79: | Line 81: | ||
| </pre> | </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) | |||
| </source> | |||