We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys. wondering if you could help me change the smaller circles in to hexagons and also how to change the colour of each individual shape randomly when mouse pressed?
thanks
PVector[] h1 = new PVector[6];
void setup() {
size(700, 600);
background(0);
for (int i = 0; i < 6; i++) h1[i] = new PVector();
}
void draw() {
background(100);
translate(width/2, height/2);
textAlign(CENTER);
text("elliebirch", 0, 0);
rotate(radians(frameCount));
stroke(255, 43, 0);
noFill();
float theta = 0.0;
for (int i = 0; i < 6; i++) {
theta += TWO_PI/6.0;
h1[i].x = cos(theta)*100;
h1[i].y = sin(theta)*100;
}
for (int i = 0; i < 5; i++) {
int nextPoint = i+1;
line(h1[i].x, h1[i].y, h1[nextPoint].x, h1[nextPoint].y);
}
line(h1[0].x, h1[0].y, h1[5].x, h1[5].y);
for (int i = 0; i < 6; i++) ellipse(h1[i].x, h1[i].y, 50, 50);
}
Answers
??
changed question
I showed this in my answer in your other thread... didn't you like it?
this is a different question.
thank you for your other reply :)
For the color, the last for loop should read this instead:
For the second question, try this https://forum.processing.org/two/search?Search=hexagon
Basically, you can create a function that draws a generic hexagon of an adjustable size. Your function can take also a rotation angle and a center point to translate the figure in space. You will also need pushMatrix/popMatrix calls. But first build the hexagon using vertex() calls.
Kf
thanks for your response. I'm very new to this is there any way you would be able to add it to my code for me and send it back please. :)
mouse press does not work on this. sorry to be a pain guys :(
Add the following lines to @chrisir's code:
Kf
you wrote
I showed this in your previous thread but you choose to ignore it and instead open this new thread....
just stitch it together
Best, Chrisir ;-)
content restored, thread closed.
vandalising threads is frowned upon here.