Skip to content

Ported "Input" examples from Processing#12

Open
hmyam6090-lab wants to merge 2 commits intoL5lua:mainfrom
hmyam6090-lab:main
Open

Ported "Input" examples from Processing#12
hmyam6090-lab wants to merge 2 commits intoL5lua:mainfrom
hmyam6090-lab:main

Conversation

@hmyam6090-lab
Copy link

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!

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.

2 participants