• fullscreen
  • sketch_jul05a.pde
  • // Pressing Control-R will render this sketch.
      
      
    float rx, ry;    // rectangle x- and y-coordinate
    float rd = 100;  // rectangle width
      
    float ex, ey;    // ellipse x- and y-coordinate
    float ed = 106;  // ellipse diameter
      
    void setup() {
      size(640, 360);
      smooth();
       
      // Set the x- and y-coordinates for the rectangle
      rx = width * 0.33 - rd/2;
      ry = height * 0.5 - rd/2;
       
      // Set the x- and y-coordinates for the ellipse
      ex = width * 0.66;
      ey = height * 0.5;
    }
      
    void draw() {
     background(0, 0, 0);
      strokeWeight(1);
      color(0);
          if ((mouseX>=rx)&&(mouseX<=rx+100)&&(mouseY>height * 0.5 - rd/2)&&(mouseY<height * 0.5 + rd/2)){background(239, 101, 68);}
          if ((mouseX<=ex+53)&&(mouseX>ex-53)&&(mouseY<=ey+53)&&(mouseY>ey-53)){background(61, 139, 214);}
      rect(rx, ry, rd, rd); ellipse(ex, ey, ed, ed);
      }
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Anika Niazi

    workshop 3

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    epar
    6 Jul 2012
    The workshop assignment required you to "Design a reaction when the mouse moves over a rectangle and design a different action when the mouse moves over a circle." Your code now had the same action for both the ellipse and the rectangle (change the background color), please update your code to fulfill the workshop requirements.
    You need to login/register to comment.