53 ctx.textBaseline = "middle"; ctx.textAlign = "left"; var textX = canvas.width + 6; var textOffset = 0; var startTime; function update(time){ if(startTime == undefined){ startTime = time; } ctx.fillStyle = BGStyle; ctx.fillRect(0, 0, canvas.width, canvas.height); textOffset = ((time - startTime) * textSpeed) % (totalTextSize); ctx.fillStyle = textStyle; ctx.fillText(textToDisplay, textX - textOffset, canvas.height / 2); requestAnimationFrame(update); } requestAnimationFrame(update); </script> </html> Referensi : Learning HTML5 Canvas (modifikasi)
RkJQdWJsaXNoZXIy MTM3NDc5MQ==