matcolor

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: BSD-3-Clause Imports: 2 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
	Base color.RGBA

	// On is the color applied to content on top of
	On color.RGBA

	// Container is the color applied to elements with less emphasis than
	Container color.RGBA

	// OnContainer is the color applied to content on top of
	OnContainer color.RGBA
}

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 color.RGBA

	// Surface is the color applied to contained areas, like the background of an app
	Surface color.RGBA

	// SurfaceBright is the color applied to elements that will always have the brightest surface color (see Surface for more information)
	SurfaceBright color.RGBA

	// SurfaceContainerLowest is the color applied to surface container elements that have the lowest emphasis (see SurfaceContainer for more information)
	SurfaceContainerLowest color.RGBA

	// SurfaceContainerLow is the color applied to surface container elements that have lower emphasis (see SurfaceContainer for more information)
	SurfaceContainerLow color.RGBA

	// SurfaceContainer is the color applied to container elements that contrast elements with the surface color
	SurfaceContainer color.RGBA

	// SurfaceContainerHigh is the color applied to surface container elements that have higher emphasis (see SurfaceContainer for more information)
	SurfaceContainerHigh color.RGBA

	// SurfaceContainerHighest is the color applied to surface container elements that have the highest emphasis (see SurfaceContainer for more information)
	SurfaceContainerHighest color.RGBA

	// SurfaceVariant is the color applied to contained areas that contrast standard Surface elements
	SurfaceVariant color.RGBA

	// OnSurface is the color applied to content on top of Surface elements
	OnSurface color.RGBA

	// OnSurfaceVariant is the color applied to content on top of SurfaceVariant elements
	OnSurfaceVariant color.RGBA

	// InverseSurface is the color applied to elements to make them the reverse color of the surrounding elements and create a contrasting effect
	InverseSurface color.RGBA

	// InverseOnSurface is the color applied to content on top of InverseSurface
	InverseOnSurface color.RGBA

	// InversePrimary is the color applied to interactive elements on top of InverseSurface
	InversePrimary color.RGBA

	// Background is the color applied to the background of the app and other low-emphasis areas
	Background color.RGBA

	// OnBackground is the color applied to content on top of Background
	OnBackground color.RGBA

	// Outline is the color applied to borders to create emphasized boundaries that need to have sufficient contrast
	Outline color.RGBA

	// OutlineVariant is the color applied to create decorative boundaries
	OutlineVariant color.RGBA

	// Shadow is the color applied to shadows
	Shadow color.RGBA

	// SurfaceTint is the color applied to tint surfaces
	SurfaceTint color.RGBA

	// Scrim is the color applied to scrims (semi-transparent overlays)
	Scrim color.RGBA
}

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) 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).

Jump to

Keyboard shortcuts

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