So, I have 4 pseudo-classes that I use here.
Vector2 which is essentially just an X and Y value.
UDim2 which has an X,Y scale as well as X,Y offset
Color3 which has r,g,b values
ImageLabel which has properties as such:
UDim2 inner workings:
So I use these to draw an image on screen, however nothing gets drawn when I do this:
The size and position I set to it are as follows:
I print out image:getDimensions() and all the stuff I pass onto love.graphics.draw and get this:
Problem with x,y scaling
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 14
- Joined: Sat Sep 01, 2012 7:43 pm
Problem with x,y scaling
- Attachments
-
- Source.love
- (9.72 MiB) Downloaded 203 times
Re: Problem with x,y scaling
What's the color value? It might have zero alpha. Also that's awful lot of calculations for something as simple as storing a coordinate.
Re: Problem with x,y scaling
Your default Color3 is black (i.e. "multiply every color by 0 so it's all black whatever texture is used").
I've changed Color3.new so it defaults to white (lines 12-14) and it works great
White sounds like a better default, but of course you can just set it manually in ImageLabel.new
I've changed Color3.new so it defaults to white (lines 12-14) and it works great
Code: Select all
col3.r = Clamp(r or 255, 0, 255)
col3.g = Clamp(g or 255, 0, 255)
col3.b = Clamp(b or 255, 0, 255)
Code: Select all
img.Color = col or Color3.new(255, 255, 255)
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Problem with x,y scaling
Side question, what's your IDE/text editor or whatever they call it?
-
- Prole
- Posts: 14
- Joined: Sat Sep 01, 2012 7:43 pm
Re: Problem with x,y scaling
Visual Studio 2013, using the BabeLua "plugin"KayleMaster wrote:Side question, what's your IDE/text editor or whatever they call it?
-
- Prole
- Posts: 14
- Joined: Sat Sep 01, 2012 7:43 pm
Re: Problem with x,y scaling
Ah, stupid mistake by me again :/0x72 wrote:Your default Color3 is black (i.e. "multiply every color by 0 so it's all black whatever texture is used").
I've changed Color3.new so it defaults to white (lines 12-14) and it works great
White sounds like a better default, but of course you can just set it manually in ImageLabel.newCode: Select all
col3.r = Clamp(r or 255, 0, 255) col3.g = Clamp(g or 255, 0, 255) col3.b = Clamp(b or 255, 0, 255)
Code: Select all
img.Color = col or Color3.new(255, 255, 255)
Thanks
-
- Prole
- Posts: 14
- Joined: Sat Sep 01, 2012 7:43 pm
Re: Problem with x,y scaling
Also now that this is settled and my next question doesn't deserve it's own new thread,
How do I tweak my equations so a size of UDim2.new(1, 0, 1, 0) stretches the image to the screens bounds
How do I tweak my equations so a size of UDim2.new(1, 0, 1, 0) stretches the image to the screens bounds
Re: Problem with x,y scaling
The target scale can be calculated by doing targetSize / imageSize.
If your screen resolution is static it's pretty straight forward.
If not you should use the love.resize() callback to recalculate all the target scales.
If your screen resolution is static it's pretty straight forward.
If not you should use the love.resize() callback to recalculate all the target scales.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Problem with x,y scaling
sx = [wiki]love.graphics.getWidth[/wiki]()/[wiki](Image):getWidth[/wiki]()
sy = [wiki]love.graphics.getHeight[/wiki]()/[wiki](Image):getHeight[/wiki]()
sy = [wiki]love.graphics.getHeight[/wiki]()/[wiki](Image):getHeight[/wiki]()
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 5 guests