Drawing a filled image

Hi All,

Ran into this today, not sure if this is a true error or me being stupid. Ran following on iOS 10.1 on iPad Pro 9.7".


displayMode(OVERLAY)
-- Use this function to perform your initial setup
function setup()
    test = image(500,500)
    tw, th = spriteSize(test)
    setContext(test)
        rectMode(CENTER)
        fill(221, 32, 32, 255)
        rect(WIDTH/2, HEIGHT/2, tw, th)
      --  background(255, 0, 4, 255)
    setContext()
    print(tw, th)
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    -- This sets the line thickness
    strokeWidth(0)
    fill(228, 184, 55, 255)
    rect(WIDTH/2, HEIGHT/2, tw, th)
    spriteMode(CENTER)
    sprite(test, WIDTH/2, HEIGHT/2)
end

I expect to get a square red sprite centred on the screen, but I see a small red rectangle with a bigger yellow square behind. If I use a red background on the sprite I get the sprite I need with none of the yellow rectangle showing. Can someone please confirm this and tell me what I am doing wrong?

Bri_G

:confused:

All,

Please ignore this, found the problem the rectangle written to the sprite uses the screen centre point coordinates not that of the sprite !!

Doh!!! Late night, need sleeeeep !!!

Bri_G

:slight_smile:

@Bri_G Don’t worry about it. I do things like that even after a good nights sleep. Sometimes it’s hard to keep track of the default settings.