p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

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

Open LalitNarayanYadav opened this issue 6 months ago • 4 comments

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 avatar Jun 07 '25 21:06 LalitNarayanYadav

fixes #7875

LalitNarayanYadav avatar Jun 07 '25 23:06 LalitNarayanYadav

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.

LalitNarayanYadav avatar Jun 12 '25 05:06 LalitNarayanYadav

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

lukeplowden avatar Jun 12 '25 09:06 lukeplowden

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

LalitNarayanYadav avatar Jun 12 '25 12:06 LalitNarayanYadav

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

lukeplowden avatar Jun 16 '25 16:06 lukeplowden

@all-contributors please add @LalitNarayanYadav for code

davepagurek avatar Jun 16 '25 17:06 davepagurek

@davepagurek

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

allcontributors[bot] avatar Jun 16 '25 17:06 allcontributors[bot]

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 avatar Jun 16 '25 17:06 LalitNarayanYadav