easing
easing(ease, value)
Return a value between 0 and 1 according to the specified easing function.
Syntaxe
var value = easing("easeInSine", 0.5);
Arguments
| Name | Required | Default | Description |
|---|---|---|---|
ease | yes | - | Name of easing function |
value | yes | - | Normalized input value between 0 and 1 |
Full example
var EASES = easing_list();
var W = 1600 ;
var r = 1.5;
var colColor = "#3C3836";
var nb = 2000;
var resultsGap = 30.0;
var cols = 9;
var offset = 400;
var availableWidth = W - resultsGap*(cols+1);
var resultsDim = availableWidth / cols;
var totalCases = length(EASES) ;
var rows = ceil(totalCases / cols);
var H = rows*resultsDim + (rows+1)*resultsGap;
canvas(width=W, height=H, background="#EBDBB2");
for (var j = 0; j < length(EASES); j++) {
var easeName = EASES[j];
var row = floor(j / cols);
var col = j % cols;
var minX = col*(resultsDim+resultsGap) + resultsGap;
var maxX = minX + resultsDim;
var minY = row*(resultsDim+resultsGap) + resultsGap;
var maxY = minY + resultsDim;
rectangle(x=minX, y=minY, w=resultsDim, h=resultsDim, stroke="#000");
for (var px = 0; px <= round(resultsDim); px++) {
var t = px / resultsDim;
var v = 1 - easing(easeName, t);
var py = minY + v * resultsDim;
circle(minX + px, py, r, fill=colColor, stroke="transparent");
}
text(easeName, minX + resultsDim/2, maxY + 10, 0.5, 0.5);
}
save("easing.png");
