JSFiddle - React, Tailwind, and code Playground

by hellosze

HTML

<canvas width=500 height=500>

JavaScript

CanvasRenderingContext2D.prototype.fillTextCircle = function(text,x,y,radius,startRotation){
   var numRadsPerLetter = 2*Math.PI / text.length;
   this.save();
   this.translate(x,y);
   this.rotate(-Math.PI*2/100*step++);
   this.rotate(startRotation);

   for(var i=0;i<text.length;i++){
      this.save();
      this.rotate(i*numRadsPerLetter);

      this.fillText(text[i],0,-radius);
      this.restore();
   }
   this.restore();
}

var ctx = $('canvas').get(0).getContext('2d');
ctx.font = '20pt Segoe UI';

var step = 0;

setInterval(function() {
    ctx.clearRect(0, 0, 500, 500);
    ctx.save();
    ctx.fillTextCircle('Rotating text             ', 100, 100, 50, 0);
    ctx.restore();
}, 20);