WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Puzzled By SetColorTexture (https://www.wowinterface.com/forums/showthread.php?t=59045)

Firesong 02-07-22 11:57 PM

Puzzled By SetColorTexture
 
This question is not crucial but I am puzzled and would be grateful for a pointer in the right direction.

MapFrame.texture:SetColorTexture(0, 0, 0) gives me black.

MapFrame.texture:SetColorTexture(255, 255, 255) gives me white.

MapFrame.texture:SetColorTexture(255, 0, 0) gives me red.

MapFrame.texture:SetColorTexture(0, 255, 0) gives me green.

But MapFrame.texture:SetColorTexture(12, 34, 56) gives me white as do a whole lot of other combinations.

I've confirmed the unexpected whites by screenshot, paste into Paint and using the color picker.

How can this be? Why are combnations like 12, 34, 56 giving me white?

Thanks in advance.

Ketho 02-08-22 12:09 AM

It's a normalized value, so use something like
Code:

MapFrame.texture:SetColorTexture(12/255, 34/255, 56/255)
https://wowpedia.fandom.com/wiki/API...etColorTexture

Firesong 02-08-22 01:01 AM

Thanks. I am trying that but it still gives unexpected results.

MapFrame.texture:SetColorTexture(12/255, 34/255, 56/255) gives me a RGB of 9/79/112 - is there something I'm missing if I want to have a RGB of 12,34,56.

Sorry for such a trivial question.

Fizzlemizz 02-08-22 09:58 AM

Grab a calculator and enter 12 divided by 255. I'd be surprised if you ended up with 9.

1 is to WoW what 255 is to Paint.

Yukyuk 02-08-22 10:29 AM

SetColorTexture uses values up to 1.
So if you want to have 12, 34 and 56 as a texture then use MapFrame.texture:SetColorTexture(0.05, 0.1, 0.2)

Firesong 02-08-22 12:02 PM

Quote:

Originally Posted by Fizzlemizz (Post 340305)
Grab a calculator and enter 12 divided by 255. I'd be surprised if you ended up with 9.

1 is to WoW what 255 is to Paint.

local r = 12/255;
local g = 34/255;
local b = 56/255;
MapFrame.texture:SetColorTexture(r, g, b)

In Paint, the resulting frame color is 7, 79, 112.

I wonder if I have a faulty graphics card or something. Yet the values that are entered as 255 and 0 work fine.

Thanks for trying.

Yukyuk 02-08-22 12:21 PM

Quote:

Originally Posted by Firesong (Post 340308)
I wonder if I have a faulty graphics card or something. Yet the values that are entered as 255 and 0 work fine.

Thanks for trying.

Nothing wrong with your graphic card.
My best guess is that values over 1 are defaulted to 1.
So MapFrame.texture:SetColorTexture(255, 0, 0) becomes MapFrame.texture:SetColorTexture(1, 0, 0) and gives you red.
So your MapFrame.texture:SetColorTexture(12, 34, 56) becomes MapFrame.texture:SetColorTexture(1, 1, 1) which actually is the correct code for white so it gives you white.

Fizzlemizz 02-08-22 01:21 PM

Quote:

Originally Posted by Firesong (Post 340308)
In Paint, the resulting frame color is 7, 79, 112.

I'm not sure where the 7, 79, 112 is coming from? Paint and WoW use different sets of numbers for the colour channels.

Colour wheels in WoW and Paint. The swatch colours seem pretty close not withstanding the different background colours.
Image (removed)

Firesong 02-10-22 02:34 AM

I'm puzzled at there those numbers come from as well but as I don't have a practical application, I'll leave it for now. Thanks again.


All times are GMT -6. The time now is 10:44 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI