Here’s a sketch that uses both the p5-func library for easing functions, AND the p5-createloop library to generate GIFs. Note how some of the easing functions take parameters (knobs) that articulate how they perform.
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution NonCommercial ShareAlike
animLoop+p5.func
Levin
xxxxxxxxxx
// Uses https://www.npmjs.com/package/p5.createloop
// Be sure that the following script is included in index.html:
// https://unpkg.com/p5.createloop@0.3.1/dist/p5.createloop.js
// Also uses p5-func, https://idmnyu.github.io/p5.js-func/
// Create the easing function generator
var ease = new p5.Ease();
var easingAlgos = ease.listAlgos();
var nAlgos = easingAlgos.length;
var curAlgo;
var curAlgoID;
var mx = 0;
//------------------------------------------
function setup() {
createCanvas(600, 500);
print(easingAlgos);
curAlgoID = 1;
curAlgo = "doubleOddPolynomialOgee"; //random(easingAlgos);
pixelDensity(1);
createLoop({
duration: 4,
gif: false // set to true to export GIF
});
}
//------------------------------------------
function draw() {
background("DodgerBlue");
drawDebug();
noStroke();
fill("white");
rectMode(CENTER);
// Generate several different "eased" versions of the progress variable.
var p = animLoop.progress;
mx = constrain(mouseX/width, 0,1);
var easeA01 = ease["normalizedLogitSigmoid"](p, mx);
var easeB01 = ease["cubicInOut"](p);
var easeC01 = ease["bounceOut"](p);
var easeD01 = ease[curAlgo](p, 0.5, mx);
// Draw the four ticks
var x1 = width * easeA01;
rect(x1, 100, 10, 50);
var x2 = width * easeB01;
rect(x2, 200, 10, 50);
var x3 = width * easeC01;
rect(x3, 300, 10, 50);
var x4 = width * easeD01;
rect(x4, 400, 10, 50);
}
//---------------------------------------------------------
function keyPressed() {
// Choose a new easing function for the bottom tick
// when you press the L/R arrow keys.
if (key == 'ArrowLeft') {
curAlgoID = (curAlgoID - 1 + nAlgos) % nAlgos;
curAlgo = easingAlgos[curAlgoID];
} else if (key == 'ArrowRight') {
curAlgoID = (curAlgoID + 1) % nAlgos;
curAlgo = easingAlgos[curAlgoID];
}
print(curAlgo);
}
//------------------------------------------
function drawDebug() {
// Draw the grid and the text.
stroke(255,255,255, 80);
for (var i=1; i<10; i++){
var x = map (i, 0,10, 0, width);
line(x, 0, x,height);
}
textSize(20);
textAlign(LEFT, CENTER);
fill(255,160);
noStroke();
text("normalizedLogitSigmoid (" + nf(mx,1,2) + ")", 20, 100);
text("cubicInOut", 20, 200);
text("bounceOut", 20, 300);
text(curAlgo, 20, 400);
}
See More Shortcuts
Please verify your email to comment
Verify Email