pub enum Color {
Show 39 variants Custom(Arc<RwLock<Id<Object>>>), SystemBlack, SystemWhite, SystemBrown, SystemBlue, SystemGreen, SystemIndigo, SystemOrange, SystemPink, SystemPurple, SystemRed, SystemTeal, SystemYellow, SystemGray, SystemGray2, SystemGray3, SystemGray4, SystemGray5, SystemGray6, Clear, Label, LabelSecondary, LabelTertiary, LabelQuaternary, SystemFill, SystemFillSecondary, SystemFillTertiary, SystemFillQuaternary, PlaceholderText, SystemBackground, SystemBackgroundSecondary, SystemBackgroundTertiary, Separator, OpaqueSeparator, Link, DarkText, LightText, MacOSWindowBackgroundColor, MacOSUnderPageBackgroundColor,
}
Expand description

Represents a Color. You can create custom colors using the various initializers, or opt to use a system-provided color. The system provided colors will automatically switch to the “correct” colors/shades depending on whether the user is in light or dark mode; to support this with custom colors, you can create a dynamic color with a custom handler that determines a color depending on a variety of system settings.

This enum is thread-safe, so clone away as needed.

Variants

Custom(Arc<RwLock<Id<Object>>>)

Represents an NSColor on macOS, and a UIColor everywhere else. You typically don’t create this variant yourself; use the initializers found on this enum.

If you need to do custom work not covered by this enum, you can drop to the Objective-C level yourself and wrap your color in this.

SystemBlack

The system-provided black. Harsh - you probably don’t want to use this.

SystemWhite

The system-provided absolute white.

SystemBrown

The system-provided brown.

SystemBlue

The system-provided blue. This value automatically switches to the correct variant depending on light or dark mode.

SystemGreen

The system-provided green. This value automatically switches to the correct variant depending on light or dark mode.

SystemIndigo

The system-provided indigo. This value automatically switches to the correct variant depending on light or dark mode.

SystemOrange

The system-provided orange. This value automatically switches to the correct variant depending on light or dark mode.

SystemPink

The system-provided pink. This value automatically switches to the correct variant depending on light or dark mode.

SystemPurple

The system-provided purple. This value automatically switches to the correct variant depending on light or dark mode.

SystemRed

The system-provided red. This value automatically switches to the correct variant depending on light or dark mode.

SystemTeal

The system-provided teal. This value automatically switches to the correct variant depending on light or dark mode.

SystemYellow

The system-provided yellow. This value automatically switches to the correct variant depending on light or dark mode.

SystemGray

The system-provided base gray color. This value automatically switches to the correct variant depending on light or dark mode.

SystemGray2

The system-provided secondary-level gray color. This value automatically switches to the correct variant depending on light or dark mode.

SystemGray3

The system-provided third-level gray color. This value automatically switches to the correct variant depending on light or dark mode.

SystemGray4

The system-provided fourth-level gray color. This value automatically switches to the correct variant depending on light or dark mode.

SystemGray5

The system-provided fifth-level gray color. This value automatically switches to the correct variant depending on light or dark mode.

SystemGray6

The system-provided sixth-level gray color. This value automatically switches to the correct variant depending on light or dark mode.

Clear

Represents a clear color. This value automatically switches to the correct variant depending on light or dark mode.

Label

The default label color. This value automatically switches to the correct variant depending on light or dark mode.

LabelSecondary

The default color for a second-level label. This value automatically switches to the correct variant depending on light or dark mode.

LabelTertiary

The default color for a third-level label. This value automatically switches to the correct variant depending on light or dark mode.

LabelQuaternary

The default color for a fourth-level label. This value automatically switches to the correct variant depending on light or dark mode.

SystemFill

The default system fill color. This value automatically switches to the correct variant depending on light or dark mode.

SystemFillSecondary

The default system second-level fill color. This value automatically switches to the correct variant depending on light or dark mode.

SystemFillTertiary

The default system third-level fill color. This value automatically switches to the correct variant depending on light or dark mode.

SystemFillQuaternary

The default system fourth-level fill color. This value automatically switches to the correct variant depending on light or dark mode.

PlaceholderText

The default color to use for placeholder text. This value automatically switches to the correct variant depending on light or dark mode.

SystemBackground

The default system background color. This value automatically switches to the correct variant depending on light or dark mode.

SystemBackgroundSecondary

The default system second-level background color. This value automatically switches to the correct variant depending on light or dark mode.

SystemBackgroundTertiary

The default system third-level background color. This value automatically switches to the correct variant depending on light or dark mode.

Separator

The default color to use for thin separators/lines that still allow content to be visible underneath. This value automatically switches to the correct variant depending on light or dark mode.

OpaqueSeparator

The default color to use for thin separators/lines that do not allow content underneath to be visible. This value automatically switches to the correct variant depending on light or dark mode.

The default color to use for rendering links. This value automatically switches to the correct variant depending on light or dark mode.

DarkText

The un-adaptable color for text on a light background.

LightText

The un-adaptable color for text on a dark background.

MacOSWindowBackgroundColor

The background color for a given window in the system theme.

MacOSUnderPageBackgroundColor

The background color that should appear under a page per the system theme.

Implementations

Creates and returns a color in the RGB space, with the specified alpha level.

Creates and returns a color in the RGB space, with the alpha level set to 255 by default. Shorthand for rgba.

Creates and returns a color in the HSB space, with the specified alpha level.

Creates and returns a color in the RGB space, with the alpha level set to 255 by default. Shorthand for hsba.

Creates and returns a white color with the specified level or intensity, along with the specified alpha.

Creates and returns a white Color with the specified level or intensity, with the alpha value set to 255. Shorthand for white_alpha.

Given a hex code and alpha level, returns a Color in the RGB space.

This method is not an ideal one to use, but is offered as a convenience method for those coming from other environments where these are more common.

Given a hex code, returns a Color in the RGB space with alpha pre-set to 255.

This method is not an ideal one to use, but is offered as a convenience method for those coming from other environments where these are more common.

Creates and returns a dynamic color, which stores a handler and enables returning specific colors at appearance time based on device traits (i.e, dark mode vs light mode, contrast settings, etc).

For systems that don’t support dark mode (macOS pre-Mojave) this will always paint with the “default” or “light” color.

Returning a dynamic color in your handler is unsupported and may panic.

Returns a CGColor, which can be used in Core Graphics calls as well as other areas.

Note that CGColor is not a context-aware color, unlike our NSColor and UIColor objects. If you’re painting in a context that requires dark mode support, make sure you’re not using a cached version of this unless you explicitly want the same color in every context it’s used in.

Trait Implementations

Provided to make passing Color types around less of a headache.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Consumes and returns the pointer to the underlying Color.

Consumes and returns the pointer to the underlying Color.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.