Howdy, Stranger!

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

Codea 1.5 (Beta 12)

SimeonSimeon Admin Mod
edited January 2013 in Beta Posts: 5,362

Closing this thread. Beta 13 discussion is now here: http://twolivesleft.com/Codea/Talk/discussion/2109/codea-1.5-beta-13

Another beta, another thread.

I've made a fairly large change to this build: The tab bar now scrolls off the screen to show more code. Scrolling up immediately brings it back. Let me know what you think about this change.

The fixes are outlined in the release notes.

However there are some things that have not been fixed:

  • tween documentation issues mentioned by @mpilgrem
  • saveProjectTab() use when explicitly naming the current project
  • unable to import photos in landscape mode mentioned by @tnlogy (cannot reproduce this one)
  • unable to run Graphics Styles example mentioned by @Codeslinger (cannot reproduce)

I'd like to consider renaming the BLEND_* constants as mentioned by @mpilgrem as well. It's not pleasant to have the BLEND_ prefix used in so many instances.

Tagged:

Comments

  • Posts: 196

    @simeon - I really like the tab bar feature, the extra space, while only a couple of lines, is very welcome when typing directly on my iPad.
    Any plans to be have it in the shaderlab too ?
    Concerning the shaderlab, can we get and option to hide the preview for fullscreen code?

  • Posts: 2,161

    I'll second renaming the blend constants. They're a pain to type with the underscores and you have to type a large segment of the name before you can see the name in the autocomplete list.

  • I found out what the problem with GraphicsStyle is for me. It contains some UTF-8 non-breaking spaces "0xc2 0xa0". I think my installation is one year old, the occurrence of nbsps in the examples may have been eliminated now. If I delete these spaces the code runs as expected. This seems to be similar to the problem I had on the desktop where Lua rejected nbsps. But Codea was able to run such scripts in the past, what happened?

  • edited January 2013 Posts: 489

    I think that "long press delete" still misbehaves in beta 1.5(12).

    I too like the tab bar feature and would vote for its equivalent in the Shader Lab.

    Until the expression key pop up has been dismissed, the hide keyboard key does nothing. Perhaps it could dismiss the pop up too?

  • Behavior of saveProjectTab() with nil content:

    Tab in same project: contents are cleared, tab still exists. Is the tab supposed to stay there or be deleted? If I want to clear the contents and keep the tab I'd rather set it to "".

    Tab in other project: Codea crashes.

  • Posts: 580

    .@Simeon I recall in another thread that you had plans to delete the tab if the contents param to saveProjectTab() was nil...are there plans to include this behavior in 1.5? I have an idea for a remote project bootstrap sort of thing, but it will depend on that behavior. It would awesome I'd it does make it into 1.5 :)

  • Posts: 489

    Is the following a bug, or by design?

    --
    -- Print Test
    --
    
    -- Produces differently formatted output in Codea 1.4.6(15)
    -- and beta 1.5(12). In the beta, tab characters are treated like
    -- single space characters
    function setup()
        -- Produces the same output in beta:
        print("a", "b", "c")
        print("a\tb\tc")
        print("a b c")
        -- Produces the same output in beta:
        print(1, 2, 3)
        print(tostring(1).."\t"..tostring(2).."\t"..tostring(3))
        print(tostring(1).." "..tostring(2).." "..tostring(3))
    end
    
    function draw() background(0) end
    
  • SimeonSimeon Admin Mod
    Posts: 5,362

    .@Codeslinger @toadkick saveProjectTab with nil should delete the tab. I'll have to fix this bug, sorry about the crash issue.

    .@mpilgrem I think this is to do with the way the text rendering has changed in the output window. I'll see if I can make it respect \t characters.

  • Posts: 1,255

    Where is saveProjectTab (and any related functions) documented?

  • At the moment, the only "documentation" are the help bubbles when you type the function name in the editor.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Yes. No documentation for that yet. There is a lot of work left to do.

  • Posts: 196

    There is still a refresh glitch with "selecting" and deleting a single word (undo feature has the same refresh issue).

    Also, I'm having issues using arrays as uniforms

    m.shader.c = { vec3(1, 1, 1), vec3(1, 1, 1) }
    
    uniform lowp vec3 c[];
    

    is that code not supposed to work ?

    There are a few display glitches with commenting:
    Any "+" you add after a comment will make the a number of characters starting from the end of the line appear white instead of green.
    Here, the last character appears white

    --++

    C type comments "green" out the code as a regular -- comment would, but they obviously don't work.

    Block comments aren't displayed properly

    --[[
    this is not "greened" out
     ]]

    Finally, the += button still does variable = variable + in the glsl editor but that's not really a bug.

    Cheers

  • Jmv38Jmv38 Mod
    Posts: 3,295

    Cursor lost bug it is almost solved: it works for the tabs, but it is lost for the main tab.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    look and feel v12.
    The tab names going away is excellent.
    I am not a fan of the new color for contextual suggestions: i peferred black to tuquoise.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    editor slow when clicking in the text to pop up thhe keyboard, i frequently have to wait 1-2s for moderately long tabs. Feels long...

  • edited January 2013 Posts: 196

    I really like the idea of being able to build a shader with a string (you can really customize shaders).
    However, i just can't get it to work (nothing gets displayed, as if shader error)
    Can anyone tell me how they get it running ?

    function setup()
        vertexSource =
        " attribute vec4 position;"..
        " void main()"..
        " {"..
        "     gl_Position = position;"..
        " }"
     
        fragmentSource =
        " void main()"..
        " {"..
        "     gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);"..
        " }"
     
        m = mesh()
        m.shader = shader()
        m.shader.vertexProgram = vertexSource
        m.shader.fragmentProgram = fragmentSource
        m:addRect(0,0, WIDTH, HEIGHT)
    end
     
    function draw()
        m:draw()
    end

    edit: ok got it to work..

    myShader = shader()
    myShader.vertexProgram = vertexSource
    myShader.fragmentProgram = fragmentSource
     
    m = mesh()
    m.shader = myShader
    ....

    @Simeon - the + glitch that affect highlighting also happens with strings, which is actually more annoying :P

  • Jmv38Jmv38 Mod
    Posts: 3,295

    BUG PASTE PROJECT unless i did sthg wrong, i think the 'long press on +' to paste a project from the clipboard works only when the project has tabs. It is a bit annoying in the case of short projects made of 1 tab only.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Actually it should work as long as the project is in the right "format" — that is the project needs to start with --# Main (have at least one tab).

    So if you copy a 1-tab project using the touch-and-hold to copy method, then you should be able to paste it through the '+' button.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    .@bortels (continuing an old discussion) hello! I have finally managed to store user information by going to PHP. You can have a look at my final solution at http://jmv38.comze.com/CODEA/server.php
    I have found the site 'ready to use' on the web. Actually, i had to work a couple days to understand how to make mySql work on my web host, but that's done now. And i am pretty happy of the result. Thank for giving me the initial impulse!

  • Posts: 489

    Hello @Simeon. I am working through some of the open issues on the Issue Tracker in connection with beta 1.5(12).

    Issue No. 217

    I find that os.time() does change from one value to another as time passes, but about once every two minutes.

    --
    -- os.time
    --
    
    function setup()
        timeCheck()
    end
    
    local trialCount = 0
    function timeCheck()
        local timeValue = os.time()
        local dateString = os.date("%c", timeValue)
        trialCount = trialCount + 1
        print(trialCount..": "..dateString)
    end
    
    function draw() background(0) end
    
    function touched(touch)
        if touch.state == BEGAN then timeCheck() end
    end
    
  • SimeonSimeon Admin Mod
    Posts: 5,362

    .@mpilgrem this is due to Codea using 32 bit floats for the Lua "number" type instead of the default 64 bit double-precision float ("double"). This is because there are performance benefits to using single-precision floats on the newer iPad ARM CPUs.

    So what is happening is the value from os.time() is getting truncated, and small changes are lost.

  • Posts: 489

    .@Simeon, in the past you have explained (here) that Codea's use of a version of Lua that uses singles rather than doubles for Lua's number type is to accommodate the performance of first generation iPads. Do you see a time where you might have an 'enhanced' version of Codea that is not intended to work well on first generation iPads?

  • edited January 2013 Posts: 489

    This is almost certainly not on any critical path for Codea version 1.5, but I see from the Lua reference that the meaning of the value returned by os.time([table]) (and understood by os.date()) is allowed to vary from system to system.

    Perhaps the Codea 'system' could change (behind the scenes) the start of the 'epoch' (update: from the 1 January 1970 GMT used by iOS) so that the number of seconds since that start fell within the precision of a 32 bit float?

    (Further update): A little knowledge is a dangerous thing, but I think it would involve something like this patch in loslib.c:

    (1) deducting some offset value (say, CODEA_EPOCH_OFFSET) from these lines:

    static int os_time (lua_State *L) {
      time_t t;
      if (lua_isnoneornil(L, 1))  /* called without args? */
        t = time(NULL) - CODEA_EPOCH_OFFSET;  /* get current time */
      else {
        ...
        t = mktime(&ts) - CODEA_EPOCH_OFFSET
      }
      ...
    

    (2) adding back the same offset value in this line:

    static int os_date (lua_State *L) {
      const char *s = luaL_optstring(L, 1, "%c");
      time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL))
        + CODEA_EPOCH_OFFSET;
      ...
    
  • edited January 2013 Posts: 489

    Issue No. 216

    What the code below allows you to explore is (1) the odd behaviour of line() when smooth is set and strokeWidth is less than 2.5; and (2) that the line width does not scale if noSmooth is set.

    --
    -- Scale-Stroke-Smooth Explorer
    --
    
    function setup()
        red = color(255, 0, 0)
        green = color(0, 255, 0)
        parameter.number("scaleValue", 1, 20, 10)
        parameter.number("strokeWidthValue", 1, 10, 5)
        parameter.boolean("isSmooth", true)
        rectMode(CENTER)
        stroke(255)
    end
    
    function drawPattern()
        fill(green)
        strokeWidth(strokeWidthValue)
        if isSmooth then
            smooth()
        else
            noSmooth()
        end
        line(-20, 10, 20, 10)
        rect(0, -20, 40, 20)
    end
    
    function draw()
        background(0)
        translate(WIDTH / 2, HEIGHT * 0.9)
        noStroke()
        fill(red) ellipse(0, 0, 5) -- Mark origin
        drawPattern()
        translate(0, - HEIGHT * 0.45)
        noStroke()
        fill(red) ellipse(0, 0, 5) -- Mark origin
        scale(scaleValue) -- Scale up
        drawPattern()
    end
    
  • Posts: 1,255

    Is there a companion statement to saveProjectTab() that creates a new project?

  • Posts: 502

    Editor bug. Paste this into an empty tab, and try to remove the O.

            local b = UI.TextButton {x=i*135, y=180, w=130, h=30, title="O" .. i,output = i}
    
    

    Works fine if I add a line break though. Current version is quite stable and nice. :)

  • SimeonSimeon Admin Mod
    Posts: 5,362

    .@mpilgrem that's a great demo — I've used it to improve the line shader with round end caps in the next build (though it's probably a bit slower now).

    The reason noSmooth() lines don't scale in width is because they use the GL_LINE primitive. This primitive is not affected the same way by vertex transforms because it only has two vertices. We could change to drawing a rect (internally) for noSmooth() lines, this would allow all four vertices to scale but would be slower.

    CODEA_EPOCH_OFFSET is an interesting idea. It would make os.time() a lot more useful, and we could disable it in case we do move to double precision numbers in the future.

    .@tnlogy I can't recreate this — is it causing the text input to become misaligned on your device?

    .@Mark not for version 1.5, but I am keeping that one in mind.

  • Posts: 489

    Hello @Simeon. The following is an Editor bug, but the solution may lie with changing the color() function.

    The argument pop-up 'tips' in the Editor suggest that when color() has a single argument, it is a 'Gray Value', and when color() has two arguments, the first is 'Gray' and the second 'Alpha'.

    However, color() only allows for color(red, green, blue, alpha) with red, green and blue assumed to be 0 if they are not supplied and alpha assumed to be 255 if it is not supplied.

    Perhaps it would be better if color() behaved more like fill() does, in terms of its arguments? - although that would be a change in the Codea API.

  • Posts: 489

    Issues No. 195 and 196

    myBody.linearDamping and myBody.angularDamping still return boolean values, in error, and are not documented in the in-app reference for 'physics.body'.

    --
    -- Dampner
    --
    
    function setup()
        physics.gravity(0, 0)
        myBody = physics.body(CIRCLE, 30)
        
        -- number, used to reduce the velocity of the body. The
        -- default, 0, is no damping. Damping is usually less
        -- than 1, but can be greater.
        myBody.linearDamping = 0.5
        
        -- number, used to reduce the angular velocity of the body.
        -- The default, 0, is no damping. Damping is usually less
        -- than 1, but can be greater.
        myBody.angularDamping = 0.5
        -- Codea bug:
        print(myBody.linearDamping) -- Output: false
        print(myBody.angularDamping) -- Output: false
        
        myBody.linearVelocity = vec2(1, 2)
        myBody.angularVelocity = 1
        myBody.sleepingAllowed = false
        fill(255)
        fontSize(32)
        title = "time: (v_x, v_y), w"
    end
    
    function draw()
        background(0)
        s = string.format("%.1f: (%.2f, %.2f), %.2f",
            ElapsedTime, myBody.linearVelocity.x,
            myBody.linearVelocity.y, myBody.angularVelocity)
        text(title, WIDTH / 2, HEIGHT / 2 + 50)
        text(s, WIDTH / 2, HEIGHT / 2)
    end
    
  • SimeonSimeon Admin Mod
    Posts: 5,362

    Thanks @mpilgrem. I've fixed the physics.body issues (and docs). I've also modified color() to behave similarly to fill() and stroke().

  • Posts: 502

    About the edit bug, it only happens in portrait mode. When I hit backspace it removed the letter 10 steps to the right instead of O.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    .@tnlogy thanks, I was able to reproduce the issue. I can't actually fix this bug without rewriting the editor (which is currently in the works — just probably not for 1.5). Is it a common occurrence for you?

  • Posts: 502

    I can live with it. Works fine if I line wrap a bit earlier, quite ok to work around.

  • Posts: 489

    Issue No. 161

    I believe that the following still apply to the 'Physics' chapter of the in-app reference:

    (1) categories and mask are not documented in the in-app reference for 'physics.body':

    categories: table, an array of the categories (0 to 15) to which the body belongs for collision filtering. The default is {0}.

    mask: table, an array of the categories of bodies with which the body will collide. The default is all categories, {0, 1, ..., 14, 15}.

    (2) the in-app reference for 'physics.body' does not document the default value for friction (0.2).

    (3) the in-app reference documents the last argument of a PRISMATIC joint as an anchor. Test2 implies that it is a directional vector.

  • Posts: 502

    Small bug with setContext. Don't know if anyone else has seen it. In this example the image drawn into setContext it cut at 493x120 instead of 560x120 which is the image size. But it is rendered correct when created from the touch event.


    function setup() displayMode(FULLSCREEN) createColorImage() end function draw() background(40, 40, 50) spriteMode(CENTER) sprite(colorImage, WIDTH/2, HEIGHT/2) end function touched() createColorImage() end function createColorImage() colorImage = image(560,120) setContext(colorImage) background() spriteMode(CORNER) sprite("Documents:ColorPicker", 0,0, 560) setContext() end
  • SimeonSimeon Admin Mod
    Posts: 5,362

    .@mpilgrem thank you for the detailed corrections. I've used your descriptions for categories and mask for now, and sent them to @John so he can review them (he's the physics guy).

    .@tnlogy I am trying this with other images and can't seem to reproduce. Perhaps you should try changing your createColorImage function to the following:


    function createColorImage() colorImage = image(560,120) setContext(colorImage) background(0,0,0,0) -- Use a transparent background spriteMode(CORNER) sprite("Documents:ColorPicker", 0,0, 560) setContext() end

    Maybe the black background just makes it look as if your image is getting cut off?

  • Posts: 502

    Strange. I use an iPad2. A workaround for me is to do like this in setup instead. I can mail you the image if you like.

        tween(.2,{},{}, "linear", createColorImage)
    
  • SimeonSimeon Admin Mod
    edited January 2013 Posts: 5,362

    Thanks @tnlogy — I'll give it a try on iPad 2 and see how your code goes. I've added your example to my bug list, so I'll check it out before the next build.

    Edit: also closing this thread. Beta 13 discussion is now here: http://twolivesleft.com/Codea/Talk/discussion/2109/codea-1.5-beta-13

This discussion has been closed.