Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is this weird or am I doing something?

edited November 13 in Code Sharing Posts: 5

In function draw(), I’m calling two functions. drawRect() and drawCircle(), I filled the rect with white and filled the circle with grey. But when I run my code, the circle is white and the rectangle is grey… what am I doing wrong?

My code looks like this:

function draw()
   background(40,40,50)
   drawRect()
   drawCircle()
end

function drawRect()
   rect(WIDTH/3, HEIGHT/3, 200,80)
   fill(255)
end

function drawCircle()
   ellipse(WIDTH/2,HEIGHT/2,100,100)
   fill(100,100,100)
end
Tagged:

Comments

  • dave1707dave1707 Mod
    edited November 13 Posts: 9,725

    The fill should be before the rect or ellipse. The color gets set first, then the object gets drawn.

    PS. When you post code, put ~~~ ( 3 tildes) before the code and again after the code. I added them to the above code.

    Just a suggestion. Look thru the reference just to get an idea of the commands and what’s available. That might help with future code, but we’re here to answer questions too.

  • Posts: 1,275

    codea things, like draw ... and everything ... happen in the order encountered. it's generally not like CSS where a chunk of stuff just all adds up to do the right thing.

    please tell us a bit about your experience, it'll help us pitch things at the right level.

    keep on, it's fun!

Sign In or Register to comment.