简体   繁体   English

HTML5画布,用户绘图调整大小并旋转

[英]HTML5 canvas, user drawing resize and rotate

I have a canvas on which the user can draw with some sort of pen. 我有一个画布,用户可以用某种笔在其上绘图。 The canvas height is slightly larger than the width. 画布高度略大于宽度。 The actual size depends on several variables. 实际大小取决于几个变量。 I want to give the user the ability to rotate his/her drawing. 我想让用户能够旋转他/她的绘图。 I'm creating a new canvas on which i draw the old canvas rotated. 我正在创建一个新的画布,在其上绘制旋转的旧画布。

Below is how i did 180 degrease. 以下是我如何进行180除脂。

if(rotation==180){
    ctx.translate(canvas.width/2, canvas.height/2);
    ctx.rotate(Math.PI);
    ctx.translate(-canvas.width/2, -canvas.height/2);
    ctx.drawImage(drawing,0,0);
}

Now for the 90 degrease I also have to do a resize because otherwise it won´t fit anymore. 现在,对于90磅的脱脂剂,我还必须进行调整大小,因为否则将不再适合。 I'm not even sure where to start. 我什至不知道从哪里开始。 Any ideas on how to do this? 有关如何执行此操作的任何想法?

u can use CSS3 for rotation:like 您可以使用CSS3进行旋转:喜欢

h1
{
rotation-point:50% 50%;
rotation:180deg;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM