GSDP:GAM100/CProcessing/CP Math LerpFloat()

From Inside
Jump to: navigation, search

CP_Math_LerpFloat()

Description

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

Parameters

CP_Math_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 = CP_Image_Load("./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 = CP_Math_LerpFloat(0.0f, 360.0f, rot_counter);
  CP_Settings_Background(CP_Color_Create(255, 255, 255, 255));
  CP_Image_DrawAdvanced(justin_face, CP_Input_GetMouseWorldX(), CP_Input_GetMouseWorldY(), 100, 150, 255, rotation);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>