Enhance your video recordings
  • ZoytZoyt
    Posts: 1,249

    Hello,
    When I upgraded to 1.3, I noticed that the recodings do not include recording of the keyboard and touches. So I went a little farther and created this library to enhance your recordings. It's a little sloppy right now, but it will do.

    function setup()
        touches = {}
        showKeyboard()
    end
    
    function draw()
        background(0, 0, 0, 255)
        enchanceRecording(CurrentTouch.x, CurrentTouch.y,1)
    end
    
    function enchanceRecording(gravx,gravy,shoingkeyboard)
        local buffer = keyboardBuffer()
        local _, gravh = textSize(Gravity.x)
        if isRecording() then
            font("HelveticaNeue")
            fill(179, 179, 179, 127)
            stroke(255, 255, 255, 127)
            strokeWidth(3)
            for k,touch in pairs(touches) do
                ellipse(touch.x, touch.y, 100, 100)
            end
            if shoingkeyboard == 1 then
                if buffer == nil then buffer = " " end
                textWrapWidth(WIDTH)
                if WIDTH == 1024 and HEIGHT == 768 or WIDTH == 750 and HEIGHT == 768 then
                    rect(0,0,WIDTH,HEIGHT/2-30)
                    fill(255, 0, 0, 255)
                    text("Typed text:".. buffer,WIDTH/2,(HEIGHT/2-30)/2)
                elseif WIDTH == 768 and HEIGHT == 1024 or WIDTH == 494 and HEIGHT == 1024 then
                    rect(0,0,WIDTH,HEIGHT/3-75)
                    fill(255, 0, 0, 255)
                    text("Typed text:".. buffer,WIDTH/2,(HEIGHT/3-75)/2)
                end
                fill(30, 255, 0, 255)
                text("Gravity X: ".. Gravity.x,gravx,gravy)
                text("Gravity Y: ".. Gravity.y,gravx,gravy-gravh)
                text("Gravity Z: ".. Gravity.z,gravx,gravy-gravh*2)
                text("User Acceleration X: ".. UserAcceleration.x,gravx,gravy-gravh*4)
                text("User Acceleration Y: ".. UserAcceleration.y,gravx,gravy-gravh*5)
                text("User Acceleration Z: ".. UserAcceleration.z,gravx,gravy-gravh*6)
            end
        end 
    end
    
    
    function touched(touch)
        if touch.state == ENDED then
            touches[touch.id] = nil
        else
            touches[touch.id] = touch
        end
    end
    

    That turns out like this:

    If the video doesn't work, click here.

    Here is the link.

    What's left to do? This:
    1. Get rid of all the unnecessary numbers in the user acceleration and gravity.
    2. And a few other small things I don't feel like listing right now.
    Have fun!

  • SimeonSimeon
    Posts: 2,856

    That's pretty cool, @Zoyt. Looks pretty useful for debugging.

    The video seems to not embed properly, so you might want to edit your post to contain the link as well.

    Edit: @Zoyt please edit your existing posts to add extra information, don't reply to the topic. I've moved your replies into the OP.

  • ZoytZoyt
    Posts: 1,249

    @Siemon - I was in the middle of the process of editing it. I usually do. Thanks!

    It works only on the mac.

  • SimeonSimeon
    Posts: 2,856

    Again, please don't add multiple replies to a topic. Just edit your existing posts instead of replying.

    That said, this is a really good idea. I like the implementation.

  • ZoytZoyt
    Posts: 1,249

    Just though I might update this to take advantage of the isKeyboardShowing() and images features. Here's the code:


    function setup() touches = {} iparameter("ShowKeyboard",0,1) iparameter("ti",1,2) end function draw() background(0, 0, 0, 255) if ShowKeyboard == 1 then showKeyboard() else hideKeyboard() end enchanceRecording(CurrentTouch.x, CurrentTouch.y) end function enchanceRecording(gravx,gravy) local buffer = keyboardBuffer() local _, gravh = textSize(Gravity.x) if isRecording() then font("HelveticaNeue") fill(179, 179, 179, 127) stroke(255, 255, 255, 127) strokeWidth(3) for k,touch in pairs(touches) do if ti == 1 then ellipse(touch.x, touch.y, 100, 100) else tint(0, 0, 0, 127) sprite("Tyrian Remastered:Energy Orb 1",touch.x, touch.y,750, 750) end end if isKeyboardShowing() then if buffer == nil then buffer = " " end textWrapWidth(WIDTH) if WIDTH == 1024 and HEIGHT == 768 or WIDTH == 750 and HEIGHT == 768 then rect(0,0,WIDTH,HEIGHT/2-30) fill(255, 0, 0, 255) text("Typed text:".. buffer,WIDTH/2,(HEIGHT/2-30)/2) elseif WIDTH == 768 and HEIGHT == 1024 or WIDTH == 494 and HEIGHT == 1024 then rect(0,0,WIDTH,HEIGHT/3-75) fill(255, 0, 0, 255) text("Typed text:".. buffer,WIDTH/2,(HEIGHT/3-75)/2) end --Debug features: --fill(30, 255, 0, 255) --text("Gravity X: ".. Gravity.x,gravx,gravy) --text("Gravity Y: ".. Gravity.y,gravx,gravy-gravh) --text("Gravity Z: ".. Gravity.z,gravx,gravy-gravh*2) --text("User Acceleration X: ".. UserAcceleration.x,gravx,gravy-gravh*4) --text("User Acceleration Y: ".. UserAcceleration.y,gravx,gravy-gravh*5) --text("User Acceleration Z: ".. UserAcceleration.z,gravx,gravy-gravh*6) end end end function touched(touch) if touch.state == ENDED then touches[touch.id] = nil else touches[touch.id] = touch end end

    I haven't coded in Codea for a while, so this is not one of my best works.

Howdy, Stranger!

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

In this Discussion

Tagged