love.graphics.translate

love.graphics.translate

Translates the coordinate system in two dimensions.

When this function is called with two numbers, dx, and dy, all the following drawing operations take effect as if their x and y coordinates were x+dx and y+dy.

Scale and translate are not commutative operations, therefore, calling them in different orders will change the outcome.

This change lasts until love.draw() exits or else a love.graphics.pop reverts to a previous love.graphics.push.

Translating using whole numbers will prevent tearing/blurring of images and fonts draw after translating.

Function

Synopsis

love.graphics.translate( dx, dy )

Arguments

number dx
The translation relative to the x-axis.
number dy
The translation relative to the y-axis.

Returns

Nothing.

Examples

Translate down and to the right by 10 pixels. Remember, the translation is reset at the end of each love.draw.

function love.draw()
   love.graphics.translate(10, 10)
   love.graphics.print("Text", 5, 5)   -- will effectively render at 15x15
end

See Also


© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.translate

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部