xxxxxxxxxx
72
function setup() {
createCanvas(600, 600);
}
function draw() {
background(255);
//one();
//two();
// line (x1, y1, x2, y2);
three();
//four();
//five();
//six();
}
function one() {
for (let i = 0; i <= 400; i+= 20) {
if ( i % 40 === 0) { // modulus,
fill(255, 0, 0);
} else {
fill(0, 0, 255);
}
circle(i, 200, 10);
}
}
function two() {
for (let x = 0; x < 400; x+=10) {
line (x, 0, x, 200);
}
for (let y = 200; y < 400; y += 10) {
line(0, y, 400, y);
}
}
function three() {
for (let i = 0; i < 400; i++) {
line(i * 20, 0, i * 20, i*i);
}
}
function four() {
for(let y = 0; y < 255; y+=2) {
fill(255, y, 0);
noStroke();
rect(0, y * 3, 300, 4);
}
}
function five() {
for (let x = 0; x < 600; x += 10) {
let y = 200;
let segment = 20;
if (x % 70 === 0) {
line(x, y - 100, x, y + 100);
} else {
line(x, y - 50, x, y + 50);
}
}
}
function six() {
for (let x = 0; x < 400; x += 10) {
for (let y = 0; y < 400; y += 10) {
circle(x, y, 5);
}
}
}