Image problem

Can someone explain what’s happening here. I create an image, size v,v. I draw a white dot at v,v. I create a rectangle at 1,1 with width v, and height v. I draw a diagonal line from 1,1 to v,v. Everything seems to work OK until the value of v is greater than 495. Over 495, it doesn’t draw the rectangle or the diagonal line to the dot at v,v. Run the program with the value of v at 300, 400, 500, and 600.


function setup()
    displayMode(FULLSCREEN)
    
    v=300    -- change to 400, 500, 600
    
    c=color(255,255,255)
    img = image(v,v)
    img:set(v,v,c)    -- draw white dot at v,v
       
    setContext(img)    
    fill(175, 179, 75, 255)
    rect(1,1,v,v)    -- draw rect at 1,1 width v, height v
    
    stroke(251, 0, 0, 255)
    strokeWidth(3)
    line(1,1,v,v)    -- draw diagonal line from 1,1 to v,v
end

function draw()
    background(0,0,0)
    sprite(img,WIDTH/2,HEIGHT/2)    -- draw image centered on screen
end

.@dave1707 I’ll have to test this. It sounds like an issue with setContext clipping draw commands to the window size instead of the image size.

I think this is issue #212: move displayMode() outside of setup().

Thanks @mpilgrem. That fixed the problem. From now on I’m going to put that and some of the other commands before setup().

@mpilgram

Moving displayMode(FULLSCREEN) above setup() worked as long as the size of v in the above program was 768 or below. Once the value got above 768 (width size) the line and rect were getting clipped again. I used translate() to shift the display so I could see the top right corner.

I understand from this discussion here that Codea clips large images in some way.

@mpilgrem The link was interesting to read. Playing around more, I can set an image size to 2048 x 2048 and use image:set() to set points up to the 2048 edge, but when I use the line or rect commands, they’re clipped at the screen size of 1024 x 768. So it seems like the image isn’t being clipped but the line and rect commands are. I’m using an iPad 1 so I don’t know if things work different on the later iPads.

Haven’t tried it, but try putting in noSmooth()

@Andrew_Stacey

The problem isn’t with the way the line looks, the rect and line commands aren’t being drawn all the way. It’s as if the rect and line commands are being clipped, but trying clip() has no affect.