Skip to content

Instantly share code, notes, and snippets.

@cdr6934
Created March 24, 2023 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdr6934/fcbf717b7c7d0446f0c024dde364c161 to your computer and use it in GitHub Desktop.
Save cdr6934/fcbf717b7c7d0446f0c024dde364c161 to your computer and use it in GitHub Desktop.
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