开发者

Flip <canvas> (rotate 180deg) after being published on page

I'm trying to rotate a canvas element AFTER it's been appended to the DOM. Canvas is 600x50 and this is the code at hand:

var canvas = document.get开发者_StackOverflow社区ElementsByTagName('canvas')[2];
var ctx = canvas.getContext('2d');
ctx.translate(300, 25); // rotate @ center

ctx.rotate(angle * Math.PI/180);

which isn't accomplishing the task. Am I missing something?

Thanks


Dug around and found this working solution;

context.scale(1,-1); //flip vertically 
context.translate(0,-height); //move beneath original position

works wonders!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜