Sanko Robinson > FLTK-0.532009 > FLTK::Color

Download:
FLTK-0.532009.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.532006   Source  

NAME ^

FLTK::Color - A color value (Wow, yeah, I know...)

Description ^

FLTK::Color is a typedef for a 32-bit integer containing r,g,b bytes and an "index" in the lowest byte (the first byte on a little-endian machine such as an x86). For instance 0xFF008000 is 255 red, zero green, and 128 blue. If rgb are not zero then the low byte is ignored, or may be treated as "alpha" by some code.

If the rgb is zero, the N is the color "index". This index is used to look up an FLTK::Color in an internal table of 255 colors shown here. All the indexed colors may be changed by using set_color_index(). However FLTK uses the ones between 32 and 255 and assummes they are not changed from their default values.

A Color of zero (FLTK::NO_COLOR) will draw black but is ambiguous. It is returned as an error value or to indicate portions of a Style that should be inherited, and it is also used as the default label color for everything so that changing color zero can be used by the -fg switch. You should use FLTK::BLACK (56) to get black.

Functions ^

BLACK

BLACK( );

Corner of color cube

Import this function with the :color tag.

BLUE

BLUE( );

Corner of color cube

Import this function with the :color tag.

CYAN

CYAN( );

Corner of color cube

Import this function with the :color tag.

DARK_BLUE

DARK_BLUE( );

Import this function with the :color tag.

DARK_CYAN

DARK_CYAN( );

Import this function with the :color tag.

DARK_GREEN

DARK_GREEN( );

Import this function with the :color tag.

DARK_MAGENTA

DARK_MAGENTA( );

Import this function with the :color tag.

DARK_RED

DARK_RED( );

Import this function with the :color tag.

DARK_YELLOW

DARK_YELLOW( );

Import this function with the :color tag.

FREE_COLOR

FREE_COLOR( );

Starting from index 16 is the FREE_COLOR area

Import this function with the :color tag.

GRAY00

GRAY00( );

hex=00, dec=.00, framebox=A, fltk1 = GRAY0, GRAY_RAMP

Import this function with the :color tag.

GRAY05

GRAY05( );

hex=0d, dec=.05, framebox=B

Import this function with the :color tag.

GRAY10

GRAY10( );

hex=1a, dec=.10, framebox=C

Import this function with the :color tag.

GRAY15

GRAY15( );

hex=27, dec=.15, framebox=D

Import this function with the :color tag.

GRAY20

GRAY20( );

hex=34, dec=.20, framebox=E

Import this function with the :color tag.

GRAY25

GRAY25( );

hex=41, dec=.25, framebox=F

Import this function with the :color tag.

GRAY30

GRAY30( );

hex=4f, dec=.31, framebox=G

Import this function with the :color tag.

GRAY33

GRAY33( );

hex=5c, dec=.36, framebox=H, fltk1 = DARK3

Import this function with the :color tag.

GRAY35

GRAY35( );

hex=69, dec=.41, framebox=I

Import this function with the :color tag.

GRAY40

GRAY40( );

hex=76, dec=.46, framebox=J (18%% gray card)

Import this function with the :color tag.

GRAY45

GRAY45( );

hex=83, dec=.51, framebox=K

Import this function with the :color tag.

GRAY50

GRAY50( );

hex=90, dec=.56, framebox=L

Import this function with the :color tag.

GRAY55

GRAY55( );

hex=9e, dec=.62, framebox=M

Import this function with the :color tag.

GRAY60

GRAY60( );

hex=ab, dec=.67, framebox=N, fltk1 = DARK2

Import this function with the :color tag.

GRAY65

GRAY65( );

hex=b8, dec=.72, framebox=O

Import this function with the :color tag.

GRAY66

GRAY66( );

hex=c5, dec=.77, framebox=P, fltk1 = DARK1, INACTIVE_COLOR

Import this function with the :color tag.

GRAY70

GRAY70( );

hex=d2, dec=.82, framebox=Q

Import this function with the :color tag.

GRAY75

GRAY75( );

hex=e0, dec=.88, framebox=R, fltk1 = GRAY, SELECTION_COLOR

Import this function with the :color tag.

GRAY80

GRAY80( );

hex=e5, dec=.90, framebox=S

Import this function with the :color tag.

GRAY85

GRAY85( );

hex=ea, dec=.92, framebox=T, fltk1 = LIGHT1

Import this function with the :color tag.

GRAY90

GRAY90( );

hex=f4, dec=.96, framebox=V, fltk1 = LIGHT2

Import this function with the :color tag.

GRAY95

GRAY95( );

hex=f9, dec=.98, framebox=W

Import this function with the :color tag.

GRAY99

GRAY99( );

hex=ff, dec=1.0, framebox=X, fltk1 = LIGHT3

Import this function with the :color tag.

GREEN

GREEN( );

Corner of color cube

Import this function with the :color tag.

MAGENTA

MAGENTA( );

Corner of color cube

Import this function with the :color tag.

NO_COLOR

NO_COLOR( );

Black, empty place holder in Style

Import this function with the :color tag.

NUM_FREE_COLOR

NUM_FREE_COLOR( );

Number of free color slots starting from index FREE_COLOR

Import this function with the :color tag.

RED

RED( );

Corner of color cube

Import this function with the :color tag.

WHITE

WHITE( );

Corner of color cube

Import this function with the :color tag.

WINDOWS_BLUE

WINDOWS_BLUE( );

Default selection_color

Import this function with the :color tag.

YELLOW

YELLOW( );

Corner of color cube

Import this function with the :color tag.

color

my $c = $color->color( $name );

Turn a string into a color. If name is undef, this returns NO_COLOR. Otherwise it returns FLTK::parsecolor(name, strlen(name)).

Import this function with the :color tag.

my $c = $color->color( $r, $g, $b );

Import this function with the :color tag.

contrast

my $color = $color->contrast( $fg, $bg );

Returns fg if fltk decides it can be seen well when drawn against a bg. Otherwise it returns either FLTK::BLACK or fltk::WHITE.

Import this function with the :color tag.

get_color_index

$color->get_color_index( $color );

Return the rgb form of color. If it is an indexed color that entry is returned. If it is an rgb color it is returned unchanged.

Import this function with the :color tag.

inactive

my $color = $color->inactive( $fore, $back );

Same as lerp(fg, bg, .5), it grays out the color.

Import this function with the :color tag.

my $color = $color->inactive( $fore );

Same as lerp(fg, getbgcolor(), .5). This is for back-compatability only?

Import this function with the :color tag.

lerp

my $color = $color->lerp( $color1, $color2, $weight );

Return (1-weight)*color1 + weight*color2. weight is clamped to the 0-1 range before use.

Import this function with the :color tag.

nearest_index

my $color = $color->nearest_index( $color );

Find an indexed color in the range 56-127 that is closest to this color. If this is an indexed color it is returned unchanged.

Import this function with the :color tag.

parsecolor

my $color = $color->parsecolor( $name, $length );

Same as the other one.

Import this function with the :color tag.

my $color = $color->parsecolor( $name );

Turn the first n bytes of name into an FLTK color. This allows you to parse a color out of the middle of a string.

Recognized values are:

  • "" turns into NO_COLOR
  • "0"-"99" decimal fltk color number, only works for indexed color range
  • "0xnnn" hex value of any fltk color number
  • "rgb" or "#rgb" three hex digits for rgb
  • "rrggbb" or "#rrggbb" 2 hex digits for each of rgb
  • "rrggbbaa" or "#rrggbbaa" fltk color number in hex
  • "rrrgggbbb" or "#rrrgggbbb" 3 hex digits for each of rgb
  • "rrrrggggbbbb" or "#rrrrggggbbbb" 4 hex digits for each of rgb
  • 17 "web safe colors" as defined by CSS 2.1
  • If FLTK is compiled to use X11, then XParseColor() is tried
  • all other strings return NO_COLOR.

Import this function with the :color tag.

set_background

$color->set_background( $color );

FLTK::GRAY75 is replaced with the passed color, and all the other FLTK::GRAY* colors are replaced with a color ramp (or sometimes a straight line) so that using them for highlighted edges of raised buttons looks correct.

Import this function with the :color tag.

set_color_index

$color->set_color_index( $index, $color );

Set one of the indexed colors to the given rgb color. index must be in the range 0-255, and color must be a non-indexed rgb color.

Import this function with the :color tag.

split_color

my @rgb = $color->split_color( $color );

Set r,g,b to the 8-bit components of this color. If it is an indexed color they are looked up in the table, otherwise they are simply copied out of the color number.

Import this function with the :color tag.

Functions ^

Symbolic names for some of the indexed colors.

The 24-entry "gray ramp" is modified by FLTK::set_background() so that the color FLTK::GRAY75 is the background color, and the others are a nice range from black to a lighter version of the gray. These are used to draw box edges. The gray levels are chosen to be evenly spaced, listed here is the actual 8-bit and decimal gray level assigned by default. Also listed here is the letter used for FLTK::FrameBox and the old fltk1.1 names used for these levels.

The remiander of the colormap is a 5x8x5 color cube. This cube is used to dither images on 8-bit screens X colormaps to reduce the number of colors used.

Author ^

Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/

License and Legal ^

Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

syntax highlighting: