Learn creative coding writing simple programs
33. Use multiplication to scale up or down speeds and sizes
Multiplication is something we often use in our programs, so it's important to feel comfortable with it. In programming languages, the sign used for multiplication is the asterisk: *. When we multiply any number by 1, we get the same number: 77 * 1 = 77. When we multiply by a number larger than 1, we get a number larger than the original number: 77 * 1.2 = 92.4. When we multiply by a positive number smaller than 1, we make it smaller: 77 * 0.8 = 61.6. Knowing these simple rules we create a program where objects move a different speeds. We also update the program we created with 5 rotating rectangles to give each rectangle a different rotation speed.
Code editor
You can make changes to the code below. Then
Reference
background
draw
ellipse
fill
float
noStroke
rect
rectMode
resetMatrix
rotate
setup
size
translate
void
background
draw
ellipse
fill
float
noStroke
rect
rectMode
resetMatrix
rotate
setup
size
translate
void
Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)
To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:``` void setup() { size(600, 600); } ```