要求使用画布变换方法。
椭圆画法参照大神佳作:http://web.jobbole.com/82960/
效果如下:
代码如下:
<!DOCTYPE html>
<html>
<head>
<title>旋转椭圆</title>
<meta charset="utf-8">
</head>
<body>
<canvas id="canvas" width="600" height="600"></canvas>
<script type="text/javascript">
var canvas = document.querySelector('#canvas'),
context = canvas.getContext('2d');
var width = canvas.width,
height = canvas.height;
// 原点坐标
var originX = width / 2,
originY = height / 2,
radius = 100;
context.lineWidth = 1;
/* 画椭圆
* x, y表示原点坐标
* radiusX, radiusY分别表示x和y