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

Open
wants to merge 8 commits into
base: dev-2.0
Choose a base branch
from

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.

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