Howdy, Stranger!

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

Why rect doesn't fill up the screen?

in Questions Posts: 19

I have a simple program here which I am expecting to see just black screen. It turns out to have a white border around it. This means that rect doesn’t fill up the entire screen. Why? What am I missing? I am running Codea 2.7.3 on iPad mini with iOS 12.1.1

function setup()     

end

function draw()     
    background(255, 255, 255, 255)

    -- why this leaves white border around the screen?
    -- strokeWidth(3)  -- any number here doesn't make any differences
    stroke(0, 0, 0, 255)
    fill(0, 0, 0, 255)
    rectMode(CORNER)
    rect(0, 0, WIDTH, HEIGHT)

    -- add this doesn't help either 
    -- strokeWidth(1) -- only when this is >= 2
    line(0, 0, 0, HEIGHT)
    line(0, HEIGHT, WIDTH, HEIGHT)
    line(WIDTH, HEIGHT, WIDTH, 0)
    line(0, 0, WIDTH, 0)
end
Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,656

    @tsukit Just Add noSmooth(). See example.

    function setup()     
    end
    
    function draw()     
        background(255, 255, 255, 255)
        fill(0, 0, 0, 255)
        noSmooth()      -- add this 
        rectMode(CORNER)
        rect(0, 0, WIDTH, HEIGHT)
    end
    
  • Posts: 1,257
    @tsukit - try noStroke() before rect.
  • dave1707dave1707 Mod
    Posts: 7,656

    @Bri_G noStroke() doesn’t work, but noSmooth does.

  • Posts: 1,257

    @dave1707 - wasn't sure which one ite was, used both of them once in a texture which left a gap without them. Never chased up to see which one removed the gap. Thanks.

  • Posts: 19

    @dave1707 and @Bri_G thanks. NoSmooth() works!

    It’s weid to me that the smoothing process has impact on this simple area fill of rect where there is no curve involved.

  • dave1707dave1707 Mod
    Posts: 7,656

    @tsukit smooth and noSmooth aren’t for curves. Their purpose is to average the color from one area to another or not. If you have a white area overlapping a black area, then smooth will average the area along the border of those 2 areas. noSmooth won’t and the border area will just go from one color to the other.

  • SimeonSimeon Admin Mod
    edited January 23 Posts: 4,990

    @tsukit yeah what @dave1707 said — they probably aren't well named, but you can think about them more like antialiasing.

  • Posts: 19

    Got it. Thanks guys.

Sign In or Register to comment.