PShape star;
void setup() {
size(640,360,P2D);
// First create the shape
star = createShape();
star.beginShape();
// You can set fill and stroke
star.fill(102);
star.stroke(255);
star.strokeWeight(2);
// Here, we are hardcoding a series of vertices
star.vertex(0, -50);
star.vertex(14, -20);
star.vertex(47, -15);
star.vertex(23, 7);
star.vertex(29, 40);
star.vertex(0, 25);
star.vertex(-29, 40);
star.vertex(-23, 7);
star.vertex(-47, -15);
star.vertex(-14, -20);
star.endShape(CLOSE);
}
// glv added:
void draw()
{
float x = random(width);
float y = random(height);
shape(star, x, y);
}
Start with just a grid of circles (or other shape) for now and then replace circle with your custom shape.
Hi @glv! I figured out how to create a for-loop structure with circles, but there is a disconnect when it comes to making a for-loop grid system with the custom shapes such as vertexes.
(Grid system via Time Rodenbroeker)
void setup(){
size(900,900);
}
void draw(){
background(0);
fill(#f1f1f1);
stroke(0);
float tilesX = 100; // or mouseX;
float tilesY = 100; // or mouseY;
float tileW = width / tilesX;
float tileH = height /tilesY;
for (int x = 0; x < tilesX; x++){
for (int y = 0; y < tilesY; y++){
ellipse(x * tileW, y * tileH, tileW, tileH);
}
}
}