effects: demo visualising easing functions, tuning

This commit is contained in:
Jörn Zaefferer 2009-04-23 22:14:47 +00:00
parent 60a0ae46e5
commit 67830bde80

View File

@ -33,6 +33,8 @@
canvas.height = 135; canvas.height = 135;
var ctx = canvas.getContext("2d"); var ctx = canvas.getContext("2d");
ctx.fillStyle = "black"; ctx.fillStyle = "black";
ctx.strokeStyle = "white";
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(10, 0); ctx.moveTo(10, 0);
ctx.quadraticCurveTo(0, 0, 0, 10); ctx.quadraticCurveTo(0, 0, 0, 10);
@ -44,18 +46,15 @@
ctx.lineTo(10, 0); ctx.lineTo(10, 0);
ctx.fill(); ctx.fill();
ctx.strokeStyle = "white";
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(0, 100.5); ctx.moveTo(0, 100.5);
ctx.lineTo(100, 100.5); ctx.lineTo(100, 100.5);
ctx.stroke(); ctx.stroke();
var mod = 2; ctx.lineWidth = 1.5;
ctx.beginPath(); ctx.beginPath();
$.each(new Array(100 * mod), function(position) { $.each(new Array(100), function(position) {
var ease = impl(0, position, 0, 1, 100 * mod); ctx.lineTo(position, 100 - position * impl(0, position, 0, 1, 100));
ctx.moveTo(position / mod, 100 - position / mod * ease);
ctx.lineTo(position / mod + 1, 99 - position / mod * ease);
}); });
ctx.stroke(); ctx.stroke();
graph.click(function() { graph.click(function() {