actionscript 3 - Problem retrieving pixel color on color picker -


i'm making color picker (pretty standard one, pretty same photoshop less options @ moment: still in stage). here's picture of actual thing : http://i.stack.imgur.com/oevjw.jpg

the problem : retrieve color of pixel under color selector (the small one, other mouse), have line thought :

_currentcolor = convert.hsbtohex(new hsb(0,   ((_colorselector.x + _colorselector.width/2)*100)/_largeur,   ((_colorselector.y + _colorselector.height/2)*100)/_hauteur )); 

just clarify code, use coordinates of selector in order create new hsb color (saturation represented on x axis , brightness (value) on y axis of such color picker). convert hsb color hexadecimal , assign property. hue set 0 @ moment irrelevant work pure red test.

it partially wanted, returned color values inversed of corners: (0,0) it's supposed return 0xffffff, returns 0x000000 instead (256, 0) it's supposed return 0xff0000, returns 0x000000 instead (0, 256) it's supposed return 0x000000, returns 0xffffff instead (256, 256) it's supposed return 0x000000, returns 0xff0000 instead

i tried many variations in code, can't seem fix properly. reply/suggestions more welcomed!

i think error (or 1 of them) using values in range 0..256 seems lead overflows, try use 0..255 instead.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -