title |
categories |
keywords |
tags |
date |
柏林噪声1D |
|
|
|
2022-09-18 16:45:10 |
let offset = 0
let ratio = 0.01
let speed = 0.01
function setup() {
createCanvas().parent(p5Container)
windowResized()
noiseDetail(2, 0.5)
strokeWeight(2)
stroke('blue')
noFill()
}
function draw() {
background(200)
beginShape()
for (let x = 0; x < width; x++) {
const y = noise(offset + x * ratio) * height
vertex(x, y)
}
endShape()
offset += speed
}
function windowResized() {
const width = p5Container.offsetWidth;
const height = Math.round(9 * width / 16);
resizeCanvas(width, height);
}