Sorry about whining at the forums again, but I'm having troubles with love.graphics.scale() scaling a circle while keeping the circle in the center.
Here's my code:
if area == "ingame" then
love.graphics.push()
love.graphics.scale(scale)
love.graphics.setColor(51, 204, 102, 255)
love.graphics.setBlendMode("alpha")
love.graphics.setColorMode("modulate")
love.graphics.circle("fill", 640, 400, 500, 500)
end
love.graphics.pop()
love.graphics.draw(p, 0, 0)
It all works except I can't get the code right to keep the circle in the center while it centers. I know it's just a simple bit of mathematics, but I'm finding it really hard to figure out.
Thanks in advance.
J
Last edited by Archiboldian C. on Tue Mar 15, 2011 5:26 pm, edited 1 time in total.
local LG = love.graphics
local scaleAround = function(x, y, scale)
if scale and scale ~= 1 then
LG.translate(x, y)
LG.scale(scale)
LG.translate(-x, -y)
end
end
local rotateAround = function(x, y, angle)
if angle and angle ~= 0 then
LG.translate(x, y)
LG.rotate(angle)
LG.translate(-x, -y)
end
end
EmmanuelOga's scaleAround function worked perfectly thanks.
Plus using a variable to shorten the amount of typing needed is an excellent idea and something I used to do in AS3 but had completely forgotten about since converting to Linux and looking for alternatives for a creative programming platform.
Also thanks to vrld for telling me about my excessive angles, I should've tested some lower amounts but 500 worked so I got lazy.
Thanks.
This forum is great, never usually get a response which doesn't demand that you search google even though you have or that just treats you like a piece of crap from forums. I guess it's because LOVE is still in alpha (I assume from the current 0.7.1 version number) and there's a small community of early adopters and the ideology of the forum is to welcome new users and not scare the shit out of them.
Surely that's the point of open sourcing things? Sharing knowledge? Isn't that the point of a forum? Haha.
J
On a somewhat more serious note, we are just some lazy people who procrastinate too much, we try to be nice to each other, and for those who do not obey these rules we keep some pitchforks around.
Last edited by bartbes on Tue Mar 15, 2011 9:25 pm, edited 1 time in total.
Reason:Shouldn't start a new sentence halfway through my old one, grammar doesn't like it
bartbes wrote:Wait.. we're here for a game engine? :O
On a somewhat more serious note, we are a just some lazy people who procrastinate too much, we try to be nice to each other, and for those who do not obey these rules we keep some pitchforks around.
Hey are you stealing thoughts out of my head " we are a just some lazy people" hehe so far I loving this forum and mind the pun
Sir Kittenface Möko IDE Codename (Erös) Returns Soon
I am dyslexic so if any of my replys confusing please just ask me to reword it as this will make things a lot easier for all parties lol.