easing_random
easing_random(ease, [min], [max])
Return a random point with a probability controlled by easing function. Value between 0 and 1, or between min and max.
Syntaxe
var value = easing_random("easeInSine");
var value = easing_random("easeInSine", min=0, max=100);
Arguments
| Name | Required | Default | Description |
|---|---|---|---|
ease | yes | - | Name of easing function |
min | - | - | Minimum value of the result (0 if not specified) |
max | - | - | Maximum value of the result (1 if not specified) |
Full example
var EASES = [
"easeInSine", "easeInQuad", "easeInCubic",
"easeInQuart", "easeInQuint", "easeInExpo",
"easeInCirc", "easeInBack", "easeInBounce",
// Out
"easeOutSine", "easeOutQuad", "easeOutCubic",
"easeOutQuart", "easeOutQuint", "easeOutExpo",
"easeOutCirc", "easeOutBack", "easeOutBounce",
// InOut
"easeInOutSine", "easeInOutQuad", "easeInOutCubic", "easeInOutQuart", "easeInOutQuint", "easeInOutExpo", "easeInOutCirc", "easeInOutBack", "easeInOutBounce",
// OutIn
"easeOutInSine", "easeOutInQuad", "easeOutInCubic", "easeOutInQuart", "easeOutInQuint", "easeOutInExpo",
"easeOutInCirc", "easeOutInBack", "easeOutInBounce",
// Special
"gaussian", "easeOutGaussian", "easeInOutGaussian", "easeInGaussian",
"standard"
];
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 k=0; k<nb;k++) {
var x = easing_random(easeName, minX, maxX);
var y = randfloat(minY, maxY);
circle(x, y, r, fill=colColor, stroke="transparent");
}
text(easeName, minX+(resultsDim/2), maxY+10, 0.5, 0.5);
}
save("easing_random.png");
