English 中文(简体)
Set canvas origin to the low-left toper
原标题:Set canvas origin to the lower-left corner

是否有办法将原产地推向更低的 can? 我尝试把所有东西都缩小到一层。 我需要做像协调制度那样的事情,但只需要积极的一面(第一点)。 因此,我需要从0.0开始。

问题回答
ctx.translate(0, canvas.height);
ctx.scale(1, -1);

http://jsfiddle.net/w6rx3/。 See a demo on JSFiddle.

is there a way to set the origin to lower-left of the canvas?

你们不喜欢,不喜欢。 你能做的最好事就是说的。

据说很难发挥一种功能,在一种系统之间转换。 例如:

// Given an X,Y in 1st quadrant cartesian coordinates give the corresponding screen coordinate
function cartToScreen(px, py) {
  return [px, -py + HEIGHT];
};

兹写:

var coords = cartToScreen(50,50);
// draws 50 pixels from the bottoom instead of 50 pixels from the top
ctx.fillText("lalala", coords[0], coords[1]);

rel=“nofollow”>Example

无论如何,我强烈建议,如果你完全能够用来筛选坐标。 如果你不总是要说明这种微小的差别,那么今后将避免头痛的负荷。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签