Jump to content



Photo

_ColorConvertValue UDF


  • Please log in to reply
11 replies to this topic

#1 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,266 posts

Posted 20 June 2009 - 10:19 AM

Hi there,

This function was initialy created as a helper function in my other recent UDF (_GUICtrlCreateTFLabel), but after searching on the forum for such function and not finding anything like this (i was surprised actualy, i thought this kind of function could be posted long time ago), i think that i should post it here.

The colors table i got from here.
In the archive with _ColorConvertValue there is also a parser script that i used to generate the table for UDF usage.

Function Header:
; #FUNCTION# ======================================================================================== ; Name...........:  _ColorConvertValue ; Description....:  Converts string color value to hex and back. ; Syntax.........:  _ColorConvertValue($sColor, $iConvertMode=-1, $aColors_Table=0) ; Parameters.....:  $sColor       - Color name or color hex value, depending on $iConvertMode. ;                    $iConvertMode  - [Optional] If this parameter <> -1, then the function will convert hex color to string value ;                                       (default is -1 - convert from string to hex). ;                    $aDefColorsTable - [Optional] If this parameter will contain an array with colors table (default is 0), ;                                       then this colors table will be used to convert the color. ;                   ; Return values..:  Success - Returns converted color value. ;                    Failure - Returns original $sColor value (if the color can not be converted). ; Author.........:  G.Sandler (MrCreatoR) ; Modified.......:  21.06.2009 ; Remarks........:  ; Related........:  ; Link...........:  Colors table used in this function: http://ilan.belhost.by/screens/colorx.shtml ; Example........:  Yes. ; ===================================================================================================


For example:

Blue converted to 0x0000FF
Red converted to 0xFF0000

and back...

0x0000FF to Blue
0xFF0000 to Red

Attachments:
v1.1 Attached File  _ColorConvertValue.zip   2.9KB   262 downloads
v1.0 Attached File  _ColorConvertValue.zip   2.69KB   179 downloads

Edited by MrCreatoR, 20 June 2009 - 11:34 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1



AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler


Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *


==================================================
My_Userbar.gif
==================================================

 

AutoIt is simple, subtle, elegant. © AutoIt Team








#2 AlmarM

AlmarM

    Programming my way.

  • Active Members
  • PipPipPipPipPipPip
  • 1,698 posts

Posted 20 June 2009 - 04:26 PM

Oh, thats pretty sweet. It doens't support ALL colors. Dont think thats necessary though.
This could be very useful! :D

Minesweeper

A minesweeper game created in autoit, source available.

 

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

 

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.


#3 James

James

    Universalist

  • MVPs
  • 10,379 posts

Posted 20 June 2009 - 04:50 PM

As I saw the topic, I was wondering how this would be done. Pretty nifty!

#4 GreenCan

GreenCan

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 338 posts

Posted 20 June 2009 - 05:46 PM

Nicely done, and useful too.

Thanks for sharing

GreenCan

#5 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,647 posts

Posted 20 June 2009 - 05:46 PM

It's a good idea and well done, MrCreatoR, but it would be nice to be able to pass their own (arbitrary) color palette. Or make that something like _SetDefaultPalette(ByRef $aPalatte).

iKey [color=#FF8C00;]|[/color] FTP Uploader [color=#FF8C00;]|[/color] Battery Checker [color=#FF8C00;]|[/color] Boot Manager [color=#FF8C00;]|[/color] Font Viewer [color=#FF8C00;]|[/color] UDF Keyword Manager [color=#FF8C00;]|[/color] Run Dialog Replacement [color=#FF8C00;]|[/color] USBProtect [color=#FF8C00;]|[/color] 3D Axis [color=#FF8C00;]|[/color] Calculator [color=#FF8C00;]|[/color] Sleep [color=#FF8C00;]|[/color] iSwitcher [color=#FF8C00;]|[/color] TM [color=#FF8C00;]|[/color] NetHelper [color=#FF8C00;]|[/color] File Types Manager [color=#FF8C00;]|[/color] Control Viewer [color=#FF8C00;]|[/color] SynFolders [color=#FF8C00;]|[/color] DLL Helper

Animated Tray Icons UDF Library [color=#FF8C00;]|[/color] Hotkeys UDF Library [color=#FF8C00;]|[/color] Hotkeys Input Control UDF Library [color=#FF8C00;]|[/color] Caret Shape UDF Library [color=#FF8C00;]|[/color] Context Help UDF Library [color=#FF8C00;]|[/color] Most Recently Used List UDF Library [color=#FF8C00;]|[/color] Icons UDF Library [color=#FF8C00;]|[/color] FTP UDF Library [color=#FF8C00;]|[/color] Script Communications UDF Library [color=#FF8C00;]|[/color] Color Chooser UDF Library [color=#FF8C00;]|[/color] Color Picker Control UDF Library [color=#FF8C00;]|[/color] IPHelper (Vista/7) UDF Library [color=#FF8C00;]|[/color] WinAPI Extended UDF Library [color=#FF8C00;]|[/color] WinAPIVhd UDF Library [color=#FF8C00;]|[/color] Icon Chooser UDF Library [color=#FF8C00;]|[/color] Copy UDF Library [color=#FF8C00;]|[/color] Restart UDF Library [color=#FF8C00;]|[/color] Event Log UDF Library [color=#FF8C00;]|[/color] NotifyBox UDF Library [color=#FF8C00;]|[/color] Pop-up Windows UDF Library [color=#FF8C00;]|[/color] TVExplorer UDF Library [color=#FF8C00;]|[/color] GuiHotKey UDF Library [color=#FF8C00;]|[/color] GuiSysLink UDF Library [color=#FF8C00;]|[/color] Package UDF Library [color=#FF8C00;]|[/color] Skin UDF Library [color=#FF8C00;]|[/color] AITray UDF Library [color=#FF8C00;]|[/color] RDC UDF Library

Appropriate path [color=#FF8C00;]|[/color] Button text color [color=#FF8C00;]|[/color] Gaussian random numbers [color=#FF8C00;]|[/color] Header's styles (Vista/7) [color=#FF8C00;]|[/color] ICON resource enumeration [color=#FF8C00;]|[/color] Menu & INI [color=#FF8C00;]|[/color] Tabbed string size [color=#FF8C00;]|[/color] Tab's skin [color=#FF8C00;]|[/color] Pop-up circular menu [color=#FF8C00;]|[/color] Progress Bar without animation (Vista/7) [color=#FF8C00;]|[/color] Registry export [color=#FF8C00;]|[/color] Registry path jumping [color=#FF8C00;]|[/color] Unique hardware ID [color=#FF8C00;]|[/color] Windows alignment

More...

Posted Image


#6 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,266 posts

Posted 20 June 2009 - 06:52 PM

Thanks to all for the feedbacks.

It's a good idea and well done, MrCreatoR, but it would be nice to be able to pass their own (arbitrary) color palette. Or make that something like _SetDefaultPalette(ByRef $aPalatte).


I am not sure that i follow you. What it should do exactly? (example could help).

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1



AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler


Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *


==================================================
My_Userbar.gif
==================================================

 

AutoIt is simple, subtle, elegant. © AutoIt Team


#7 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,647 posts

Posted 20 June 2009 - 07:39 PM

I am not sure that i follow you. What it should do exactly? (example could help).

Dim $aDefColorsTable[140][2] = [[0xFFFFFF, 'White'],[0xFFFFF0, 'Ivory'], ...] Func _SetColorsTable(ByRef $aColorsTable)     ; Checks for $aColorsTable array         ...     $aDefColorsTable = $aColorsTable     Return 1 EndFunc   ;==>_SetColorsTable


In this case _ColorConvertValue() should work with a $aDefColorsTable array.

iKey [color=#FF8C00;]|[/color] FTP Uploader [color=#FF8C00;]|[/color] Battery Checker [color=#FF8C00;]|[/color] Boot Manager [color=#FF8C00;]|[/color] Font Viewer [color=#FF8C00;]|[/color] UDF Keyword Manager [color=#FF8C00;]|[/color] Run Dialog Replacement [color=#FF8C00;]|[/color] USBProtect [color=#FF8C00;]|[/color] 3D Axis [color=#FF8C00;]|[/color] Calculator [color=#FF8C00;]|[/color] Sleep [color=#FF8C00;]|[/color] iSwitcher [color=#FF8C00;]|[/color] TM [color=#FF8C00;]|[/color] NetHelper [color=#FF8C00;]|[/color] File Types Manager [color=#FF8C00;]|[/color] Control Viewer [color=#FF8C00;]|[/color] SynFolders [color=#FF8C00;]|[/color] DLL Helper

Animated Tray Icons UDF Library [color=#FF8C00;]|[/color] Hotkeys UDF Library [color=#FF8C00;]|[/color] Hotkeys Input Control UDF Library [color=#FF8C00;]|[/color] Caret Shape UDF Library [color=#FF8C00;]|[/color] Context Help UDF Library [color=#FF8C00;]|[/color] Most Recently Used List UDF Library [color=#FF8C00;]|[/color] Icons UDF Library [color=#FF8C00;]|[/color] FTP UDF Library [color=#FF8C00;]|[/color] Script Communications UDF Library [color=#FF8C00;]|[/color] Color Chooser UDF Library [color=#FF8C00;]|[/color] Color Picker Control UDF Library [color=#FF8C00;]|[/color] IPHelper (Vista/7) UDF Library [color=#FF8C00;]|[/color] WinAPI Extended UDF Library [color=#FF8C00;]|[/color] WinAPIVhd UDF Library [color=#FF8C00;]|[/color] Icon Chooser UDF Library [color=#FF8C00;]|[/color] Copy UDF Library [color=#FF8C00;]|[/color] Restart UDF Library [color=#FF8C00;]|[/color] Event Log UDF Library [color=#FF8C00;]|[/color] NotifyBox UDF Library [color=#FF8C00;]|[/color] Pop-up Windows UDF Library [color=#FF8C00;]|[/color] TVExplorer UDF Library [color=#FF8C00;]|[/color] GuiHotKey UDF Library [color=#FF8C00;]|[/color] GuiSysLink UDF Library [color=#FF8C00;]|[/color] Package UDF Library [color=#FF8C00;]|[/color] Skin UDF Library [color=#FF8C00;]|[/color] AITray UDF Library [color=#FF8C00;]|[/color] RDC UDF Library

Appropriate path [color=#FF8C00;]|[/color] Button text color [color=#FF8C00;]|[/color] Gaussian random numbers [color=#FF8C00;]|[/color] Header's styles (Vista/7) [color=#FF8C00;]|[/color] ICON resource enumeration [color=#FF8C00;]|[/color] Menu & INI [color=#FF8C00;]|[/color] Tabbed string size [color=#FF8C00;]|[/color] Tab's skin [color=#FF8C00;]|[/color] Pop-up circular menu [color=#FF8C00;]|[/color] Progress Bar without animation (Vista/7) [color=#FF8C00;]|[/color] Registry export [color=#FF8C00;]|[/color] Registry path jumping [color=#FF8C00;]|[/color] Unique hardware ID [color=#FF8C00;]|[/color] Windows alignment

More...

Posted Image


#8 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,266 posts

Posted 20 June 2009 - 08:26 PM

; Checks for $aColorsTable array

What it should do inside the array? Switch the values?
Or you mean pass the array to use instead of the strings inside the UDF?

Edited by MrCreatoR, 20 June 2009 - 08:28 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1



AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler


Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *


==================================================
My_Userbar.gif
==================================================

 

AutoIt is simple, subtle, elegant. © AutoIt Team


#9 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,647 posts

Posted 20 June 2009 - 10:13 PM

Your _ColorConvertValue() function works with local variables $aStrColors_Table and $aHexColors_Table. I think that would be more useful when the user can assign its value for these variables. For example, with an additional function _SetColorsTable(). In my example I used an array for simplicity. I think it is more convenient when the names of colors and their values are stored in the array. That's all.

iKey [color=#FF8C00;]|[/color] FTP Uploader [color=#FF8C00;]|[/color] Battery Checker [color=#FF8C00;]|[/color] Boot Manager [color=#FF8C00;]|[/color] Font Viewer [color=#FF8C00;]|[/color] UDF Keyword Manager [color=#FF8C00;]|[/color] Run Dialog Replacement [color=#FF8C00;]|[/color] USBProtect [color=#FF8C00;]|[/color] 3D Axis [color=#FF8C00;]|[/color] Calculator [color=#FF8C00;]|[/color] Sleep [color=#FF8C00;]|[/color] iSwitcher [color=#FF8C00;]|[/color] TM [color=#FF8C00;]|[/color] NetHelper [color=#FF8C00;]|[/color] File Types Manager [color=#FF8C00;]|[/color] Control Viewer [color=#FF8C00;]|[/color] SynFolders [color=#FF8C00;]|[/color] DLL Helper

Animated Tray Icons UDF Library [color=#FF8C00;]|[/color] Hotkeys UDF Library [color=#FF8C00;]|[/color] Hotkeys Input Control UDF Library [color=#FF8C00;]|[/color] Caret Shape UDF Library [color=#FF8C00;]|[/color] Context Help UDF Library [color=#FF8C00;]|[/color] Most Recently Used List UDF Library [color=#FF8C00;]|[/color] Icons UDF Library [color=#FF8C00;]|[/color] FTP UDF Library [color=#FF8C00;]|[/color] Script Communications UDF Library [color=#FF8C00;]|[/color] Color Chooser UDF Library [color=#FF8C00;]|[/color] Color Picker Control UDF Library [color=#FF8C00;]|[/color] IPHelper (Vista/7) UDF Library [color=#FF8C00;]|[/color] WinAPI Extended UDF Library [color=#FF8C00;]|[/color] WinAPIVhd UDF Library [color=#FF8C00;]|[/color] Icon Chooser UDF Library [color=#FF8C00;]|[/color] Copy UDF Library [color=#FF8C00;]|[/color] Restart UDF Library [color=#FF8C00;]|[/color] Event Log UDF Library [color=#FF8C00;]|[/color] NotifyBox UDF Library [color=#FF8C00;]|[/color] Pop-up Windows UDF Library [color=#FF8C00;]|[/color] TVExplorer UDF Library [color=#FF8C00;]|[/color] GuiHotKey UDF Library [color=#FF8C00;]|[/color] GuiSysLink UDF Library [color=#FF8C00;]|[/color] Package UDF Library [color=#FF8C00;]|[/color] Skin UDF Library [color=#FF8C00;]|[/color] AITray UDF Library [color=#FF8C00;]|[/color] RDC UDF Library

Appropriate path [color=#FF8C00;]|[/color] Button text color [color=#FF8C00;]|[/color] Gaussian random numbers [color=#FF8C00;]|[/color] Header's styles (Vista/7) [color=#FF8C00;]|[/color] ICON resource enumeration [color=#FF8C00;]|[/color] Menu & INI [color=#FF8C00;]|[/color] Tabbed string size [color=#FF8C00;]|[/color] Tab's skin [color=#FF8C00;]|[/color] Pop-up circular menu [color=#FF8C00;]|[/color] Progress Bar without animation (Vista/7) [color=#FF8C00;]|[/color] Registry export [color=#FF8C00;]|[/color] Registry path jumping [color=#FF8C00;]|[/color] Unique hardware ID [color=#FF8C00;]|[/color] Windows alignment

More...

Posted Image


#10 Ashalshaikh

Ashalshaikh

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 20 June 2009 - 10:21 PM

Nice ..
Thank You ...

#11 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,266 posts

Posted 20 June 2009 - 11:30 PM

@Yashied
Ok, done.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1



AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler


Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *


==================================================
My_Userbar.gif
==================================================

 

AutoIt is simple, subtle, elegant. © AutoIt Team


#12 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,647 posts

Posted 21 June 2009 - 12:48 AM

Excellent.

iKey [color=#FF8C00;]|[/color] FTP Uploader [color=#FF8C00;]|[/color] Battery Checker [color=#FF8C00;]|[/color] Boot Manager [color=#FF8C00;]|[/color] Font Viewer [color=#FF8C00;]|[/color] UDF Keyword Manager [color=#FF8C00;]|[/color] Run Dialog Replacement [color=#FF8C00;]|[/color] USBProtect [color=#FF8C00;]|[/color] 3D Axis [color=#FF8C00;]|[/color] Calculator [color=#FF8C00;]|[/color] Sleep [color=#FF8C00;]|[/color] iSwitcher [color=#FF8C00;]|[/color] TM [color=#FF8C00;]|[/color] NetHelper [color=#FF8C00;]|[/color] File Types Manager [color=#FF8C00;]|[/color] Control Viewer [color=#FF8C00;]|[/color] SynFolders [color=#FF8C00;]|[/color] DLL Helper

Animated Tray Icons UDF Library [color=#FF8C00;]|[/color] Hotkeys UDF Library [color=#FF8C00;]|[/color] Hotkeys Input Control UDF Library [color=#FF8C00;]|[/color] Caret Shape UDF Library [color=#FF8C00;]|[/color] Context Help UDF Library [color=#FF8C00;]|[/color] Most Recently Used List UDF Library [color=#FF8C00;]|[/color] Icons UDF Library [color=#FF8C00;]|[/color] FTP UDF Library [color=#FF8C00;]|[/color] Script Communications UDF Library [color=#FF8C00;]|[/color] Color Chooser UDF Library [color=#FF8C00;]|[/color] Color Picker Control UDF Library [color=#FF8C00;]|[/color] IPHelper (Vista/7) UDF Library [color=#FF8C00;]|[/color] WinAPI Extended UDF Library [color=#FF8C00;]|[/color] WinAPIVhd UDF Library [color=#FF8C00;]|[/color] Icon Chooser UDF Library [color=#FF8C00;]|[/color] Copy UDF Library [color=#FF8C00;]|[/color] Restart UDF Library [color=#FF8C00;]|[/color] Event Log UDF Library [color=#FF8C00;]|[/color] NotifyBox UDF Library [color=#FF8C00;]|[/color] Pop-up Windows UDF Library [color=#FF8C00;]|[/color] TVExplorer UDF Library [color=#FF8C00;]|[/color] GuiHotKey UDF Library [color=#FF8C00;]|[/color] GuiSysLink UDF Library [color=#FF8C00;]|[/color] Package UDF Library [color=#FF8C00;]|[/color] Skin UDF Library [color=#FF8C00;]|[/color] AITray UDF Library [color=#FF8C00;]|[/color] RDC UDF Library

Appropriate path [color=#FF8C00;]|[/color] Button text color [color=#FF8C00;]|[/color] Gaussian random numbers [color=#FF8C00;]|[/color] Header's styles (Vista/7) [color=#FF8C00;]|[/color] ICON resource enumeration [color=#FF8C00;]|[/color] Menu & INI [color=#FF8C00;]|[/color] Tabbed string size [color=#FF8C00;]|[/color] Tab's skin [color=#FF8C00;]|[/color] Pop-up circular menu [color=#FF8C00;]|[/color] Progress Bar without animation (Vista/7) [color=#FF8C00;]|[/color] Registry export [color=#FF8C00;]|[/color] Registry path jumping [color=#FF8C00;]|[/color] Unique hardware ID [color=#FF8C00;]|[/color] Windows alignment

More...

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users