is clip() broken?

i have problems with clip(x,y,w,h).
Is it broken in current codea version? I dont remember if this was already said…
(it could be my mistake).
Thanks.

@Jmv38, I don’t believe clip is broken. Could you post an example of some code or explain a little more what is not working?

@JakAttak thanks. Then i’ll carefully check my code first. It is quite likely the bug is in my code…

@Jmv38, are you remembering that for clip(x, y, w, h) x and y are for the bottom-left corner?

@jakattak yes, thanks.
actually in my code if do a background(255,0,0) it works great: i can see the clipped area is the good one, but if i draw my button in tha same area, it doesnt draw at all. While it does if i comment out the clip… weird.

@Jmv38 clip() seems to work, but it depends on where you put it. If you put clip in setup(), it doesn’t work. If you put clip in draw, it works.

EDIT: Ignore this. See the example below that shows what’s happening.

@Jmv38 Try the program below. A parameter can turn clip on or off. Also, a parameter changes if background is before or after clip. If background is before clip, everything works ok. If background is after clip, it looks like clip doesn’t work. But what is actually happening is that clip is setting the area to draw in so when background is after clip, then the area outside of the clip area isn’t changed. So it looks like clip isn’t working when it actually is.


supportedOrientations(LANDSCAPE_ANY)

function setup()
    parameter.boolean("cl",true)
    parameter.boolean("bk",true)
end

function draw()
    if bk then
        background(40,40,50)
    end
    if cl then
        clip(0,0,300,300)
    end
    if not bk then
        background(40,40,50)
    end
    fill(255)
    stroke(255)
    strokeWidth(2)
    line(0,0,2000,2000)
    line(500,0,500,HEIGHT)
    rect(100,100,400,100)
    fill(255)
    if cl then
        text("clip on",50,250)
    else
        text("clip off",50,250)
    end
end

thanks @dave1707 and @jakattak.
As usual, the bug was in my code :"> so clip() works fine…

@Jmv38, so I assume you fixed it? Always nice when you squash a little bug :slight_smile:

The user and all related content has been deleted.