HTML5 Game - Canvas Rotate text

Description

Rotate text

Demo

ResultView the demo in separate window

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Chapter 6</title>
</head>/*  w ww.  j  a v  a  2s .c  o m*/
<script>
function onload() {
  let canvas=document.getElementById("canvas");
  let context=canvas.getContext("2d");
    context.font = 'bold 30px Times';
  context.rotate(Math.PI / 4);
   context.fillText("Hello World!", canvas.width / 4, 0);
  context.restore();
}
</script>
<body onload="onload()">
    <canvas id="canvas" width="320" height="480">Get a better browser!</canvas>
</body>
</html>

Related Topic