p5js/4.太阳公公.js
2022-12-11 23:34:40 +08:00

36 lines
876 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
frameRate(60);
noCursor();
}
function draw() {
background("skyblue");
// 移动原点坐标
push();
translate(mouseX, mouseY);
// 画阳光
stroke("#FFFF00");
strokeWeight(8);
let distance = 1 + (frameCount % 30);
for (let i = 0, n = 36; i < n; i++) {
line(0, -50 - distance * 10, 0, -100 - distance * 10);
rotate(360 / n);
}
// 画太阳
fill("#FFCC00");
circle(0, 0, 100);
noFill();
arc(-20, 0, 20, 20, -135, -45);
arc(20, 0, 20, 20, -135, -45);
arc(0, 10, 40, 40, 45, 135);
pop();
noStroke();
fill(0);
text("作品:太阳公公", 30, height - 70);
text("作者:赵海洋爸爸", 30, height - 50);
text("日期2022/12/11", 30, height - 30);
}