相关疑难解决方法(0)

在画布旋转后查找坐标

0到0,-70由此:

ctx.strokeStyle = "red";
ctx.lineWidth = 2;
ctx.rotate(Math.PI/-10;);
ctx.beginPath();
ctx.moveTo(0,0); 
ctx.lineTo(0,-70);
ctx.stroke();
Run Code Online (Sandbox Code Playgroud)

我可以通过'PI/-10'旋转它,这是有效的.

如何在使用旋转后获得x,y点数?

javascript html5 canvas html5-canvas

2
推荐指数
1
解决办法
4777
查看次数

在 html 画布中绘制具有特定角度的线

我尝试在 html 画布中画一条具有一定角度的线。不幸的是,这条线没有以所需的角度出现。有人可以告诉我我做错了什么吗?

html代码:

<!DOCTYPE html>
<html lang="de">
    <head>
        <title>Test html canvas</title>
    </head>
    <body>
        <canvas id="cumulatedView" width="250" height="250"></canvas>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

CSS代码:

canvas{
  background-color: grey;
  background-position: center;
  background-size: 100% 100%;
}
Run Code Online (Sandbox Code Playgroud)

JavaScript 代码:

var angle = 90; // Degree

var c = document.getElementById("cumulatedView");
var ctx = c.getContext("2d");
x1 = 125;
y1 = 125;
length =  100;

x2 = x1 + Math.cos((Math.PI / 180.0) * angle - 90) * length
y2 = y1 + Math.sin((Math.PI / 180.0) * angle - 90) * …
Run Code Online (Sandbox Code Playgroud)

javascript canvas

2
推荐指数
1
解决办法
4930
查看次数

标签 统计

canvas ×2

javascript ×2

html5 ×1

html5-canvas ×1