Documentation
¶
Overview ¶
Package matcolor provides support for creating Material Design 3 color schemes and palettes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SchemeIsDark = false
SchemeIsDark is whether the currently active color scheme is a dark-themed or light-themed color scheme. In almost all cases, it should be set via cogentcore.org/core/colors.SetScheme, not directly.
Functions ¶
This section is empty.
Types ¶
type Accent ¶
type Accent struct {
// Base is the base color for typically high-emphasis content.
Base image.Image
// On is the color applied to content on top of [Accent.Base].
On image.Image
// Container is the color applied to elements with less emphasis than [Accent.Base].
Container image.Image
// OnContainer is the color applied to content on top of [Accent.Container].
OnContainer image.Image
}
Accent contains the four standard variations of a base accent color.
func NewAccentDark ¶
NewAccentDark returns a new dark theme Accent from the given Tones.
type Key ¶
type Key struct {
// the primary accent key color
Primary color.RGBA
// the secondary accent key color
Secondary color.RGBA
// the tertiary accent key color
Tertiary color.RGBA
// the select accent key color
Select color.RGBA
// the error accent key color
Error color.RGBA
// the success accent key color
Success color.RGBA
// the warn accent key color
Warn color.RGBA
// the neutral key color used to generate surface and surface container colors
Neutral color.RGBA
// the neutral variant key color used to generate surface variant and outline colors
NeutralVariant color.RGBA
// an optional map of custom accent key colors
Custom map[string]color.RGBA
}
Key contains the set of key colors used to generate a Scheme and Palette
type Palette ¶
type Palette struct {
// the tones for the primary key color
Primary Tones
// the tones for the secondary key color
Secondary Tones
// the tones for the tertiary key color
Tertiary Tones
// the tones for the select key color
Select Tones
// the tones for the error key color
Error Tones
// the tones for the success key color
Success Tones
// the tones for the warn key color
Warn Tones
// the tones for the neutral key color
Neutral Tones
// the tones for the neutral variant key color
NeutralVariant Tones
// an optional map of tones for custom accent key colors
Custom map[string]Tones
}
Palette contains a tonal palette with tonal values for each of the standard colors and any custom colors. Use NewPalette to create a new palette.
func NewPalette ¶
NewPalette creates a new Palette from the given key colors.
type Scheme ¶
type Scheme struct {
// Primary is the primary color applied to important elements
Primary Accent
// Secondary is the secondary color applied to less important elements
Secondary Accent
// Tertiary is the tertiary color applied as an accent to highlight elements and create contrast between other colors
Tertiary Accent
// Select is the selection color applied to selected or highlighted elements and text
Select Accent
// Error is the error color applied to elements that indicate an error or danger
Error Accent
// Success is the color applied to elements that indicate success
Success Accent
// Warn is the color applied to elements that indicate a warning
Warn Accent
// an optional map of custom accent colors
Custom map[string]Accent
// SurfaceDim is the color applied to elements that will always have the dimmest surface color (see Surface for more information)
SurfaceDim image.Image
// Surface is the color applied to contained areas, like the background of an app
Surface image.Image
// SurfaceBright is the color applied to elements that will always have the brightest surface color (see Surface for more information)
SurfaceBright image.Image
// SurfaceContainerLowest is the color applied to surface container elements that have the lowest emphasis (see SurfaceContainer for more information)
SurfaceContainerLowest image.Image
// SurfaceContainerLow is the color applied to surface container elements that have lower emphasis (see SurfaceContainer for more information)
SurfaceContainerLow image.Image
// SurfaceContainer is the color applied to container elements that contrast elements with the surface color
SurfaceContainer image.Image
// SurfaceContainerHigh is the color applied to surface container elements that have higher emphasis (see SurfaceContainer for more information)
SurfaceContainerHigh image.Image
// SurfaceContainerHighest is the color applied to surface container elements that have the highest emphasis (see SurfaceContainer for more information)
SurfaceContainerHighest image.Image
// SurfaceVariant is the color applied to contained areas that contrast standard Surface elements
SurfaceVariant image.Image
// OnSurface is the color applied to content on top of Surface elements
OnSurface image.Image
// OnSurfaceVariant is the color applied to content on top of SurfaceVariant elements
OnSurfaceVariant image.Image
// InverseSurface is the color applied to elements to make them the reverse color of the surrounding elements and create a contrasting effect
InverseSurface image.Image
// InverseOnSurface is the color applied to content on top of InverseSurface
InverseOnSurface image.Image
// InversePrimary is the color applied to interactive elements on top of InverseSurface
InversePrimary image.Image
// Outline is the color applied to borders to create emphasized boundaries that need to have sufficient contrast
Outline image.Image
// OutlineVariant is the color applied to create decorative boundaries
OutlineVariant image.Image
// Shadow is the color applied to shadows
Shadow image.Image
// SurfaceTint is the color applied to tint surfaces
SurfaceTint image.Image
// Scrim is the color applied to scrims (semi-transparent overlays)
Scrim image.Image
}
Scheme contains the colors for one color scheme (ex: light or dark). To generate a scheme, use [NewScheme].
func NewDarkScheme ¶
NewDarkScheme returns a new dark-themed Scheme based on the given Palette.
type Tones ¶
type Tones struct {
// the key color used to generate these tones
Key color.RGBA
// the cached map of tonal color values
Tones map[int]color.RGBA
}
Tones contains cached color values for each tone of a seed color. To get a tonal value, use Tones.Tone.
func (*Tones) AbsTone ¶
AbsTone returns the color at the given absolute tone on a scale of 0 to 100. It uses the cached value if it exists, and it caches the value if it is not already.
func (*Tones) AbsToneUniform ¶ added in v0.2.1
AbsToneUniform returns image.Uniform of Tones.AbsTone.
func (*Tones) Tone ¶
Tone returns the color at the given tone, relative to the "0" tone for the current color scheme (0 for light-themed schemes and 100 for dark-themed schemes).
func (*Tones) ToneUniform ¶ added in v0.3.8
ToneUniform returns image.Uniform of Tones.Tone.