p5js/sketch.js

35 lines
733 B
JavaScript
Raw Normal View History

2022-12-10 09:35:14 +00:00
function setup() {
2022-12-12 12:04:55 +00:00
createCanvas(600, 600);
2022-12-11 13:52:13 +00:00
angleMode(DEGREES);
2022-12-12 12:04:55 +00:00
pixelDensity(1);
colorMode(HSB);
cursor(CROSS);
2022-12-11 13:52:13 +00:00
frameRate(60);
2022-12-10 09:35:14 +00:00
}
function draw() {
2022-12-12 12:04:55 +00:00
background(0);
drawGrid();
textInfo();
}
function drawGrid() {
push();
stroke(255, 64);
strokeWeight(1);
for (let x = 0; x < width; x += 10) line(x, 0, x, height);
for (let y = 0; y < height; y += 10) line(0, y, width, y);
pop();
}
function textInfo(title, date, name = "赵海洋爸爸") {
2022-12-11 13:52:13 +00:00
push();
2022-12-12 12:04:55 +00:00
noStroke();
fill(255);
text(`作品:${title}`, 30, height - 70);
text(`作者:${name}`, 30, height - 50);
text(`日期:${date}`, 30, height - 30);
2022-12-11 13:52:13 +00:00
pop();
2022-12-10 09:35:14 +00:00
}