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 › Pulse an ellipse
Page Index Toggle Pages: 1
Pulse an ellipse? (Read 1109 times)
Pulse an ellipse?
Jan 15th, 2008, 6:42pm
 
Hey guys, when the user presses moves their mouse over the button it changes colour, but when they press it, is there any way it can vibrate or move??

heres is one of my boolean's

boolean overCircle(int x, int y, int diameter)  
{
 float disX = x - mouseX;
 float disY = y - mouseY;
 if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) {
   return true;
 } else {
   return false;
 }
}


thanks alot
Re: Pulse an ellipse?
Reply #1 - Jan 15th, 2008, 8:20pm
 
your boolean is ok. to make your ellipse vibrate, you could draw it with random offsets at each frame. something like :

Code:
ellipseMode(CENTER);

if (overCircle(x, y, d)) {
ellipse(x + random(10)-5, y + random(10)-5, d, d);
}
Re: Pulse an ellipse?
Reply #2 - Jan 15th, 2008, 11:52pm
 
thats great, but where would i place that in my application?

at the top every circe has its own interger and boolean

int circleX, circleY;         // Diameter of circle
int circle1X, circle1Y;        // Diameter of circle 1
int circle2X, circle2Y;

boolean circleOver = false;
boolean circle1Over = false;
boolean circle2Over = false;
void setup()
{
 size(1200, 600);     // Size of the window                                      
 //myMovie = new Movie(this, "steamboat.mov"); // Loading the first movie into the sketch                                                  
 //myMovie.loop();                               // So the movie can loop          
 //myMovie1 = new Movie(this, "bob.MOV");    // Loading the second movie into the sketch          
 //myMovie1.loop();                             // So the movie can loop
 frameRate(30);                 // How fast the sketch will run, which will affect the speed of the videos
 smooth();                                   // Allowing the buttons to have smooth edges    
 circleColor = color(255,0,0);                 // The color of the circle  
 circleHighlight = color(204);              // The color of the circle  when highlighted    
 circle1Color = color(255, 145, 0);                // The color of the circle 1        
 circle1Highlight = color(204);             // The color of the circle  when highlighted 1        
 circle2Color = color(255, 255, 0);       // The color of the circle 2        
 circle2Highlight = color(204);  

void draw()
{
 background(0);  // Sets the background  
 update(mouseX, mouseY);
 if(circleOver) {              // If the circle has the mouse over it, will fill with the highlight color, otherwise it will go back to the original color
   fill(circleHighlight);
 } else {
   fill(circleColor);
 }
 noStroke();
 ellipse(circleX, circleY, circleSize, circleSize);
 
 if(circle1Over) {            // If circle 1 has the mouse over it, will fill with the highlight color, otherwise it will go back to the original color
   fill(circle1Highlight);
 } else {
   fill(circle1Color);
 }
 noStroke();                 // No black line around the button
 ellipse(circle1X, circle1Y, circle1Size, circle1Size);
Re: Pulse an ellipse?
Reply #3 - Jan 16th, 2008, 3:07am
 
Actually i figuredit out, thanks alot. gonna really improve my project
Page Index Toggle Pages: 1