We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello For my project I want to fill the field with these different patterns (will be more). They should get a random location on the screen but they shouldn't overlap each other. If anyone has some suggestions how I could do this that would be great. I do not a lot of experience with Processing.
Here is my code:
float[][] coordinatesHex1 = {{12.7,20.3},{12.7,14.4},{12.8,14.4},{14,12.2},{13.9,12.2},{17.2,10.2 },{17.3,10.3 },{19.7,10.3 },{21,8.2 },{19.7,6.1 },{17.3,6.1 },{16.1,8.2 },{16.1,8.3 },{12.8,10.2 },{12.8,10.1 },{10.3,10.1 },{10.3,10.2 },{7,8.3 },{7,8.2 },{5.8,6.1 },{3.3,6.1 },{2.1,8.2 },{3.3,10.3 },{5.8,10.3 },{5.8,10.2 },{9.1,12.2 },{9.1,12.2 },{9.1,12.3 },{5.8,14.2 },{5.8,14.2 },{3.3,14.2 },{2.1,16.3 },{3.3,18.4 },{5.8,18.4 },{7,16.3 },{7,16.2 },{10.3,14.3}, {10.3,14.4 },{10.4,14.4 },{10.4,20.3}};
float[][] coordinatesHex1_2 = {{12.7,20.3},{12.7,14.3 },{12.8,14.3 },{12.8,14.3 },{16.1,16.2 },{16.1,16.3 },{17.3,18.4},{19.8,18.4 },{21,16.3 },{19.8,14.1 },{17.3,14.1 },{17.3,14.2 },{14,12.3 },{14,12.2 },{12.8,10.1 },{10.3,10.1},{9.1,12.2},{10.3,14.3},{10.4,14.3}, {10.4,20.3}};
void setup() {
size(800,800);
smooth();
background(255);
}
void draw() {
float x = random(width);
float y = random(height);
stroke(0);
strokeWeight(0.1);
noFill();
pushMatrix();
translate(x, y);
rotate(radians(random(-45, 45)));
beginShape(LINES);
for (int i = 0; i < coordinatesHex1.length-1; i++) {
for (int j = 0; j < coordinatesHex1.length-1; j++) {
vertex(coordinatesHex1[i][0],coordinatesHex1[i][1]);
vertex(coordinatesHex1[i+1][0],coordinatesHex1[i+1][1]);
}
}
endShape(CLOSE);
popMatrix();
resetMatrix();
stroke(0);
strokeWeight(0.1);
noFill();
pushMatrix();
translate(x, y);
rotate(radians(random(-45, 45)));
beginShape(LINES);
for (int i = 0; i < coordinatesHex1_2.length-1; i++) {
for (int j = 0; j < coordinatesHex1_2.length-1; j++) {
vertex(coordinatesHex1_2[i][0],coordinatesHex1_2[i][1]);
vertex(coordinatesHex1_2[i+1][0],coordinatesHex1_2[i+1][1]);
}
}
endShape(CLOSE);
popMatrix();
resetMatrix();
}
Answers
Thanks a lot! I'll check the video out too
Check this post: https://forum.processing.org/two/discussion/comment/90483/#Comment_90483
Kf