我只是在玩帆布,而我试图让它在一个圆圈而不是一个方形中移动,这可能吗?如果是,怎么样?
这是我到目前为止所做的事情,而且我不知道如何让它在一个圆圈内移动。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>derp</title>
</head>
<body>
<canvas id="canvas" width="800" height="500" style="border:1px solid #d3d3d3;"></canvas>
<script type="text/javascript" language="JavaScript">
var height = 500;
var width = 800;
var radius = 100;
var x = 100;
var y = 100;
var xass = 0;
function draw(){
if(x == 100 && y == 100){
xass = 0
}
if(x == 700 && y == 100){
xass = 1
}
if(x == 700 && y == 400){
xass = 2
}
if(x == 100 && y == 400){
xass = 3
}
if( xass == 0){
x++
}
else if(xass == 1){
y++
}
else if(xass == 2){
x--
}
else if(xass == 3){
y--
}
var c = document.getElementById("canvas");
var ctx = c.getContext("2d");
ctx.clearRect(0, 0, 800, 500);
ctx.beginPath();
ctx.moveTo(400,250);
ctx.lineTo(x,y);
ctx.stroke();
ctx.beginPath();
ctx.arc(x,y,5,0,2*Math.PI);
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.arc(400,250,15,0,2*Math.PI);
ctx.stroke();
}
</script>
<style>
canvas {
margin-left: auto;
margin-right: auto;
display: block;
}
</style>
</body>
</html>
答案 0 :(得分:2)
看到这个https://jsfiddle.net/kup3qe5c/2/我刚刚使用了圆形函数(数学)
application.getAccounts(Accounts.where(Accounts.email().eqIgnoreCase(email)));
答案 1 :(得分:0)
// Create a rectangle shaped path with its top left point at
// {x: 75, y: 75} and a size of {width: 75, height: 75}
var path = new Path.Rectangle({
point: [75, 75],
size: [75, 75],
strokeColor: 'black'
});
function onFrame(event) {
// Each frame, rotate the path by 3 degrees:
path.rotate(3);
}
这会有帮助吗