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 & HelpPrograms › Help needed :(
Page Index Toggle Pages: 1
Help needed :( (Read 502 times)
Help needed :(
Apr 27th, 2010, 3:17am
 
Hi guys,
Just wondering if anyone can help me. I am working through the processing program & am wondering if lines & a quad can be joined to make a 'shape' so that i am able to assign it to the mouse x & y, and it is able to enlarge and scale smaller when the mouse moves.

Here is my current code, the ellipse at the bottom of the screen is what i would like to be a boat, so the boat is coming towards and away from the screen when the cursor moves the 'sun'. I know it's lame! Please help, this is driving me crazy!

void setup() {
   size(400, 400);
   smooth();
   noStroke();
 }

  void draw() { ;
   if (mouseY < 100) {
     
fill (62,161,234);  
     rect(0, 0, 400, 200);          
   } else if ((mouseY >= 50) && (mouseY <= 100)) {
     fill (184,192,198);
     rect(0, 0, 400, 200);
   } else if ((mouseY >=100) && (mouseY <=350)) {
     fill (255,181,44);    
     rect(0, 0, 400, 200);
   } else if (mouseY >= 350){
    fill (0);
   rect (0, 0,400, 200);
   }
    float x = mouseX;
   float y = mouseY;
    float mx = constrain(x, 0, 400);
  float my = constrain(y, 0, 200);
  fill(251,255,49);
 
   ellipse(mx, my, 70, 70);
  fill(80,234,197);
   float ix = width - mouseX;   // Inverse X
   float iy = mouseY - height;  // Inverse Y
  fill (39,55,216);

   rect(0, 200, 400, 200);
      fill (250);
   rect (x, height-220, y, y);
  }


and here is the 'thing' i am imagining is the boat:

size (200,200);
smooth ();
fill (0);
quad (20,70,50,50,80,70,50,105);
strokeWeight (2);

line (20,70,22,85);
line (80,70,78,85);
line (50,105,50,130);
line (78,85,50,130);
line (50,130,22,85);

THANKS HEAPS!! Any suggestions are appreciated!! x
Re: Help needed :(
Reply #1 - Apr 27th, 2010, 4:09am
 
First off - drawing shapes...
You might be better off using beginShape / endShape and vertex calls to 'draw'.  That should give you a bit more control.

Scaling....
Unless it's a part of your assignment to manually calculate the offset caused by scaling you're probably better off just using scale; though may also need to look at pushMatrix and popMatrix (see related links in scale)...
Page Index Toggle Pages: 1