Skip to content

Instantly share code, notes, and snippets.

@shiffman
Created November 18, 2013 15:35
Show Gist options
  • Save shiffman/7529804 to your computer and use it in GitHub Desktop.
Save shiffman/7529804 to your computer and use it in GitHub Desktop.
Simple demonstration of lerp (as compared to average demo).
// Simple interpolated value demonstration
// Daniel Shiffman
float lerpedMouseX;
void setup() {
size(300, 300);
}
void draw() {
background(0);
// The following moves lerpedMouseX "10%" of the way from itself to mouseX.
lerpedMouseX = lerp(lerpedMouseX,mouseX,0.1);
// Draw raw value and average to compare
ellipse(mouseX, 100, 32, 32);
ellipse(lerpedMouseX, 200, 32, 32);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment