#### 移动坐标原点
方法:translate(x,y):x,y代表移动后x,y坐标
#### 旋转坐标系
方法:rotate(angle), 旋转角度,整数为逆时针,负数为顺时针。
实例
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<canvas id="c2d" width="500" height="500">不支持canvas</canvas>
<script>
const canvas = document.querySelector('#c2d');
if(canvas.getContext) {
const ctx = canvas.getContext('2d');
ctx.fillRect(0,0,10,30);
ctx.translate(10,30);
ctx.fillRect(0,0,10,30);
ctx.translate(10,30);
ctx.rotate(-Math.PI * 1/2);
ctx.fillStyle='red';
ctx.fillRect(0,0,10,30);
}
</script>
</body>
</html>
```
![运行结果](https://upload-images.jianshu.io/upload_images/2789632-b0683e5537c89659.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)