Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <canvas id="myCanvas" width="679" height="290"></canvas>
  2.  
  3. function drawTextAlongArc(context, str, centerX, centerY, radius, angle) {
  4. var len = str.length, s;
  5.  
  6. context.save();
  7. context.translate(centerX, centerY);
  8. context.rotate(-1 * angle / 2);
  9. context.rotate(-1 * (angle / len) / 2);
  10.  
  11. for(var n = 0; n < len; n++) {
  12. context.rotate(angle / len);
  13. context.save();
  14. context.translate(0, -1 * radius);
  15.  
  16. s = str[n];
  17. context.fillText(s, 0, 0);
  18. context.restore();
  19. }
  20. context.restore();
  21. }
  22.  
  23. var canvas = document.getElementById('myCanvas'),
  24. context = canvas.getContext('2d'),
  25. centerX = canvas.width / 2,
  26. centerY = canvas.height + 40,
  27. angle = Math.PI * 0.8,
  28. radius = 250;
  29.  
  30. context.font = 'bold 30pt Ubuntu';
  31. context.textAlign = 'center';
  32. context.fillStyle = 'orange';
  33. context.strokeStyle = '#336699';
  34. context.lineWidth = 10;
  35.  
  36. drawTextAlongArc(context, 'Sustainable Skill Solutions', centerX, centerY, radius, angle);
  37.  
  38.  
  39. // draw circle underneath text
  40. context.arc(centerX, centerY, radius +70, 0, 2 * Math.PI, false);
  41. context.stroke();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement