We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › simple ellipse rotate z axis
Pages: 1 2 
simple ellipse rotate z axis (Read 2784 times)
Re: simple ellipse rotate z axis
Reply #15 - Jul 1st, 2009, 6:21am
 
Not sure this is exactly what you're trying to do, but it might give you some ideas Wink

Code:
int segs = 6;
int steps = 1;
float rotAdjust = radians (360.0/segs/2.0);
float radius = 95.0;
float segWidth = radius/steps;
float interval = TWO_PI/segs;
int SHADE = 0;
int TINT =1;
float angleInDegrees = 42;

// declare global cols array
color[] cols = new color[segs];


void setup() {  
size(256,256);    
ellipseMode(CENTER);

// populate the array
// could perhaps create a larger more varied colour array, perhaps by using nested loops
for (int i=0; i< segs; i++) {
cols[i] = color(255-(255/segs)*i, 255-(255/segs)*i,(255/segs)*i);
}

}
void draw() {  
background(128);

pushMatrix();

//start drawing from mouse position  
translate(mouseX, mouseY);
rotate(angleInDegrees);
createWheel(width/2, SHADE);
// back where it should be
popMatrix ();

// keep this small or rotation is too fast!
angleInDegrees += 0.1;

}
// changed parameters
void createWheel (int diameter, int valueshift) {
if (valueshift == SHADE){
    for (int i=0; i< segs; i++){
      fill(cols[i]);
      arc(0, 0, diameter, diameter, interval*i+rotAdjust, interval*(i+1)+rotAdjust);
    }
   
  }  
}
Re: simple ellipse rotate z axis
Reply #16 - Jul 1st, 2009, 10:48am
 
YYYYYYYY!

My bnw flower rotates like that but my color flower wont - yyy!

Thks 2u2 ** - that rotates just fine .....

...... although that palette is all wrong !!!! :')

tx a pronto
Re: simple ellipse rotate z axis
Reply #17 - Jul 1st, 2009, 1:49pm
 
You left the rotate() call out of the last version you posted - that will be why it didn't rotate Wink

As for the colour palette: that was just one example of how you might do it.  You could forget all about using 'i' to influence the colour and go for something completely random instead:

Code:
for (int i=0; i< segs; i++) {
cols[i] = color(random(255), random(255),random(255));
}


Or even declare several variables in your for loop:

Code:
for (int i=0, j=255; i< segs; i++, j -= (255/segs)) {
 cols[i] = color(255-j,abs(150-j), j);
}


The important point is that you use 'i' in this case primarily as an index to populate a particular point in the array, rather than creating an array at each iteration Wink
Pages: 1 2