Thread Tools Display Modes
02-07-22, 11:57 PM   #1
Firesong
A Deviate Faerie Dragon
Join Date: Jan 2022
Posts: 19
Question 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.
  Reply With Quote
02-08-22, 12:09 AM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
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
  Reply With Quote
02-08-22, 01:01 AM   #3
Firesong
A Deviate Faerie Dragon
Join Date: Jan 2022
Posts: 19
Smile

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.
  Reply With Quote
02-08-22, 09:58 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
02-08-22, 10:29 AM   #5
Yukyuk
A Chromatic Dragonspawn
 
Yukyuk's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 179
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)
__________________
Better to fail then never have tried at all.
  Reply With Quote
02-08-22, 12:02 PM   #6
Firesong
A Deviate Faerie Dragon
Join Date: Jan 2022
Posts: 19
Unhappy

Originally Posted by Fizzlemizz View Post
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.
  Reply With Quote
02-08-22, 12:21 PM   #7
Yukyuk
A Chromatic Dragonspawn
 
Yukyuk's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 179
Originally Posted by Firesong View Post
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.
__________________
Better to fail then never have tried at all.
  Reply With Quote
02-08-22, 01:21 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Originally Posted by Firesong View Post
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)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-17-22 at 08:08 AM.
  Reply With Quote
02-10-22, 02:34 AM   #9
Firesong
A Deviate Faerie Dragon
Join Date: Jan 2022
Posts: 19
Red face

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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Puzzled By SetColorTexture

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off