Hi to the devs of this API. I ask you to consider returning back the quad:flip(x,y) function. It seems the idea was right and usuable correctly but then in 0.9.0 version removed from API.
Can this be returned back? From the quick look at the source file of quad.cpp i see that only 2 variables are needed to be added and then the u/v coords of texture are recalculated without changing the two triangles or 4 points.
Maybe someone hated the solution and they recommended the -scaleX or -scaleY option in love.graphics.draw. Which i consider not bad but more ugly than using quad:flip(x,y). This way the drawing becomes less overcalculated by adding offsets when flipping by hand through -scale while having the origin point not in the center of the sprite.
PS:I recommend also adding the quad:clone method. It would help in some cases to have it at hand ready.
QUAD flip horizontal and vertical
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: QUAD flip horizontal and vertical
You can add that function yourself, right, if you don't like simple negation? Lua allows for table overrides etc.
I mean, I don't know the reasons, nor had used that function. Maybe @slime will chip in.
I mean, I don't know the reasons, nor had used that function. Maybe @slime will chip in.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: QUAD flip horizontal and vertical
Not that easy, but doable.
Code: Select all
debug.getregistry().Quad.flip = function (self, x, y)
local vpx, vpy, vpw, vph = self:getViewport()
local vpsx, vpsy = self:getTextureDimensions()
if x then
vpx = -vpx - vpw
vpsx = -vpsx
end
if y then
vpy = -vpy - vph
vpsy = -vpsy
end
self:setViewport(vpx, vpy, vpw, vph, vpsx, vpsy)
end
Re: QUAD flip horizontal and vertical
Now that's some sorcery right there, patching an API class with a new function.
Re: QUAD flip horizontal and vertical
Generally I'm strongly against adding new functions to existing classes or tables, as that hinders readability (it's what many people do when they write a math.round() function or other similar ones, thinking it's clever to extend the existing math library), but in this case it's more like reviving a function that was once there, and if someone needs to look it up, the docs are available.
Re: QUAD flip horizontal and vertical
Now that is something i can only wonder about. Nice! I like it as a solution. Thanks! It works.pgimeno wrote: ↑Fri Jul 26, 2024 2:26 pm Not that easy, but doable.
Code: Select all
debug.getregistry().Quad.flip = function (self, x, y) local vpx, vpy, vpw, vph = self:getViewport() local vpsx, vpsy = self:getTextureDimensions() if x then vpx = -vpx - vpw vpsx = -vpsx end if y then vpy = -vpy - vph vpsy = -vpsy end self:setViewport(vpx, vpy, vpw, vph, vpsx, vpsy) end
Re: QUAD flip horizontal and vertical
Sure, but if backward compatibility is required, this will work. I.e. you could create a polyfill using your technique to run older games, where functions have been phased out by newer LOVE versions.pgimeno wrote: ↑Fri Jul 26, 2024 3:34 pm Generally I'm strongly against adding new functions to existing classes or tables, as that hinders readability (it's what many people do when they write a math.round() function or other similar ones, thinking it's clever to extend the existing math library), but in this case it's more like reviving a function that was once there, and if someone needs to look it up, the docs are available.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 2 guests