Animations, Interactivity
Refresher on trigonometry and how to use it in the setting of an animation.
A first look at making interactive sketches with mouse and keyboard inputs
What we covered last time
This notion might be important when teaching the students, there's three ways to declare variables in JavaScript:
if(true){
let x = 1
console.log(x)
}
console.log(x)
Trigonometry is super useful when we want to place things along the circumference of a circle - we don't actually need to know the math or anything, just think about it intuitively. It's a very important tool in creative coding!
For example, if we want to draw a circle of points on the canvas, how would we do it? Compute point coordinate with cos() and sin()
rad = 100
angle = PI
let x = 200 + rad * cos(angle)
let y = 200 + rad * sin(angle)
strokeWeight(5)
stroke(255,0,0)
point(x, y)
Next: How do we animate this?
The easiest way to think about this is that we're converting from cartesian to polar coordinates.
We need a counter to increment the animation and redraw it:
Instead of a simple rotation, we can modify the rotation parameters and modulate them to obtain interesting shapes.