matcolor

package
v0.3.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package matcolor provides support for creating Material Design 3 color schemes and palettes.

Index

Constants

This section is empty.

Variables

View Source
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

func NewAccentDark(tones Tones) Accent

NewAccentDark returns a new dark theme Accent from the given Tones.

func NewAccentLight

func NewAccentLight(tones Tones) Accent

NewAccentLight returns a new light 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

func KeyFromPrimary

func KeyFromPrimary(primary color.RGBA) *Key

Key returns a new Key from the given primary accent key color.

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

func NewPalette(key *Key) *Palette

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

func NewDarkScheme(p *Palette) Scheme

NewDarkScheme returns a new dark-themed Scheme based on the given Palette.

func NewLightScheme

func NewLightScheme(p *Palette) Scheme

NewLightScheme returns a new light-themed Scheme based on the given Palette.

type Schemes

type Schemes struct {
	Light Scheme
	Dark  Scheme
}

Schemes contains multiple color schemes (light, dark, and any custom ones).

func NewSchemes

func NewSchemes(p *Palette) *Schemes

NewSchemes returns new Schemes for the given Palette containing both light and dark schemes.

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 NewTones

func NewTones(c color.RGBA) Tones

NewTones returns a new set of Tones for the given color.

func (*Tones) AbsTone

func (t *Tones) AbsTone(tone int) color.RGBA

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

func (t *Tones) AbsToneUniform(tone int) *image.Uniform

AbsToneUniform returns image.Uniform of Tones.AbsTone.

func (*Tones) Tone

func (t *Tones) Tone(tone int) color.RGBA

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

func (t *Tones) ToneUniform(tone int) *image.Uniform

ToneUniform returns image.Uniform of Tones.Tone.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL