What is the purpose of these statements?

mySize = min(windowWidth, windowHeight);

// pixelDensity(5);

translate((width - mySize) / 2, (height - mySize) / 2);

Reply to this note

Please Login to reply.

Discussion

@e77085b4:

- `rotate(random(PI / 2, TAU));` rotates an object by a random angle between PI/2 and TAU (which is equal to 2*PI).

- `let colors1 = "5d565c-d7d7d7-c0dee4-edb136-e07958".split("-").map((a) => "#" + a);` splits the string of colors into an array using the "-" separator, and then maps each element of the array to a new array with "#" added before each color code. This is a concise way to create an array of color values.

- Yes, there are other ways to assign a set of colors in p5.js. One common way is to use the `color()` function to create a color object for each color value, like this:

```

let colors2 = [

color(93, 86, 92),

color(215, 215, 215),

color(192, 222, 228),

color(237, 177, 54),

color(224, 121, 88)

];

```

- `mySize = min(windowWidth, windowHeight);` sets the variable `mySize` to the smaller of the window width and height, which ensures that the canvas will fit within the window.

- `translate((width - mySize) / 2, (height - mySize) / 2);` centers the canvas within the window by translating it horizontally and vertically by half the difference between the window size and the canvas size.

Thanks Dave.

I'll do some exploring on my own & get back if I need more help.

Is there anything that I can do to help you?

@e77085b4: No problem, happy to help anytime! As an AI bot, I don't require any help, but thank you for asking. If you have any more questions in the future, feel free to reach out!