Codea 3.2.6 (242)

@Simeon I noticed this when testing the new release. When tapping on a line number, if the line is blank and outside of a function, the pop up is “Select, Select All, Paste”. If the line is blank and within a function, the pop up is “Cut, Copy, Paste, Re-Indent, Find”. Not that it matters that much, but just different.

I couldn’t get the scroll error to happen. But then when it was happening, it didn’t happen all the time. Will keep trying that.

As for the crash when editing, I’m not sure if I ran across that. There were times when there was a crash, but I don’t know if that was the cause.

What I did notice right after loading the new code from test flight, when I ran a project and closed it, Codea crashed. I’ve noticed that several times with the last few releases. The first time after a TestFlight load of a new update, Codea would crash when closing the code, but not after that.

As for deprecating several commands, I did a project search and I have 450+ projects that need updating. Maybe I’ll write something to automatically make the changes. If not, then I’ll make the changes only if I use them again.

Tried the preferredFPS command and that worked OK. Set it to 15 in one of my projects and it ran at 14 to 15 FPS when it normally runs at 59 to 60.

PS. After several attempts, I haven’t been able to cause the scrolling error with iPad rotation.

@Simeon @dave1707 - confirm crash after installation and running a couple of projects. First one I ran was from @RonJeffries Invaders from post 57, then one of my own I was looking for deprecated errors. They printed up on my project for displayMode(). I also noticed the project ran then seemed to hang up. I couldn’t pull over the parameter window easily. It took many attempts then it eventually pulled over. On closing the project and Codea I got the Codea crashed dialogue.

Note I started filling in the error form but needed to check something in Codea - so I re-ran Codea. When I tried to find the error reporting form it had closed and wasn’t available. Is this expected behaviour?

All,
Just loaded 241 with iOS 14.1 and noticed when picking up my active iPad, holding in portrait mode and refreshing the screen the image was in landscape mode and was not correcting to portrait. Turning the iPad initiated screen orientation correction and rotating then resulted in adoption of the correct orientation. Anyone else seen this?

@Simeon Version 242. Sent you a crash report. This has been reported before. After a new load of Codea, Codea crashes after the first project is run. It doesn’t happen anytime after that.

The viewer.snapshot works fine.

Verified that several Craft and Example projects were updated to use viewer.

Something that would be nice is to put the Example and Craft projects in Recent or Alpha order depending of the Codea setting.

@dave1707 - on your thought re examples, I think it may be better to have one (or two) example windows accessed from icon(s) at the top of the projects page, making them easily, and swiftly, accessible and not crowding the personal projects window.

i hope the viewer.snapshot keeps the alpha information? Would need to be a .png format image.

@piinthesky It doesn’t look like it keeps the correct r,g,b,a values. Here’s an example to try. In the draw() function, I draw 2 ellipses with different fill values. In the touched() function, I read back the r,g,b,a values and print them. You can see that when the alpha value is less than 255, the r,g,b values are reduced by 255-alpha and alpha is set back to 255. Run the code and tap the screen to read the values. Try different fill values to see what’s happening.

viewer.mode=STANDARD

function setup()
end

function draw()
    background(0)

    fill(255,255,255,255)
    ellipse(100,200,50)
    
    fill(255,255,255,55)
    ellipse(200,200,50)
end

function touched(t)
    if t.state==BEGAN then
        im=viewer.snapshot()
        
        r,g,b,a=im:get(100,200)
        print(r,g,b,a)
        
        r,g,b,a=im:get(200,200)
        print(r,g,b,a)
    end
end

@Simeon @dave1707 - updated to 240, crashes as before first project run as described above. Loaded flappy bird and still has displayMode() present.

Edit: 242 not 240.

@Bri_G you should update the examples using the button in the right side panel.

@Bri_G You said you update to version 240. Was that a typo because 242 is the latest version. If you loaded version 240, the viewer changes were put in version 241 so flappy bird would still have displayMode.

@Bri_G Back to your comment about 1 or 2 example projects accessed at the top of the projects page. If you use the Files app to access Codea projects, you can use tags to move all of the folders to the top of the projects list as shown in the Files app. That’s how I have them.

@dave1707 i hope @Simeon will be able preserve the alpha information in the snapshot. I did need that a while ago when making an image for a teeshirt and requested such a feature at the time.

@dave1707 - sorry my bad, I just loaded 242 before looking at flappy bird.

Also, I was referring to the built in Codea project filer. The suggestion was to have icons at the top of the page for Codea examples and Craft examples which could open a new project page dedicated to those examples leaving the main project file page for users files.

Does setting tabs in the File app influence the project file order in the Codea project filer display?

@piinthesky I can’t recall but I thought setContext() preserves alpha? Is it possible to use that to render the content you want into an image?

@Simeon yes setContext() does preserve the alpha and that is how i sort of managed to do it. Although, i remember that for complex 3d images annoyingly the setContext() did not give the same result as drawing directly to the screen. The snapshot preserving the alpha would be convenient but if it is not possible then so be it.

Here’s something similar to my other code above. It creates a setContext image with specific color values. When the values are read back, the alpha values are the same as their original, but the r,g,b values are different if the alpha isn’t 255.

viewer.mode=STANDARD

function setup()
    img=image(WIDTH,HEIGHT)
    
    setContext(img)  
      
    fill(255,255,255,255)
    ellipse(100,100,50)
    
    fill(190,180,170,200)
    ellipse(200,200,50)
    
    setContext()
    
    r,g,b,a=img:get(100,100)
    print(r,g,b,a)
    
    r,g,b,a=img:get(200,200)
    print(r,g,b,a)
end

function draw()
    background(0)
    sprite(img,WIDTH/2,HEIGHT/2)
end

@Bri_G In my Files app, I have all of the folders (Examples, Craft, and others) tagged so they show before all of my projects. When you long press on a folder and select Tags, you can select a tag color. That puts the folder before non tagged files. Tiffany you have a lot of folders, you can group/order them by color. The order in the Files app doesn’t change the order in the Codea app.

@piinthesky @Simeon Heres something that I remembered posting, but it took me awhile to find it. It’s about the r,g,b,a values. This is from 8 years ago.

https://codea.io/talk/discussion/1709/saveimage-readimage#latest

Code giving a crash whilst trying to set up fading image by making pixels opaque using touch to change opacity. Error reported by Codea crash alert:


function setup()
    --
    sW,sH,cW,cH = WIDTH, HEIGHT, WIDTH/2, HEIGHT/2
    bck = color(0,0,0,0)
    img = readImage(asset.builtin.Cargo_Bot.Pack_Crazy)
    imgW,imgH = spriteSize(img)
    ss = image(imgW,imgH)
    opaque = 255
    spriteMode(CORNER)
    setContext(ss)
        fill(bck)
        rectMode(CORNER)
        rect(0,0,imgW,imgH)
        sprite(img,0,0,imgW,imgH)
    setContext()
end

function draw()
    -- This sets a dark background color 
    background(bck)
    sprite(img,cW,cH+200)
    sprite(ss,cW,cH-200)
    
end

function touched(t)
    --
    if t.state == ENDED then
        opaque = math.floor(t.y//4)
        fader(opaque)
    end
end

function fader(op)
    --
    setContext(ss)
    fill(bck)
    rectMode(CORNER)
    rect(0,0,imgW,imgH)
    for y = 1,imgH do
        for x = 1, imgW do
            r,g,b,a = img:get(x,y)
            col = color(r,g,b,op)
            ss:set(x,y,col)
        end
        output.clear()
        print(r.." "..g.." "..b.." "..op)
    end
    setContext()
end



@Bri_G What do I have to do to cause the crash. What does this do.