setup()
setup() runs once when the sketch starts. Using windowWidth and windowHeight here makes your canvas responsive—it automatically resizes when the browser window is resized (as long as windowResized() is also defined).
function setup() {
createCanvas(windowWidth, windowHeight);
// ヒント: windowWidth/windowHeightを使うと、キャンバスがレスポンシブになります
initializeDots(); // ドットを初期化する関数を呼び出します
}
Line-by-line explanation (2 lines)
🔧 Subcomponents:
createCanvas(windowWidth, windowHeight);
Creates a canvas that fills the entire browser window, adapting to any screen size
initializeDots();
Populates the dots array with initial white dot objects in a grid pattern
createCanvas(windowWidth, windowHeight);- Creates a canvas with width and height equal to the browser window dimensions, making the animation fill the entire screen
initializeDots();- Calls the initializeDots() function to create all the dot objects and populate the dots array