Skip to content

added paletteLerp#6960

Merged
davepagurek merged 7 commits into
processing:mainfrom
RandomGamingDev:paletteLerp
Aug 11, 2024
Merged

added paletteLerp#6960
davepagurek merged 7 commits into
processing:mainfrom
RandomGamingDev:paletteLerp

Conversation

@RandomGamingDev
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
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