Howdy, Stranger!

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

Codea 3.2.6 (242)

dave1707dave1707 Mod
edited October 1 in Beta Posts: 8,622

@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.

Comments

  • edited September 30 Posts: 1,838

    @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?

  • edited September 30 Posts: 1,838

    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?

  • dave1707dave1707 Mod
    edited September 30 Posts: 8,622

    @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.

  • Posts: 1,838
    @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.

  • dave1707dave1707 Mod
    edited September 30 Posts: 8,622

    @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
    
  • edited October 1 Posts: 1,838

    @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.

  • dave1707dave1707 Mod
    Posts: 8,622

    @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.

  • dave1707dave1707 Mod
    Posts: 8,622

    @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.

  • Posts: 561

    @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.

  • edited October 1 Posts: 1,838
    @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?
  • SimeonSimeon Admin Mod
    Posts: 5,417

    @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?

  • Posts: 561

    @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.

  • dave1707dave1707 Mod
    Posts: 8,622

    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
    
  • dave1707dave1707 Mod
    Posts: 8,622

    @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.

  • dave1707dave1707 Mod
    Posts: 8,622

    @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
    
  • Posts: 1,838

    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
  • dave1707dave1707 Mod
    edited October 4 Posts: 8,622

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

  • Posts: 1,838
    @dave1707 - the project loads a sprite, copies that to a memory sprite and reads touch to get a value for opaqueness. After touch the memory image is read per pixel and the opaqueness set to the computed touch value. Not finished, not debugged - and not working.
    But, it seemed to hang up a little on me when trying to close, then back to project list window. I tried to close Codea but it came back up with a crash error on top of the Codea projects window. Never seen an error in that way.
  • Posts: 1,838
    @Simeon - not sure what your editing changes entail fully, but I am seeing some inconsistencies with placing the cursor. Usually at the bottom of the listing, the cursor sometimes appears to move up a line. Also I can't always get the editing options up when I need to paste. I have no problems with placing the cursor on the line number though which emphasises as expected.
  • dave1707dave1707 Mod
    Posts: 8,622

    @Bri_G @Simeon I’ve also noticed when tapping near the bottom that the cursor is a few lines above where I touched. I thought it was just how I was tapping the screen and never went back to fully investigate it. I was always too busy working on something.

  • dave1707dave1707 Mod
    Posts: 8,622

    @Bri_G As for your above code, it seems to be working how you have it coded. I’ve tried it several times, but I haven’t had any crashes or other problems with it.

  • edited October 5 Posts: 1,838
    @dave1707 - funny, on my iPad the code doesn't fade the lower image which was my intention. A slightly different version partially fades it - that one used a parameter call to set the opaqueness. Just playing with sprites to see if there was an issue with opaqueness as with your rectangle/ellipse routines. But as I said not yet finished.
  • dave1707dave1707 Mod
    Posts: 8,622

    @Bri_G Add this line of code after background(bck) and you’ll see the opaqueness as you tap the screen near the top or bottom.

        sprite(asset.builtin.Cargo_Bot.Startup_Screen,0,0)
    
  • dave1707dave1707 Mod
    Posts: 8,622

    @Simeon The alert(“ ”) function causes a total Codea crash. Run this a tap the screen.

    function setup()
    end
    
    function touched(t)
        if t.state==BEGAN then
            alert("crash")
        end
    end
    
  • Posts: 1,838

    @dave1707 - confirmed, tried the demo for alert in the reference with alert() added but still crashed.

  • edited October 17 Posts: 1,838

    @Simeon - I have returned to an old project which uses parameter.number with a range of 0.03 to 0.009. When you scroll the slider it rounds the figure displayed up to two decimal places. Is there any way to define the number of places defined as you lose the detail in scrolling. I know I can change the range to 1000 greater then divide the output by a 1000 but it seems a bit untidy. I would have thought that the output would have been scaled to the lowest level in the parameter definition for scaling. So 0.000 in my example above.

  • edited October 18 Posts: 1,838

    @Simeon - just playing around trying to read a directory of sprites in the documents folder. Messy code produced here:


    function setup() -- tab = {} tabPNG = {} s = {} parameter.action("list png",showPng) path = asset.documents s = assetList(asset.documents,"sprite") for a,b in pairs do print(a,b) end end

    Tried spriteList, assetList then tried above code to create the list of sprites - didn’t work so I tried placing the asset.documents in inverted commas ran - then crashed.

    p.s. can’t find assetList in Codea reference section but it is present in Codea reference web site.

  • dave1707dave1707 Mod
    Posts: 8,622

    @Bri_G Heres something to look at.

    function setup()
        s=asset.builtin.Cargo_Bot.all
        for a,b in pairs(s) do
            print(b.name)
        end
    end
    
  • dave1707dave1707 Mod
    edited October 18 Posts: 8,622

    @Bri_G Here’s another.

    function setup()
        xx={}
        tab1=asset.builtin.all
        for a,b in pairs(tab1) do
            tab2=asset.builtin[b.name].all
            table.insert(xx,"\n\n"..b.name)
            for c,d in pairs(tab2) do
                table.insert(xx," "..d.name)
            end
        end
        print(table.concat(xx,"\n"))
    end
    
  • edited October 19 Posts: 1,838

    @dave1707 - thanks for that, I was actually using code from your first incarnation of your last post when I ran into the problem. That code used assets.builtin before @Simeon changed to asset.builtin.

    @Simeon - another funny when I use assetList() it is not displayed as a keyword i.e. emphasised in green. Should it be? Or is it not really a function.

  • Posts: 1,838

    @Simeon - further on the asset front - I typed list = asset and no options popped up until I added the ‘.’ But whilst playing around with it, not able to reproduce it yet, I found assetl empasized in green as a displayed option. However assetl and assetL do not display the expected options. Like assetList is part of the system but not fully recognised.

  • SimeonSimeon Admin Mod
    Posts: 5,417

    @Bri_G the assetList function still exists but is deprecated so no longer appears highlighted or in the documentation (and eventually may be removed)

    @dave1707 thank you for finding the alert crash

Sign In or Register to comment.