I've been dedicating a significant amount of time to finding a solution, but haven't had any luck.
I'm aiming to create a visual effect where 10 words with varying font sizes slide in from different directions on a canvas within my document. I've attempted some coding (link to jsFiddle), but I'm struggling to make progress. Any guidance or advice would be greatly appreciated.
var can, ctx, step, steps = 0,
delay = 20;
function init() {
can = document.getElementById("MyCanvas1");
ctx = can.getContext("2d");
ctx.fillStyle = "blue";
ctx.font = "20pt Verdana";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
step = 0;
steps = can.height + 50;
RunTextRightToLeft();
}
function RunTextRightToLeft() {
step++;
ctx.clearRect(0, 0, can.width, can.height);
ctx.save();
ctx.translate(can.width / 2, step);
ctx.fillText("Welcome", 0, 0);
ctx.restore();
if (step == steps)
step = 0;
if (step < steps)
var t = setTimeout('RunTextRightToLeft()', delay);
}
canvas {
border: 1px solid #bbb;
}
.subdiv {
width: 320px;
}
.text {
margin: auto;
width: 290px;
}
<body onload="init();">
<div class="subdiv">
<canvas id="MyCanvas1" width="300" height="200">
</canvas>
</div>
</body>
Appreciate your help!