move the pivit-point to rotate complex shape
in
Programming Questions
•
1 year ago
Hi There,
Learner driver here: I've tried various ways but I'm stuck
I've constructed a 'flower' and I want to rotate the stem+ flower from left to right ( but not the leave) I want it to move round a pivital point at the bottom of the stem. But I can't seem to make it rotate around that point.
btw I've haad simular problems with the leave, where I couldn't move the pivital point , making placement of the leave rather awkward- but I succeeded.
So this is what I'm after
this is how far I got:
float x;
float y;
float flowerAngle;
float angleChange =1.5;
final int ANGLE_LIMIT = 135;
void setup (){
size (600, 400);
smooth();
}
void draw () {
background (255);
drawLeave();
drawFlower ();
flowerAngle += angleChange;
if (flowerAngle > ANGLE_LIMIT || flowerAngle < 0)
{
angleChange = -angleChange;
flowerAngle += angleChange;
}
}
void drawFlower (){// draw flower and stem
pushMatrix();
translate (400, 300);
//stem
strokeWeight (6);
noFill();
stroke(96, 255, 82);
rotate(radians(flowerAngle));
arc(x, y, 250, 320, PI, 3.93);
//flower
noStroke ();
fill (250, 0, 0);
ellipse (x-75,y-130, 50,50);
fill (250, 250, 0);
ellipse (x-75,y-130, 20,20);
popMatrix();
}
void drawLeave (){ //draw leave
pushMatrix ();
fill (96, 255, 82);
translate (205,285);// make bottom of stem point zero
rotate(radians(45)); //rotate the leafshape
ellipse (-7, -40, 140, 20);
popMatrix();
}
cheers
nanette
Learner driver here: I've tried various ways but I'm stuck
I've constructed a 'flower' and I want to rotate the stem+ flower from left to right ( but not the leave) I want it to move round a pivital point at the bottom of the stem. But I can't seem to make it rotate around that point.
btw I've haad simular problems with the leave, where I couldn't move the pivital point , making placement of the leave rather awkward- but I succeeded.
So this is what I'm after
this is how far I got:
float x;
float y;
float flowerAngle;
float angleChange =1.5;
final int ANGLE_LIMIT = 135;
void setup (){
size (600, 400);
smooth();
}
void draw () {
background (255);
drawLeave();
drawFlower ();
flowerAngle += angleChange;
if (flowerAngle > ANGLE_LIMIT || flowerAngle < 0)
{
angleChange = -angleChange;
flowerAngle += angleChange;
}
}
void drawFlower (){// draw flower and stem
pushMatrix();
translate (400, 300);
//stem
strokeWeight (6);
noFill();
stroke(96, 255, 82);
rotate(radians(flowerAngle));
arc(x, y, 250, 320, PI, 3.93);
//flower
noStroke ();
fill (250, 0, 0);
ellipse (x-75,y-130, 50,50);
fill (250, 250, 0);
ellipse (x-75,y-130, 20,20);
popMatrix();
}
void drawLeave (){ //draw leave
pushMatrix ();
fill (96, 255, 82);
translate (205,285);// make bottom of stem point zero
rotate(radians(45)); //rotate the leafshape
ellipse (-7, -40, 140, 20);
popMatrix();
}
cheers
nanette
1