Howdy, Stranger!

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

how to fill shape color

i’m a little stuck on trying to fill the shape color of one of the shapes i created TT no matter what i do, it either doesn’t show when i press play or i get that red highlight

-- Line thickness, background, general
strokeWidth(200)
fill(233, 142, 80)
background(122, 134, 210)

-- The shapes
rect(200, 400, 200, 100)
ellipse(300, 250, 200)

i don’t know where to insert fill. sorry if this is a rookie question, i’m very new to coding as a whole and i couldn’t find answers that would work for Codea that didn’t sound complicated

Comments

  • Posts: 1,275

    please show the whole (small) program. I'll provide a tiny example below, unless someone beats me to it.

  • Posts: 1,275

    Here's a sample. Things draw go in the draw function, or are called by the draw function, which is called repeatedly as the program runs.

    -- stuff
    
    -- Use this function to perform your initial setup
    function setup()
        print("Hello World!")
    end
    
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
    
    
        -- Line thickness, background, general
        strokeWidth(200)
        fill(233, 142, 80)
        background(122, 134, 210)
    
        -- The shapes
        rect(200, 400, 200, 100)
        ellipse(300, 250, 200)
    
    end
    
  • dave1707dave1707 Mod
    Posts: 9,725

    Here’s an updated example of the above code.

    -- stuff
    
    viewer.mode=FULLSCREEN
    
    -- Use this function to perform your initial setup
    function setup()
        print("Hello World!")
    end
    
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
    
        -- sets the outline thickness and color
        stroke(255,0,0)
        strokeWidth(10)
    
        -- sets the inside color    
        fill(233, 142, 80)
    
        -- The shapes
        rect(200, 400, 200, 100)
        ellipse(300, 250, 200)    
    end
    
  • Posts: 1,275

    a noticeable improvement. I did like that I was able to use OP's code directly, however, as the first step.

  • dave1707dave1707 Mod
    Posts: 9,725

    @RonJeffries When I ran your code, all I got was a white rect and ellipse. The strokeWidth(200) was messing things up. The double background() wasn’t doing anything either.

  • Posts: 1,275

    yes. my point was only to show where the draw code goes. you improved the situation.

Sign In or Register to comment.