P
P
Proshka172015-05-20 21:01:12
Canvas
Proshka17, 2015-05-20 21:01:12

What's wrong here (canvas)?

Why didn't the text rotate? I just started reading about canvas and I don't understand why it doesn't work. Please tell me how to rotate the text by a certain degree.

<html>
<head>
</head>
<body>
<canvas id="canvas" width="600" height="300"></canvas>
</body>
<script>
var ctx = document.getElementById('canvas').getContext('2d')
ctx.translate(100,100)
ctx.font = "bold italic 30px sans-serif"
ctx.strokeText("Привет Хабр",0,0)
ctx.rotate(45*Math.PI/180)
</script>
</html>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2015-05-26
@twobomb

https://jsfiddle.net/twobomb/xb1rnf3c/3/

K
Keyten, 2015-06-13
@Keyten

Place rotate before rendering the text. You want to rotate the canvas first and then draw the text, not the other way around, right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question