将画布原点设置到左下角 [英] Set canvas origin to the lower-left corner

查看:60
本文介绍了将画布原点设置到左下角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将原点设置在画布的左下角?我尝试按− 1进行缩放,但此后一切都颠倒了。我需要制作类似坐标系的东西,但只包含正部分(第一象限)。因此,我需要它从左下角的0.0开始。

Is there a way to set the origin to lower-left of the canvas? I tried scaling by −1 but after that everything is upside down. I need to make something like a coordinate system but only with the positive part (first quadrant). So I need it to start with 0.0 at down-left corner.

推荐答案

ctx.translate(0, canvas.height);
ctx.scale(1, -1);

请参阅JSFiddle上的演示。

See a demo on JSFiddle.

这篇关于将画布原点设置到左下角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆