Difference between revisions of "Talk:love.graphics.translate"

(Created page with 'Camera shake ahoy!')
 
Line 1: Line 1:
 
Camera shake ahoy!
 
Camera shake ahoy!
 +
 +
--[[User:Meevere|Meevere]] ([[User talk:Meevere|talk]]) 20:47, 5 March 2023 (CET)
 +
Does this article provide misleading information, or am I stupid..
 +
 +
This article says that if I make `translate(dx,dy)` then when I call draw(x,y), I would effectively get draw(x+dx,y+dy)
 +
Then, if I would like to scale something around a point, I would use this piece of code:
 +
<source lang="lua">
 +
function scale_around(origin, scale)
 +
love.graphics.push()
 +
love.graphics.translate(-origin[1],-origin[2]) -- Because if I would call something at the origin I would like to stay it still
 +
love.graphics.scale(scale)
 +
love.graphics.translate(origin[1], origin[2])
 +
end
 +
</source>
 +
But it only works if I swap the signs for origin. Is that a bug or am I doing something wrong?

Revision as of 19:47, 5 March 2023

Camera shake ahoy!

--Meevere (talk) 20:47, 5 March 2023 (CET) Does this article provide misleading information, or am I stupid..

This article says that if I make `translate(dx,dy)` then when I call draw(x,y), I would effectively get draw(x+dx,y+dy) Then, if I would like to scale something around a point, I would use this piece of code:

function scale_around(origin, scale)
	love.graphics.push()
	love.graphics.translate(-origin[1],-origin[2]) -- Because if I would call something at the origin I would like to stay it still
	love.graphics.scale(scale)
	love.graphics.translate(origin[1], origin[2])
end

But it only works if I swap the signs for origin. Is that a bug or am I doing something wrong?