Sign in to follow this  
Followers 0
CodyBarrett

Color Matrix

3 posts in this topic

is there a function to get a color matrix?

like in _ChooseColor () but i want to make a realtime ColorToHEX converter and ahve THAT color from the matrix converted to HEX in a loop form... i cant find any thing on the forums about it... and No WINAPI functions... any help you guys?

Share this post


Link to post
Share on other sites



is there a function to get a color matrix?

like in _ChooseColor () but i want to make a realtime ColorToHEX converter and ahve THAT color from the matrix converted to HEX in a loop form... i cant find any thing on the forums about it... and No WINAPI functions... any help you guys?

Here is an example answering one interpretation of what your post is about.

;
#include <Array.au3>

; A colour matrix - an array filled with colours in decimal format.
Local $aColMat[5][5] = [[0xff0000, 0x00FF00, 0x0000FF, 0x123456, Random(0, 0xFFFFFF, 1)], _
        [Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1)], _
        [Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1)], _
        [Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1)], _
        [Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1), Random(0, 0xFFFFFF, 1)]]

_ArrayDisplay($aColMat, "random colours Dec. format")

_ArrayToHex($aColMat, 1)

_ArrayDisplay($aColMat, "Colours converted to Hex. format")

; $iReturnType similar to $iReturnType parameter in _ChooseColor fuction.
Func _ArrayToHex(ByRef $aArr, $iReturnType)
    For $x = 0 To UBound($aColMat) - 1
        For $y = 0 To UBound($aColMat, 2) - 1
            Select
                Case $iReturnType = 1 ; Reverse colour channel order as orig. array with hex format.
                    $aArr[$x][$y] = "0x" & StringRegExpReplace(Hex($aArr[$x][$y], 6), "(.{2})(.{2})(.{2})", "\3\2\1")
                Case $iReturnType = 2 ; Same colour channel order as orig. array with hex format.
                    $aArr[$x][$y] = "0x" & Hex($aArr[$x][$y], 6)
            EndSelect
        Next
    Next
    Return 1
EndFunc   ;==>_ArrayToHex
;

Share this post


Link to post
Share on other sites

wow.. thanks..thats interesting..

but i was kinda thinking of that Image, of all the colors on the right hand side of _ChooseColor... is there a way to get that? cause then Pixel get color would work to get what one is chosen... but i need that image.. i can make everything else but i was wondering how to get that image onto a GUI

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0