Skip to content
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

added paletteLerp #6960

Merged
merged 7 commits into from
Aug 11, 2024
Merged

added paletteLerp #6960

merged 7 commits into from
Aug 11, 2024

Conversation

RandomGamingDev
Copy link
Contributor

Resolves #6959

Changes:

Add a function called paletteLerp() for lerping/interpolating between a list/palette of colors.

Screenshots of the change:

function setup() {
  createCanvas(400, 400);
}

function draw() {
  const palette = [color("red"), color("yellow"), color("green")];
  const lerp_color = paletteLerp(palette, (millis() / 2000) % 1);
  background(lerp_color);
}

PR Checklist

@RandomGamingDev
Copy link
Contributor Author

RandomGamingDev commented Aug 11, 2024

Here's what the new version requested using color stops uses:

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(lerpPalette([
    ["white", 0],
    ["red", 0.05],
    ["green", 0.25],
    ["blue", 1]
  ], millis() / 10000 % 1));
}

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.

This looks good! You mentioned on Discord potentially having a version that supports just an array of numbers for evenly-spaced stops, do you want me to wait before merging for that or do you want that to be a follow-up?

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.

We talked on Discord and probably will end up doing another PR if we want to add a version with no stops, so I'll merge this now!

@davepagurek davepagurek merged commit 56ec9b6 into processing:main Aug 11, 2024
2 checks passed
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.

Add a function for interpolating between multiple colors
2 participants