変数は、値を格納するために使用されます。この例では、変数の値を変更して構成に影響を与えます。
variables line
Data
View Source Code
/*
* @name Variables
* @arialabel Black background with three sets of grey lines that form rectangles.
* @description Variables are used for storing values. In this example, change
* the values of variables to affect the composition.
*/
function setup() {
// createCanvas(720, 400);
createCanvas(windowWidth, windowHeight);
background(0);
stroke(153);
strokeWeight(4);
strokeCap(SQUARE);
let a = 50;
let b = 120;
let c = 180;
line(a, b, a + c, b);
line(a, b + 10, a + c, b + 10);
line(a, b + 20, a + c, b + 20);
line(a, b + 30, a + c, b + 30);
a = a + c;
b = height - b;
line(a, b, a + c, b);
line(a, b + 10, a + c, b + 10);
line(a, b + 20, a + c, b + 20);
line(a, b + 30, a + c, b + 30);
a = a + c;
b = height - b;
line(a, b, a + c, b);
line(a, b + 10, a + c, b + 10);
line(a, b + 20, a + c, b + 20);
line(a, b + 30, a + c, b + 30);
}
License
Source code is available on GitHub p5.js website legacy.
All examples are licensed under CC BY-NC-SA 4.0.