GSDP:GAM100/CProcessing/lerpColorHSV()

From Inside
Jump to: navigation, search

lerpColorHSV()

Description

Linearly lerps between 2 given HSV color values on a scale from 0.0 to 1.0. Returns the newly determined color.

Parameters

lerpColor(PColor a, PColor b, float t)

  • a - (PColorHSV) the base color to lerp from. The return value is a when t = 0.0
  • b - (PColorHSV) the end color to lerp to. The return values is b when t = 1.0
  • t - (float) the value between 0.0 and 1.0 used to linearly lerp from a to b

Example

float counterHSV = 0;
bool countUp = true;
PColorHSV start;
PColorHSV end;

void init()
{
  size(400, 400);
  rectMode(CORNER);

  start = colorHSV(0, 100, 50, 255);
  end = colorHSV(360, 100, 50, 255);
}

void update()
{
  background(color(0, 0, 0, 255));
  PColorHSV hsv = lerpColorHSV(start, end, counterHSV);
  fill(hsv2rgb(hsv));
  rectRounded(10, 10, 380, 380, 20);

  counterHSV += countUp == true ? dt() : -dt();

  if (counterHSV > 1.0 || counterHSV < 0.0f)
  {
    counterHSV = clampFloat(counterHSV, 0.0f, 1.0f);
    countUp = !countUp;
  }
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>