1. An example of how to get palette colours returned.

Here you go, Vic. One Euphoria program that demonstrates how to get the RGB
values of a passed colour.

include \euphoria\include\graphics.e

function get_palette_colours(atom colour)

     object original_palette

     integer Red_, Green_, Blue_

     Red_ = 0
     Green_ = 0
     Blue_ = 0

     -- set colour received to all zeroes, causing the original RGB colours
to be stored in a
     -- object

     original_palette = palette(colour, {Red_, Green_, Blue_})

     -- extract colours into individual variables

     Red_ = original_palette[1]
     Green_ = original_palette[2]
     Blue_ = original_palette[3]

     -- reset colour received back to original value using palette saved
from previous palette()
     original_palette = palette(colour, original_palette)

     -- Tah-da! The colours are returned for the specified palette.
     return {Red_, Green_, Blue_}

end function

-- Example code

object returned_RGB

if graphics_mode(18) then
     puts(1, "Mode Set Failure")
     abort(1)
end if

returned_RGB = get_palette_colours(YELLOW)

if graphics_mode(-1) then
     puts(1, "Mode Set Failure")
     abort(2)
end if

print(1,returned_RGB)
puts(1,'\n')

new topic     » topic index » view message » categorize

2. Re: An example of how to get palette colours returned.

Hi David,
The code works! Thanks alot...
What I'm trying to so is write a bunch of fade scripts and the starfield
effect and other neat stuff and...the code was really needed.
Thanks again,
/ViC./
 ______________________________________________________________________
|     http://www.geocities.com/SiliconValley/Heights/8858/home.htm     |
|                     Veni vidi, vici. Fiat lux.                       |
|______________________________________________________________________|

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

3. Re: An example of how to get palette colours returned.

> Hi David,
> The code works! Thanks alot...
> What I'm trying to so is write a bunch of fade scripts and the starfield
> effect and other neat stuff and...the code was really needed.
> Thanks again,
> /ViC./

You're welcome. Glad I could help.

Is this for a game you are writing in Euphoria? :)

David Gay
http://www.interlog.com/~moggie/Euphoria
"A Beginner's Guide To Euphoria"

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

4. Re: An example of how to get palette colours returned.

>Is this for a game you are writing in Euphoria? :)
>
>David Gay
>http://www.interlog.com/~moggie/Euphoria
>"A Beginner's Guide To Euphoria"


I will try :)
/ViC./
 ______________________________________________________________________
|     http://www.geocities.com/SiliconValley/Heights/8858/home.htm     |
|                     Veni vidi, vici. Fiat lux.                       |
|______________________________________________________________________|

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

Search



Quick Links

User menu

Not signed in.

Misc Menu