1. wxEuphoria - color_selector()



atom red,green,blue,skin
  red = 255
  green = 200
  blue = 100
  skin = create(wxColour,{red,green,blue})


Later I change skin with color_selector().
That works but there seems to be no way to save the color to a file.

Saving skin to file does not produce a consistent result.
That is, set_back_color(Win, skin) works,
but when skin is saved to a file, and then the program is stopped and restarted
and it reads skin,
set_back_color(Win, skin) doesn't work.
Unless there is a bug in the way I'm doing it.

Also there seems to be no way to derive red,green,blue from skin. That would be
ideal. Then the ini file could be edited.

How can a color from color_selector() be saved to a file?

new topic     » topic index » view message » categorize

2. Re: wxEuphoria - color_selector()

Jerry Story wrote:
> 
> }}}
<eucode>
> atom red,green,blue,skin
>   red = 255
>   green = 200
>   blue = 100
>   skin = create(wxColour,{red,green,blue})
> </eucode>
{{{

> 
> Later I change skin with color_selector().
> That works but there seems to be no way to save the color to a file.
> 
> Saving skin to file does not produce a consistent result.
> That is, set_back_color(Win, skin) works,
> but when skin is saved to a file, and then the program is stopped and
> restarted
> and it reads skin,
> set_back_color(Win, skin) doesn't work.
> Unless there is a bug in the way I'm doing it.
> 
> Also there seems to be no way to derive red,green,blue from skin. That would
> be ideal. Then the ini file could be edited.
> 
> How can a color from color_selector() be saved to a file?

I don't use wxEuphoria but I do use XColors in Xmotor,
I think you'll find that skin is a pointer the structure
that contains your color.
So when the program ends that pointer is no longer valid.
You will probably have to save the three color values in an ini file.

Then when your program starts do a  
   skin = create(wxColour,{red,green,blue})

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

3. Re: wxEuphoria - color_selector()

Bernie Ryan wrote:
> You will probably have to save the three color values in an ini file.
> 
> Then when your program starts do a  
>    skin = create(wxColour,{red,green,blue})

The question boils down to:
how to get the 3 colors from color_selector()?

new topic     » goto parent     » topic index » view message » categorize

4. Re: wxEuphoria - color_selector()

Jerry Story wrote:
> 
> Bernie Ryan wrote:
> > You will probably have to save the three color values in an ini file.
> > 
> > Then when your program starts do a  
> >    skin = create(wxColour,{red,green,blue})
> 
> The question boils down to:
> how to get the 3 colors from color_selector()?

Instead of trying to get the value from the color selector, why not try 
grabbing the values of the colors since they're easier to work with?

Something like printf might work for what you're trying to do.

printf ( FILE, "%d,%d,%d", {Red,Green,Blue})

Hope that helps.

new topic     » goto parent     » topic index » view message » categorize

5. Re: wxEuphoria - color_selector()

Jesse Adkins wrote:
> 
> Jerry Story wrote:
> > 
> > Bernie Ryan wrote:
> > > You will probably have to save the three color values in an ini file.
> > > 
> > > Then when your program starts do a  
> > >    skin = create(wxColour,{red,green,blue})
> > 
> > The question boils down to:
> > how to get the 3 colors from color_selector()?
> 
> Instead of trying to get the value from the color selector, why not try 
> grabbing the values of the colors since they're easier to work with?
> 
> Something like printf might work for what you're trying to do.
> 
> printf ( FILE, "%d,%d,%d", {Red,Green,Blue})
> 
> Hope that helps.

How do I get red,green,blue?
I know how to do everything else.

new topic     » goto parent     » topic index » view message » categorize

6. Re: wxEuphoria - color_selector()

Jerry Story wrote:
> 
> Jesse Adkins wrote:
> > 
> > Jerry Story wrote:
> > > 
> > > Bernie Ryan wrote:
> > > > You will probably have to save the three color values in an ini file.
> > > > 
> > > > Then when your program starts do a  
> > > >    skin = create(wxColour,{red,green,blue})
> > > 
> > > The question boils down to:
> > > how to get the 3 colors from color_selector()?
> > 
> > Instead of trying to get the value from the color selector, why not try 
> > grabbing the values of the colors since they're easier to work with?
> > 
> > Something like printf might work for what you're trying to do.
> > 
> > printf ( FILE, "%d,%d,%d", {Red,Green,Blue})
> > 
> > Hope that helps.
> 
> How do I get red,green,blue?
> I know how to do everything else.

 From the win32lib library ...

-----------------------------------------------------------------------------
--/topic Graphics
--/func split_rgb( object pColor)
--/desc Convert a color into a {red, green, blue}.
--/ret Sequence: 3-element {RED, GREEN, BLUE}
-- Converts the color value into its component colors.
--
-- Example:
-- /code
--      -- get the colors got a pixel
--      RGB = split_rgb( getPixel(myBMP, 4,7) )
--      RGB = split_rgb( "BrightCyan" )
--      RGB = split_rgb( COLOR_BUTTONFACE )
--      RGB = split_rgb( Magenta )
-- /endcode
atom gColors gColors = allocate_mem(4)
global function split_rgb( object pColor )
    poke4(gColors, colorValue(pColor))
    return peek({gColors,3})
end function


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

7. Re: wxEuphoria - color_selector()

Jerry Story wrote:
> 
> }}}
<eucode>
> atom red,green,blue,skin
>   red = 255
>   green = 200
>   blue = 100
>   skin = create(wxColour,{red,green,blue})
> </eucode>
{{{

> 
> Later I change skin with color_selector().
> That works but there seems to be no way to save the color to a file.
> 
> Saving skin to file does not produce a consistent result.
> That is, set_back_color(Win, skin) works,
> but when skin is saved to a file, and then the program is stopped and
> restarted
> and it reads skin,
> set_back_color(Win, skin) doesn't work.
> Unless there is a bug in the way I'm doing it.
> 
> Also there seems to be no way to derive red,green,blue from skin. That would
> be ideal. Then the ini file could be edited.
> 
> How can a color from color_selector() be saved to a file?

You can use these functions to get the color components:

--/topic wxColour
--/func get_red( atom color )
--
--Returns the red intensity of a wxColour.
global function get_red( atom color )
	return and_bits(call_member( wxColour_Red, color, {} ), #FF)
end function

--/topic wxColour
--/func get_green( atom color )
--
--Returns the green intensity of a wxColour.
global function get_green( atom color )
	return and_bits(call_member( wxColour_Green, color, {} ), #FF)
end function

--/topic wxColour
--/func get_blue( atom color )
--
--Returns the blue intensity of a wxColour.
global function get_blue( atom color )
	return and_bits(call_member( wxColour_Blue, color, {} ), #FF)
end function


Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

8. Re: wxEuphoria - color_selector()

Matt Lewis wrote:
> You can use these functions to get the color components:
> 
> }}}
<eucode>
> --/topic wxColour
> --/func get_red( atom color )
> --
> --Returns the red intensity of a wxColour.
> global function get_red( atom color )
> 	return and_bits(call_member( wxColour_Red, color, {} ), #FF)
> end function
> 
> --/topic wxColour
> --/func get_green( atom color )
> --
> --Returns the green intensity of a wxColour.
> global function get_green( atom color )
> 	return and_bits(call_member( wxColour_Green, color, {} ), #FF)
> end function
> 
> --/topic wxColour
> --/func get_blue( atom color )
> --
> --Returns the blue intensity of a wxColour.
> global function get_blue( atom color )
> 	return and_bits(call_member( wxColour_Blue, color, {} ), #FF)
> end function
> </eucode>
{{{


Thanks. It works.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu