Xojo Conferences
XDCMay2019MiamiUSA

color from Hex string (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Storing Application Settings
Next thread: Re: ServerSocket


Re: RB Company.   -   Rubber Chicken Software Co.
  color from Hex string   -   Louis G5 Batayte
   Re: color from Hex string   -   Eric dLR
   Re: color from Hex string   -   Eric dLR
   Re: color from Hex string   -   Norman Palardy
   Re: color from Hex string   -   Jann Gobble
   Re: color from Hex string   -   Louis G5 Batayte
   Re: color from Hex string   -   Norman Palardy
   Re: color from Hex string   -   Jann Gobble
   Re: color from Hex string   -   Eric dLR
   Re: color from Hex string   -   Norman Palardy

color from Hex string
Date: 04.08.09 18:23 (Tue, 4 Aug 2009 13:23:13 -0400)
From: Louis G5 Batayte
I can't find the answer to this in the LR, it may be there though.
I have a string with 6 letters for Hex digits, e.g. FF0ACB.
What is the easiest/best way to make a Color from this string
i.e.
Dim c as Color
DIm ss as string = "FF0ACB"

c = ????? ( a function of ss )

thanks,
Lou

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 05.08.09 17:51 (Wed, 5 Aug 2009 17:51:04 +0100)
From: Eric dLR

Le 4 août 09 à 19:39, Jann Gobble a écrit :

> I don't have a posting form any Eric on this subject.. :(

It may have end in your junk mail!! ;-)
Hope this one won't have the same fate...

For those who need it, I also have a few methods to handle CSS colors.

There is one that convert a string like 'orange' to something like
&cFFA500.
It supports the 16 CSS standard color names and the so called cross-
browser color Names.

There is another one that parses a CSS color definition like these:

body { background-color:yellow;}
h1 { background-color:#00ff00;}
p { background-color:rgb(255,0,255);}
h2 { background-color:rgb(%20,%50,%67);}

You just have to extract the color definition between the ':' and the
';' of the paramater and send this string to the method. It will
return the color as a variant. It does this because if the color can't
be parsed, then it returns nil.

There are a few other helpful ( at least they are for me ) methods. If
you found it useful, let me know. If you don't... you can let me know
too. :)

Just check it here:
<http:www.edlr.fr/realbasic/framework/ColorLib.rbo.zip>

Eric.


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 05.08.09 17:56 (Wed, 5 Aug 2009 17:56:42 +0100)
From: Eric dLR

Le 5 août 09 à 17:51, Eric dLR a écrit :

> Just check it here:
> <http:www.edlr.fr/realbasic/framework/ColorLib.rbo.zip>

<http://www.edlr.fr/realbasic/framework/ColorLib.rbo.zip>

Way better.

Eric.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 20:13 (Tue, 4 Aug 2009 13:13:44 -0600)
From: Norman Palardy

On 4-Aug-09, at 12:39 PM, Jann Gobble wrote:

> I don't have a posting form any Eric on this subject.. :(
>
Eric dLR ?
He replied about the same time I did with

Function ColorFromString(inString As String) As Color

Dim v As Variant = "&c" + Instring
Return v.ColorValue

End Function

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 19:39 (Tue, 4 Aug 2009 11:39:39 -0700)
From: Jann Gobble
I don't have a posting form any Eric on this subject.. :(

On Aug 4, 2009, at 11:05 AM, Norman Palardy wrote:

>
> On 4-Aug-09, at 11:52 AM, Jann Gobble wrote:
>
>> That is elegant!
>>
>> Did not think of doing it that way!
>>
>> Good job, Norman! (for what it is worth!) I have had this issue in
>> the past and just hand-converted it to RGB, then used the RGB
>> function.
>
> That's only one way
> There are others like Eric's which is a tad shorter and more direct
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 19:07 (Tue, 4 Aug 2009 14:07:24 -0400)
From: Louis G5 Batayte
Thank you, both Eric and Norman
Clearly I need to become more familiar with the Data Type Variant

Stick one thing in, get something else out

Thanks,
Lou

On Aug 4, 2009, at 1:41 PM, Eric dLR wrote:

>
> Le 4 août 09 à 18:23, Louis G5 Batayte a écrit :
>
>> I can't find the answer to this in the LR, it may be there though.
>> I have a string with 6 letters for Hex digits, e.g. FF0ACB.
>> What is the easiest/best way to make a Color from this string
>
> Function ColorFromString(inString As String) As Color
>
> Dim v As Variant = "&c" + Instring
> Return v.ColorValue
>
> End Function
>
> Eric.
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 19:05 (Tue, 4 Aug 2009 12:05:39 -0600)
From: Norman Palardy

On 4-Aug-09, at 11:52 AM, Jann Gobble wrote:

> That is elegant!
>
> Did not think of doing it that way!
>
> Good job, Norman! (for what it is worth!) I have had this issue in
> the past and just hand-converted it to RGB, then used the RGB
> function.

That's only one way
There are others like Eric's which is a tad shorter and more direct

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 18:52 (Tue, 4 Aug 2009 10:52:28 -0700)
From: Jann Gobble
That is elegant!

Did not think of doing it that way!

Good job, Norman! (for what it is worth!) I have had this issue in
the past and just hand-converted it to RGB, then used the RGB function.

:)

J

On Aug 4, 2009, at 10:36 AM, Norman Palardy wrote:

>
> On 4-Aug-09, at 11:23 AM, Louis G5 Batayte wrote:
>
>> I can't find the answer to this in the LR, it may be there though.
>> I have a string with 6 letters for Hex digits, e.g. FF0ACB.
>> What is the easiest/best way to make a Color from this string
>> i.e.
>> Dim c as Color
>> DIm ss as string = "FF0ACB"
>>
>> c = ????? ( a function of ss )
>
> Dim c as Color
> DIm ss as string = "FF0ACB"
> dim v as variant = val("&h" + ss)
> c = v.ColorValue
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 18:41 (Tue, 4 Aug 2009 18:41:57 +0100)
From: Eric dLR

Le 4 août 09 à 18:23, Louis G5 Batayte a écrit :

> I can't find the answer to this in the LR, it may be there though.
> I have a string with 6 letters for Hex digits, e.g. FF0ACB.
> What is the easiest/best way to make a Color from this string

Function ColorFromString(inString As String) As Color

Dim v As Variant = "&c" + Instring
Return v.ColorValue

End Function

Eric.



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: color from Hex string
Date: 04.08.09 18:36 (Tue, 4 Aug 2009 11:36:18 -0600)
From: Norman Palardy

On 4-Aug-09, at 11:23 AM, Louis G5 Batayte wrote:

> I can't find the answer to this in the LR, it may be there though.
> I have a string with 6 letters for Hex digits, e.g. FF0ACB.
> What is the easiest/best way to make a Color from this string
> i.e.
> Dim c as Color
> DIm ss as string = "FF0ACB"
>
> c = ????? ( a function of ss )

Dim c as Color
DIm ss as string = "FF0ACB"
dim v as variant = val("&h" + ss)
c = v.ColorValue

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>