GSDP:GAM100/CProcessing/lerpFloat()

From Inside
Jump to: navigation, search

lerpFloat()

Description

Linearly interpolates between two input floats with an input lerp factor.

Parameters

lerpFloat(float a, int b, float lerp_factor)

  • a - (float) The value the function returns when lerp_factor is 0.0, the starting value.
  • b - (float) The value the function returns when lerp_factor is 1.0, the ending value.
  • lerp_factor - (float) The ratio used to determine what value to return between a and b.

Example

PImage justin_face;
void init()
{
  justin_face = loadImage("./Assets/justin1.png");
}

float rot_counter = 0;
void update()
{
  // Increment rotation lerp factor or reset
  if (rot_counter >= 1.0f)
    rot_counter -= 1.0f;
  else
    rot_counter += dt();

  // Lerp rotation and draw image
  float rotation = lerpFloat(0.0f, 360.0f, rot_counter);
  background(color(255, 255, 255, 255));
  imageRotated(justin_face, mouseX, mouseY, 100, 150, 255, rotation);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>