'Populate custom shape (vertex) with dots in p5
Trying to populate this red custom shape with dots like the ellipse. See image / code example below. Any help would be appreciated.
This Populating a circle with dots, using bias towards the edge of the cirlcle explains how to populate an ellipse but how to do the same technique in a custom shape?
Image with explanation of what I'm trying to do
function setup() {
createCanvas(750, 750);
background(0);
noStroke();
fill(255);
noLoop();
}
function draw() {
translate(width / 2, height / 2);
for (let i = 0; i < 5000; i++) {
let theta = random(0, TWO_PI);
let h = randomGaussian(3.3); //experiment with different means
let r = (exp(h) - 1) / (exp(h) + 1);
let x = width / 2 * r * cos(theta);
let y = height / 2 * r * sin(theta);
ellipse(x,y,1,1);
}
// Trying to populate this custom shape with dots like the above ellipse
beginShape();
fill("#ff0000");
vertex(179, 136);
quadraticVertex(245, 30, 400, 140);
bezierVertex(430, 360, 174, 306, 176, 211);
endShape(CLOSE)
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
