Color

Struct Color 

Source
pub struct Color { /* private fields */ }
Expand description

Defines colors used by FLTK. Colors are stored as RGBI values, the last being the index for FLTK colors in this enum. Colors in this enum don’t have an RGB stored. However, custom colors have an RGB, and don’t have an index. The RGBI can be acquired by casting the color to u32 and formatting it to 0x{08x}. The last 2 digits are the hexadecimal representation of the color in this enum. For example, Color::White, has a hex of 0x000000ff, ff being the 255 value of this enum. A custom color like Color::from_u32(0x646464), will have an representation as 0x64646400, of which the final 00 indicates that it is not stored in this enum. For convenience, the fmt::Display trait is implemented so that the name of the Color is shown when there is one, otherwise the RGB value is given.

Implementations§

Source§

impl Color

Source

pub const ForeGround: Color

ForeGround, label colors

Source

pub const Foreground: Color

Foreground, label colors

Source

pub const BackGround2: Color

BackGround2, Is the color inside input, output and text display widgets

Source

pub const Background2: Color

Background2, Is the color inside input, output and text display widgets

Source

pub const Inactive: Color

Inactive

Source

pub const Selection: Color

Selection

Source

pub const Free: Color

Free

Source

pub const Gray0: Color

Gray0

Source

pub const GrayRamp: Color

GrayRamp

Source

pub const Dark3: Color

Dark3

Source

pub const Dark2: Color

Dark2

Source

pub const Dark1: Color

Dark1

Source

pub const FrameDefault: Color

FrameDefault

Source

pub const BackGround: Color

BackGround

Source

pub const Background: Color

Background

Source

pub const Light1: Color

Light1

Source

pub const Light2: Color

Light2

Source

pub const Light3: Color

Light3

Source

pub const Black: Color

Black

Source

pub const Red: Color

Red

Source

pub const Green: Color

Green

Source

pub const Yellow: Color

Yellow

Source

pub const Blue: Color

Blue

Source

pub const Magenta: Color

Magenta

Source

pub const Cyan: Color

Cyan

Source

pub const DarkRed: Color

DarkRed

Source

pub const DarkGreen: Color

DarkGreen

Source

pub const DarkYellow: Color

DarkYellow

Source

pub const DarkBlue: Color

DarkBlue

Source

pub const DarkMagenta: Color

DarkMagenta

Source

pub const DarkCyan: Color

DarkCyan

Source

pub const White: Color

White

Source

pub const XtermBlack: Color

ANSI/xterm Black, not part of FLTK’s colormap

Source

pub const XtermRed: Color

ANSI/xterm Red, not part of FLTK’s colormap

Source

pub const XtermGreen: Color

ANSI/xterm Green, not part of FLTK’s colormap

Source

pub const XtermYellow: Color

ANSI/xterm Yellow, not part of FLTK’s colormap

Source

pub const XtermBlue: Color

ANSI/xterm Blue, not part of FLTK’s colormap

Source

pub const XtermMagenta: Color

ANSI/xterm Magenta, not part of FLTK’s colormap

Source

pub const XtermCyan: Color

ANSI/xterm Cyan, not part of FLTK’s colormap

Source

pub const XtermWhite: Color

ANSI/xterm White, not part of FLTK’s colormap

Source

pub const XtermBgRed: Color

ANSI/xterm background Red, not part of FLTK’s colormap

Source

pub const XtermBgGreen: Color

ANSI/xterm background Green, not part of FLTK’s colormap

Source

pub const XtermBgYellow: Color

ANSI/xterm background Yelllow, not part of FLTK’s colormap

Source

pub const XtermBgBlue: Color

ANSI/xterm background Blue, not part of FLTK’s colormap

Source

pub const XtermBgMagenta: Color

ANSI/xterm background Magenta, not part of FLTK’s colormap

Source

pub const XtermBgCyan: Color

ANSI/xterm background Cyan, not part of FLTK’s colormap

Source

pub const XtermBgWhite: Color

ANSI/xterm background White, not part of FLTK’s colormap

Source

pub const TransparentBg: Color

Special background color value that lets the Terminal widget’s box() color show through behind the text. Not part of FLTK’s colormap

Source

pub const fn bits(&self) -> u32

Gets the inner color representation

Source

pub const fn from_rgb(r: u8, g: u8, b: u8) -> Color

Returns a color from RGB

Source

pub const fn from_rgbi(rgbi: u32) -> Color

Returns a color enum from RGBI encoding

Source

pub fn from_rgba_tuple(tup: (u8, u8, u8, u8)) -> Color

Create color from RGBA using alpha compositing. Works for non-group types.

Source

pub const fn from_u32(val: u32) -> Color

Returns a color from hex or decimal

Source

pub const fn from_hex(val: u32) -> Color

Returns a color from hex or decimal

Source

pub fn from_hex_str(col: &str) -> Result<Color, FltkError>

Return a Color from a hex color format (#xxxxxx)

Source

pub fn to_hex_str(&self) -> String

Returns the color in hex string format

Source

pub fn by_index(idx: u8) -> Color

Returns a color by index of RGBI

Source

pub fn inactive(&self) -> Color

Returns an inactive form of the color

Source

pub fn darker(&self) -> Color

Returns an darker form of the color

Source

pub fn lighter(&self) -> Color

Returns an lighter form of the color

Source

pub fn gray_ramp(val: i32) -> Color

Returns a gray color value from black (i == 0) to white (i == FL_NUM_GRAY - 1)

Source

pub fn color_average(c1: Color, c2: Color, weight: f32) -> Color

Returns a gray color value from black (i == 0) to white (i == FL_NUM_GRAY - 1)

Source

pub fn contrast(fg: Color, bg: Color) -> Color

Returns a color that contrasts with the background color.

Source

pub fn gray_scale(g: u8) -> Color

Returns the color closest to the passed grayscale value

Source

pub fn rgb_color(r: u8, g: u8, b: u8) -> Color

Returns the color closest to the passed rgb value

Source

pub fn to_rgb(&self) -> (u8, u8, u8)

Get the RGB value of the color

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for Color

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Color

Source§

fn cmp(&self, other: &Color) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Color) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Color

Source§

fn partial_cmp(&self, other: &Color) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Color

Source§

impl Eq for Color

Source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more