Learn creative coding writing simple programs
29. Rectangle spinning around the mouse pointer
In this episode we finally see how to rotate a rectangle around its own center. We add the fade-out effect to make the rectangle leave a nice blurry trail behind it, and changing just one line we make it spin around the mouse position.
Key ingredients for this episode are rectMode(), rotate() and translate().
Code editor
You can make changes to the code below. Then
Reference
background
draw
fill
float
height
mouseX
mouseY
noStroke
random
rect
rectMode
rotate
setup
size
smooth
translate
void
width
background
draw
fill
float
height
mouseX
mouseY
noStroke
random
rect
rectMode
rotate
setup
size
smooth
translate
void
width
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); } ```