Sayaka
Aus exmediawiki
p5 code 1
let i = 0; let i2 = 0;
function setup() {
//createCanvas(400, 400);
createCanvas(400, 400, SVG);
//noLoop();
angleMode(DEGREES);
rectMode(CENTER);
frameRate(7);
background(220);
textSize(30);
textStyle(BOLD);
textFont("Arial");
angleMode(DEGREES);
}
function draw() {
if (i < 500) {
noFill();
stroke(random(0,100),random(100,200),random(200,255));
push();
translate(width / 2, height / 2);
rotate(0 + i);
rect(-50, -50, 10+i, 20-i);
pop();
push();
translate(width / 2, height / 2);
rotate(0 + i);
rect(0, 0, 10+i, 20+i);
pop();
push();
translate(width / 2, height / 2);
rotate(0 + i);
rect(50, 50, 10+i, 20-i);
pop();
i = i + 1;
noFill();
stroke(255);
line(mouseX,mouseY,random(-1000,1000), random(-1000,1000));
rotate(0 + i);
console.log('positive');
} else {
noFill();
stroke(255,123,255);
push();
translate(width / 2, height / 2);
rotate(0 + i2);
rect(-50, -50, 10+i2, 20-i2);
pop();
push();
translate(width / 2, height / 2);
rotate(0 + i2);
rect(0, 0, 10+i2, 20-i2);
pop();
push();
translate(width / 2, height / 2);
rotate(0 + i2);
rect(50, 50, 10+i2, 20-i2);
pop();
i2 = i2 + 5;
console.log('negative');
}
}
function mousePressed() {
save("mybrushybrush.svg");
print("saved svg");
}
p5 code 2
let wordCount = 10
function setup() {
createCanvas(400, 400, SVG);
background(255);
//div.center();
//rectMode (CENTER);
noLoop();
//console.log(10+10);
textSize(60);
textStyle(BOLD);
textFont("Arial");
angleMode(DEGREES);
}
function draw() {
fill(230, 245, 245); noStroke(); rect(50, 50, 300, 300);
strokeWeight(1); noFill(); let yPos = 15; let xPos = 15; let R = 000; let G = 255; let B = 255;
for (let i = 0; i < 160; i++) {
console.log(i);
stroke(R + i * 4, G - i, random(0, 255));
rect(xPos + i * 2, yPos + i * 2, 50 + i, 50 + i);
}
stroke(000);
for (let n = 0; n < 12; n++) {
let y = 80;
let x = 285;
let hw = 35;
stroke(000);
noFill();
rect(y - n * 2, x + n, hw + n, hw + n);
}
rect(280, 80, 40, 40);
noFill();
rect(281, 78, 41, 41);
noFill();
rect(282, 76, 42, 42);
noFill();
rect(283, 74, 43, 43);
noFill();
rect(284, 72, 44, 44);
noFill();
rect(285, 70, 45, 45);
noFill();
rect(286, 68, 46, 46);
noFill();
rect(287, 66, 47, 47);
noFill();
rect(288, 64, 48, 48);
noFill();
rect(289, 62, 49, 49);
noFill();
rect(290, 60, 50, 50);
noFill();
rect(291, 58, 51, 51);
noFill();
rect(292, 56, 52, 52);
push();
noStroke();
fill(000,255,200);
translate(width / 2, height /2);
for(let i = 0; i < wordCount; i++){
rotate(360/wordCount);
text("S", 0, 0);
}
pop();
}
function mousePressed() {
save("mybrushybrush.svg");
print("saved svg");
}