Created
March 24, 2023 20:53
-
-
Save cdr6934/fcbf717b7c7d0446f0c024dde364c161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const drawPaperTexture = (x, y, w, h) => { | |
let cx, cy, rng, cs; | |
rng = 100; | |
push(); | |
translate(x, y); | |
let a = (w + h) * 4; | |
for (let i = 0; i < a; i++) { | |
noStroke(); | |
fill(255, R() * 255); | |
cs = R() * 3; | |
ellipse(R() * w, R() * h, cs, cs); | |
noFill(); | |
if (R() < 0) { | |
stroke(255, R() * 150); | |
beginShape(); | |
cx = R() * w; | |
cy = R() * h; | |
curveVertex(cx, cy); | |
curveVertex(cx + rng * R() * sn(), cy + rng * R() * sn()); | |
cx = R() * w; | |
cy = R() * h; | |
curveVertex(cy + rng * R() * sn(), cy + rng * R() * sn()); | |
curveVertex(cx + rng * R() * sn(), cy + rng * R() * sn()); | |
endShape(); | |
} | |
} | |
pop(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment