Skip to content

Alias GLSL's mix function as lerp in p5.strands (#7875) #7887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 16, 2025

Conversation

LalitNarayanYadav
Copy link
Contributor

Resolves #7875

Changes:

  • Introduced an alias for the GLSL mix function under the name lerp in p5.strands.
  • Ensures that lerp() within p5.strands maps to mix() when generating shader expressions.
  • Falls back to the original p5.js lerp() function outside of p5.strands.

Rationale:

This change bridges the gap between core p5.js and p5.strands by making lerp() work seamlessly within shader code. It increases accessibility by allowing familiar p5.js functions to be used in new contexts.

A short inline comment was also added for clarity:

PR Checklist

@LalitNarayanYadav
Copy link
Contributor Author

LalitNarayanYadav commented Jun 7, 2025

fixes #7875

Copy link
Member

@lukeplowden lukeplowden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Lalit for working on this! I've left a couple of suggestions. What was causing a reference error, however? I can't recreate it. If you could let me know a bit about your dev environment that might help. How are you building the library or importing this module?

@lukeplowden lukeplowden self-assigned this Jun 10, 2025
@LalitNarayanYadav
Copy link
Contributor Author

I was using VS Code but the issue I was facing was not because of environment. I had created a syntax error by mistake which I was not noticing.

@lukeplowden
Copy link
Member

Thank you, almost there! Could you also remove the unused variable fn on line 11?

@LalitNarayanYadav
Copy link
Contributor Author

I have made the changes as you suggested. Please review it when you have time.

@lukeplowden
Copy link
Member

Thank you for working on this! It looks good to me. @davepagurek could you review too?

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @LalitNarayanYadav! Let us know if you're interested in taking on more strands functions 🙂

@davepagurek davepagurek merged commit 5579bb8 into processing:dev-2.0 Jun 16, 2025
2 checks passed
@davepagurek
Copy link
Contributor

@all-contributors please add @LalitNarayanYadav for code

Copy link
Contributor

@davepagurek

I've put up a pull request to add @LalitNarayanYadav! 🎉

@LalitNarayanYadav
Copy link
Contributor Author

Looks great, thanks @LalitNarayanYadav! Let us know if you're interested in taking on more strands functions 🙂

You're very welcome @davepagurek ! 😊 And thank you@ I'd be glad to take on more p5.strands functions or any other related work! Just let me know where help is needed next. happy to contribute more.

@LalitNarayanYadav LalitNarayanYadav deleted the patch-7 branch June 16, 2025 17:25
@LalitNarayanYadav LalitNarayanYadav restored the patch-7 branch June 16, 2025 17:25
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