Why can't I center my rectangle??

edited February 2015 in Questions about Code

Hello, I just want to center my rectangle so that it blends in with my ellipse. Right now it is too far to the left and I want it at the top center... how can I fix this :/ ? I've been looking through tutorials and examples but using rectMode(CENTER); didn't work for me ... please help. Here is the code:




  • can you copy paste your text here ? please

  • ellipseMode(CENTER) is the default

  • here

    size(600, 600);
    ellipseMode(CENTER);  // Set ellipseMode to CENTER
    fill(100);  // Set fill to gray
    ellipse(50, 50, 30, 30);  // Draw gray ellipse using CENTER mode
    rect(50, 50, 30, 30);  
  • you need to pass the same x,y values to rect as you pass to ellipse....

  • void setup(){ size(600,600); background(240,221,186);


    void draw(){ rectMode(RADIUS); stroke(245,215,231); fill(245,215,231); rect(100,100,50,200);

    ellipse(width/2, height/1.5, 400, 300);

    fill(200); rect(10,10,10,30);


  • it keeps formatting funny :/ sorry thats why i posted an image ..

  • 2 empty lines before and after

    select code without the lines

    hit C in the small command bar

    --- does it work now?

  • I just want to fix my rectangle : <

  • rectMode(CENTER);

  • you edit your previous posts

  • does it work now?

  • Read this to find out how to format source code for this forum. Then go back and edit your comments.

  • "I just want to fix my rectangle"
    Learning to properly use the forum is a step to get proper help...

  • void setup() { 
      size(600, 600); 
      background(240, 221, 186);
    void draw() { 
      stroke(245, 215, 231); 
      fill(245, 215, 231); 
      ellipse(width/2, height/1.5, 400, 300);
      rect(width/2, height/1.5, 50, 200);
      rect(width/2-70, height/1.5-70, 10, 30);
Sign In or Register to comment.