canvas移动画布原点
时间: 2023-08-22 17:06:13 浏览: 248
回答: 在canvas中,移动画布的原点可以通过调用`translate`方法来实现。例如,可以使用以下代码将画布的原点移动到(200, 200)的位置:
```
const canvas = document.getElementById('mycanvas');
const ctx = canvas.getContext('2d');
ctx.translate(200, 200);
```
这样,之后在画布上绘制的图形将以(200, 200)为原点进行定位。\[3\]
#### 引用[.reference_title]
- *1* *3* [canvas学习17之如何改变canvas的原点](https://blog.csdn.net/zhangxiaochunxy/article/details/105087871)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Canvas鼠标滚轮缩放以及画布拖动(图文并茂版)](https://blog.csdn.net/astonishqft/article/details/128985061)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文