Problem with x,y scaling

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ElmuKelmuZ
Prole
Posts: 14
Joined: Sat Sep 01, 2012 7:43 pm

Problem with x,y scaling

Post by ElmuKelmuZ »

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:
Image
UDim2 inner workings:
Image
Image

So I use these to draw an image on screen, however nothing gets drawn when I do this:
Image
The size and position I set to it are as follows:
Image
I print out image:getDimensions() and all the stuff I pass onto love.graphics.draw and get this:
Image
Attachments
Source.love
(9.72 MiB) Downloaded 203 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Problem with x,y scaling

Post by raidho36 »

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.
User avatar
0x72
Citizen
Posts: 55
Joined: Thu Jun 18, 2015 9:02 am

Re: Problem with x,y scaling

Post by 0x72 »

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

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)
White sounds like a better default, but of course you can just set it manually in ImageLabel.new

Code: Select all

    img.Color = col or Color3.new(255, 255, 255)
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: Problem with x,y scaling

Post by KayleMaster »

Side question, what's your IDE/text editor or whatever they call it?
ElmuKelmuZ
Prole
Posts: 14
Joined: Sat Sep 01, 2012 7:43 pm

Re: Problem with x,y scaling

Post by ElmuKelmuZ »

KayleMaster wrote:Side question, what's your IDE/text editor or whatever they call it?
Visual Studio 2013, using the BabeLua "plugin"
ElmuKelmuZ
Prole
Posts: 14
Joined: Sat Sep 01, 2012 7:43 pm

Re: Problem with x,y scaling

Post by ElmuKelmuZ »

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

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)
White sounds like a better default, but of course you can just set it manually in ImageLabel.new

Code: Select all

    img.Color = col or Color3.new(255, 255, 255)
Ah, stupid mistake by me again :/

Thanks :P
ElmuKelmuZ
Prole
Posts: 14
Joined: Sat Sep 01, 2012 7:43 pm

Re: Problem with x,y scaling

Post by ElmuKelmuZ »

Also now that this is settled and my next question doesn't deserve it's own new thread,

Image

How do I tweak my equations so a size of UDim2.new(1, 0, 1, 0) stretches the image to the screens bounds
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: Problem with x,y scaling

Post by Tjakka5 »

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.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Problem with x,y scaling

Post by Positive07 »

sx = [wiki]love.graphics.getWidth[/wiki]()/[wiki](Image):getWidth[/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)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 5 guests