Consider the Cliches

No man is an island.

There is no such thing as a new idea.

Everything is related to everything else.

It’s all relative.

Syntax Full Formula Meaning
x++ x = x + 1 Increase x by 1
x-- x = x - 1 Decrease x by 1
x += n x = x + n Increase x by n
x -= n x = x - n Decrease x by n
x *= n x = x * n Multiply x by n
x /= n x = x / n Divide x by n

p5. Canvas

image.png

The center point is always (width/2, height/2), so its position changes when the width or height of the canvas changes, but it always stays in the center. This is a positive relationship because when the width or height increases, the x or y position of the center also increases proportionally. Instead of thinking of position as a fixed value, I can think of it as a relationship between variables. It is also a diminishing relationship because the center position changes by half the amount that the canvas dimension changes.

Canvas width  = width
Canvas height = height
Canvas slope = height /width

Center X = width / 2
Center Y = height / 2

p5. Canvas & Rectangle

image.png

I drew this diagram to understand how the position and size of a rectangle can be related to the canvas. Instead of using fixed numbers, I can use width and height as variables. If the rectangle starts at (width/4, height/4) and its dimensions are width/2and height/2, its center will always be (width/2, height/2). This means that when the canvas becomes larger or smaller, the rectangle changes proportionally and stays in the center.

rect(width/4, height/4, width/2, height/2);

p5. Canvas & Circle/Oval

image.png