sketch.js
let mode = 1;
function setup() {
createCanvas(600, 600); //ウィンドウサイズの指定
background(255, 255, 255); //背景色を指定して1回だけ塗る。
stroke(100, 100, 100);
fill(251, 234, 183);
circle(300, 300, 500);
noFill();
circle(300, 300, 600);
fill(255, 220, 123);
circle(300, 300, 450);
line(300, 50, 300, 550);
line(50, 300, 550, 300);
line(125, 125, 475, 475);
line(125, 475, 475, 125);
fill(255, 0, 0);
noStroke();
text("Let's cooking PIZZA!", 450, 20);
text("1,2,3を押してぐざいを変えよう", 20, 580);
}
function draw() {
// background(0, 0, 0); //背景色を指定して1回だけ塗る。
if (mouseIsPressed == true) {
if (mode == 1) {
fill(255, 0, 0);
noStroke();
circle(mouseX, mouseY, random(50, 20));
}
if (mode == 2) {
fill(255, 255, 255);
noStroke();
circle(mouseX, mouseY, random(40, 30));
}
if (mode == 2) {
fill(255, 255, 255);
noStroke();
circle(mouseX, mouseY, random(40, 30));
}
if (mode == 3) {
fill(35, 105, 0);
noStroke();
let a = random(40, 30);
triangle(
mouseX,
mouseY,
mouseX - a / 2,
mouseY + (a / 2) * 1.73,
mouseX + a / 2,
mouseY + (a / 2) * 1.73,
);
}
}
}
function mousePressed() {
//マウスのボタンが押し下げられた時の処理
}
function mouseReleased() {
//マウスのボタンが離された時の処理
}
function keyPressed() {
if (key == "1") {
mode = 1;
}
if (key == "2") {
mode = 2;
}
if (key == "3") {
mode = 3;
}
if (key == "s") {
saveCanvas();
}
}