## Problem with x,y scaling

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
ElmuKelmuZ
Prole
Posts: 14
Joined: Sat Sep 01, 2012 7:43 pm

### Problem with x,y scaling

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:
Attachments
Source.love

raidho36
Party member
Posts: 1951
Joined: Mon Jun 17, 2013 12:00 pm

### 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.

0x72
Citizen
Posts: 51
Joined: Thu Jun 18, 2015 9:02 am

### 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

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: 212
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?

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

### Re: Problem with x,y scaling

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

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

ElmuKelmuZ
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

Tjakka5
Party member
Posts: 240
Joined: Thu Dec 26, 2013 12:17 pm

### 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.
Check out my portfolio: http://tjakka5.sorunome.de/

Positive07
Party member
Posts: 1005
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]()
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

### Who is online

Users browsing this forum: No registered users and 8 guests