Skip to content

Commit 4c446c4

Browse files
committed
Edit interpolate and add thumbnail
1 parent bc1283f commit 4c446c4

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

examples/06_Calculating_Values/00_Interpolate.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
/*
1+
/**
22
* @name Linear Interpolation
3-
* @arialabel White circle follows the user’s mouse around the screen
43
* @frame 720, 400
5-
* @description Move the mouse across the screen and the symbol will follow.
4+
* @description
5+
* <a href="https://developer.mozilla.org/en-US/docs/Glossary/Interpolation" target="_blank">Interpolation</a>
6+
* calculates a value between two other values. For example, the number 5 is
7+
* halfway between 0 and 10. Different types of interpolation uses
8+
* different rates of change between values. Linear interpolation,
9+
* abbreviated as lerp, uses a constant rate of change. The
10+
* <a href="https://p5js.org/reference/#/p5/lerp" target="_blank">lerp()</a>
11+
* function linearly interpolates between two numbers.
12+
*
13+
* Move the mouse across the screen and the symbol will follow.
614
* Between drawing each frame of the animation, the ellipse moves part
7-
* of the distance (0.05) from its current position toward the cursor using
8-
* the lerp() function.
9-
* This is the same as the Easing under input only with lerp() instead..
15+
* of the distance from its current position toward the cursor.
1016
*/
1117

1218
let x = 0;
@@ -15,6 +21,7 @@ let y = 0;
1521
function setup() {
1622
createCanvas(720, 400);
1723
noStroke();
24+
textOutput();
1825
}
1926

2027
function draw() {
@@ -25,7 +32,7 @@ function draw() {
2532
// where 0.0 equal to the first point, 0.1 is very near the first point, 0.5
2633
// is half-way in between, etc.
2734

28-
// Here we are moving 5% of the way to the mouse location each frame
35+
// Move 5% of the way to the mouse location each frame
2936
x = lerp(x, mouseX, 0.05);
3037
y = lerp(y, mouseY, 0.05);
3138

8.47 KB
Loading

0 commit comments

Comments
 (0)