Skip to content

Ported "Input" examples from Processing#12

Merged
lee2sman merged 9 commits intoL5lua:mainfrom
hmyam6090-lab:main
Mar 20, 2026
Merged

Ported "Input" examples from Processing#12
lee2sman merged 9 commits intoL5lua:mainfrom
hmyam6090-lab:main

Conversation

@hmyam6090-lab
Copy link
Contributor

Ported all examples under the Input section of the Processing examples website

https://processing.org/examples/

Specifically, the adapted examples were: Clock, Constrain, Easing, Keyboard, Keyboard Functions, Milliseconds, Mouse 1D, Mouse 2D, Mouse Functions, Mouse Press, Mouse Signals and Storing Input.

There was feature parity on most input examples in processing, with just two trivial small difference:

  1. The built-in key variable for the "Keyboard" and "Keyboard Functions" example under the keyPressed() function needed to be converted from string to its byte value first.
Screenshot 2026-03-08 at 3 28 23 AM

as opposed to

Screenshot 2026-03-08 at 3 29 18 AM
  1. I think this is intentional but in the "Mouse Press" example, the conditional to check if the mouse is being pressed uses the "mouseIsPressed" built-in variable instead of Processing's "mousePressed"
Screenshot 2026-03-08 at 3 33 16 AM

Ported all examples under the Input section of the Processing examples website.
@lee2sman
Copy link
Contributor

lee2sman commented Mar 8, 2026

Excellent! I look forward to reviewing these.

It's late here and so this should be reviewed with fresh eyes, but my instinct is that it might be easier to use string.match like if string.match(key, "^[A-Z]$") then potentially.

local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    
    if string.match(key, "^[A-Z]$") then
        keyIndex = string.find(alphabet, key) - 1
        letterHeight = maxHeight
        fill(colors[keyIndex])
    elseif string.match(key, "^[a-z]$") then
        keyIndex = string.find(alphabet, string.upper(key)) - 1
        letterHeight = minHeight
        fill(colors[keyIndex])
    else
        fill(0)
        letterHeight = 10
    end

hmmm. maybe not! after writing all that, i don't think it saves any code! maybe there's an even more idiomatic way to do it?

  1. yes, we use mouseIsPressed like in p5.js. Do you have a suggestion where this could be better documented on the L5 website?

I really appreciate the effort here and I think the best place to put these is on the L5 website itself by building out the Examples page there. It would be nice to have it follow the design of Processing's example page or p5's example page. My apologies on the additional work suggestion. I should perhaps either retire this section or add a note that examples go there.

Thanks for all your contributions!

@lee2sman
Copy link
Contributor

We can pull these in after the L5-website merge, making sure these are copies of those!

@Nitish-bot Nitish-bot mentioned this pull request Mar 17, 2026
Matched the revised input examples in the L5 website, with proper crediting/licensing.

Cleaned up unrelated L5.lua and main.lua changes for another issue
@lee2sman
Copy link
Contributor

Looks like L5.lua, main.lua and TODO.txt got pulled in by mistake, and an extra .../beginShapeTrianglsWithTexture.lua — can you revert those files to match main? Rest of examples ok! Thank you. Almost there.

@hmyam6090-lab
Copy link
Contributor Author

Got it! I think it was because my fork wasn't synced with main after the other PRs got merged.

Thank you for being so patient with me! Should be all set now.

@lee2sman lee2sman merged commit 53378fc into L5lua:main Mar 20, 2026
@lee2sman
Copy link
Contributor

Thanks for your work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants