Documentation
¶
Index ¶
- Variables
- func ConstraintNames() []string
- func EnableLightForeground(tone float64) float64
- func FindDesiredChromaByTone(hue, chroma, tone float64, byDecreasingTone bool) float64
- func ForegroundTone(bgTone, ratio float64) float64
- func GetPiecewiseHue(sourceColorHct color.Hct, hueBreakpoints []float64, hues []float64) float64
- func GetRotatedHue(sourceColorHct color.Hct, hueBreakpoints []float64, rotations []float64) float64
- func IsFidelity(scheme *Scheme) bool
- func IsMonochrome(scheme *Scheme) bool
- func PlatformNames() []string
- func ToneAllowsLightForeground(tone float64) bool
- func TonePolarityNames() []string
- func TonePrefersLightForeground(tone float64) bool
- func VariantNames() []string
- func VersionNames() []string
- type ChromaMultiplier
- type Color
- type ColorCalculationDelegate
- type ColorFunc
- type Constraint
- type ContrastCurve
- type ContrastCurveFunc
- type MaterialColorSpec
- type MaterialSpec2021
- func (m MaterialSpec2021) Background() *Color
- func (m MaterialSpec2021) Error() *Color
- func (m MaterialSpec2021) ErrorContainer() *Color
- func (m MaterialSpec2021) ErrorDim() *Color
- func (m MaterialSpec2021) HighestSurface(s *Scheme) *Color
- func (m MaterialSpec2021) InverseOnSurface() *Color
- func (m MaterialSpec2021) InversePrimary() *Color
- func (m MaterialSpec2021) InverseSurface() *Color
- func (m MaterialSpec2021) NeutralPaletteKeyColor() *Color
- func (m MaterialSpec2021) NeutralVariantPaletteKeyColor() *Color
- func (m MaterialSpec2021) OnBackground() *Color
- func (m MaterialSpec2021) OnError() *Color
- func (m MaterialSpec2021) OnErrorContainer() *Color
- func (m MaterialSpec2021) OnPrimary() *Color
- func (m MaterialSpec2021) OnPrimaryContainer() *Color
- func (m MaterialSpec2021) OnPrimaryFixed() *Color
- func (m MaterialSpec2021) OnPrimaryFixedVariant() *Color
- func (m MaterialSpec2021) OnSecondary() *Color
- func (m MaterialSpec2021) OnSecondaryContainer() *Color
- func (m MaterialSpec2021) OnSecondaryFixed() *Color
- func (m MaterialSpec2021) OnSecondaryFixedVariant() *Color
- func (m MaterialSpec2021) OnSurface() *Color
- func (m MaterialSpec2021) OnSurfaceVariant() *Color
- func (m MaterialSpec2021) OnTertiary() *Color
- func (m MaterialSpec2021) OnTertiaryContainer() *Color
- func (m MaterialSpec2021) OnTertiaryFixed() *Color
- func (m MaterialSpec2021) OnTertiaryFixedVariant() *Color
- func (m MaterialSpec2021) Outline() *Color
- func (m MaterialSpec2021) OutlineVariant() *Color
- func (m MaterialSpec2021) Primary() *Color
- func (m MaterialSpec2021) PrimaryContainer() *Color
- func (m MaterialSpec2021) PrimaryDim() *Color
- func (m MaterialSpec2021) PrimaryFixed() *Color
- func (m MaterialSpec2021) PrimaryFixedDim() *Color
- func (m MaterialSpec2021) PrimaryPaletteKeyColor() *Color
- func (m MaterialSpec2021) Scrim() *Color
- func (m MaterialSpec2021) Secondary() *Color
- func (m MaterialSpec2021) SecondaryContainer() *Color
- func (m MaterialSpec2021) SecondaryDim() *Color
- func (m MaterialSpec2021) SecondaryFixed() *Color
- func (m MaterialSpec2021) SecondaryFixedDim() *Color
- func (m MaterialSpec2021) SecondaryPaletteKeyColor() *Color
- func (m MaterialSpec2021) Shadow() *Color
- func (m MaterialSpec2021) Surface() *Color
- func (m MaterialSpec2021) SurfaceBright() *Color
- func (m MaterialSpec2021) SurfaceContainer() *Color
- func (m MaterialSpec2021) SurfaceContainerHigh() *Color
- func (m MaterialSpec2021) SurfaceContainerHighest() *Color
- func (m MaterialSpec2021) SurfaceContainerLow() *Color
- func (m MaterialSpec2021) SurfaceContainerLowest() *Color
- func (m MaterialSpec2021) SurfaceDim() *Color
- func (m MaterialSpec2021) SurfaceTint() *Color
- func (m MaterialSpec2021) SurfaceVariant() *Color
- func (m MaterialSpec2021) Tertiary() *Color
- func (m MaterialSpec2021) TertiaryContainer() *Color
- func (m MaterialSpec2021) TertiaryDim() *Color
- func (m MaterialSpec2021) TertiaryFixed() *Color
- func (m MaterialSpec2021) TertiaryFixedDim() *Color
- func (m MaterialSpec2021) TertiaryPaletteKeyColor() *Color
- type MaterialSpec2025
- func (m MaterialSpec2025) Error() *Color
- func (m MaterialSpec2025) ErrorContainer() *Color
- func (m MaterialSpec2025) ErrorDim() *Color
- func (m MaterialSpec2025) InverseOnSurface() *Color
- func (m MaterialSpec2025) InversePrimary() *Color
- func (m MaterialSpec2025) InverseSurface() *Color
- func (m MaterialSpec2025) OnError() *Color
- func (m MaterialSpec2025) OnErrorContainer() *Color
- func (m MaterialSpec2025) OnPrimary() *Color
- func (m MaterialSpec2025) OnPrimaryContainer() *Color
- func (m MaterialSpec2025) OnPrimaryFixed() *Color
- func (m MaterialSpec2025) OnPrimaryFixedVariant() *Color
- func (m MaterialSpec2025) OnSecondary() *Color
- func (m MaterialSpec2025) OnSecondaryContainer() *Color
- func (m MaterialSpec2025) OnSecondaryFixed() *Color
- func (m MaterialSpec2025) OnSecondaryFixedVariant() *Color
- func (m MaterialSpec2025) OnSurface() *Color
- func (m MaterialSpec2025) OnSurfaceVariant() *Color
- func (m MaterialSpec2025) OnTertiary() *Color
- func (m MaterialSpec2025) OnTertiaryContainer() *Color
- func (m MaterialSpec2025) OnTertiaryFixed() *Color
- func (m MaterialSpec2025) OnTertiaryFixedVariant() *Color
- func (m MaterialSpec2025) Outline() *Color
- func (m MaterialSpec2025) OutlineVariant() *Color
- func (m MaterialSpec2025) Primary() *Color
- func (m MaterialSpec2025) PrimaryContainer() *Color
- func (m MaterialSpec2025) PrimaryDim() *Color
- func (m MaterialSpec2025) PrimaryFixed() *Color
- func (m MaterialSpec2025) PrimaryFixedDim() *Color
- func (m MaterialSpec2025) Secondary() *Color
- func (m MaterialSpec2025) SecondaryContainer() *Color
- func (m MaterialSpec2025) SecondaryDim() *Color
- func (m MaterialSpec2025) SecondaryFixed() *Color
- func (m MaterialSpec2025) SecondaryFixedDim() *Color
- func (m MaterialSpec2025) Surface() *Color
- func (m MaterialSpec2025) SurfaceBright() *Color
- func (m MaterialSpec2025) SurfaceContainer() *Color
- func (m MaterialSpec2025) SurfaceContainerHigh() *Color
- func (m MaterialSpec2025) SurfaceContainerHighest() *Color
- func (m MaterialSpec2025) SurfaceContainerLow() *Color
- func (m MaterialSpec2025) SurfaceContainerLowest() *Color
- func (m MaterialSpec2025) SurfaceDim() *Color
- func (m MaterialSpec2025) Tertiary() *Color
- func (m MaterialSpec2025) TertiaryContainer() *Color
- func (m MaterialSpec2025) TertiaryDim() *Color
- func (m MaterialSpec2025) TertiaryFixed() *Color
- func (m MaterialSpec2025) TertiaryFixedDim() *Color
- type Platform
- type Scheme
- type SchemePalettesDelegate
- type TonalPaletteFunc
- type ToneDeltaPair
- type ToneDeltaPairFunc
- type ToneFunc
- type TonePolarity
- type Variant
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // ColorCalculation2025 is a delegate implementing color calculation logic // following the Material Design 2025 specification. ColorCalculation2025 = colorCalculationDelegateImpl2025{} // ColorCalculation2021 is a delegate implementing color calculation logic // following the Material Design 2021 specification. ColorCalculation2021 = colorCalculationDelegateImpl2021{} )
var ErrInvalidConstraint = fmt.Errorf("not a valid Constraint, try [%s]", strings.Join(_ConstraintNames, ", "))
var ErrInvalidPlatform = fmt.Errorf("not a valid Platform, try [%s]", strings.Join(_PlatformNames, ", "))
var ErrInvalidTonePolarity = fmt.Errorf("not a valid TonePolarity, try [%s]", strings.Join(_TonePolarityNames, ", "))
var ErrInvalidVariant = fmt.Errorf("not a valid Variant, try [%s]", strings.Join(_VariantNames, ", "))
var ErrInvalidVersion = fmt.Errorf("not a valid Version, try [%s]", strings.Join(_VersionNames, ", "))
Functions ¶
func ConstraintNames ¶
func ConstraintNames() []string
ConstraintNames returns a list of possible string values of Constraint.
func EnableLightForeground ¶
EnableLightForeground adjusts a tone to enable light foreground if needed.
func FindDesiredChromaByTone ¶
FindDesiredChromaByTone finds a tone where the chroma is as close as possible to the requested value
func ForegroundTone ¶
ForegroundTone calculates a foreground tone that has sufficient contrast with a background tone
func GetPiecewiseHue ¶
GetPiecewiseHue returns a new hue based on a piece wise function and the input color's hue.
func GetRotatedHue ¶
func GetRotatedHue( sourceColorHct color.Hct, hueBreakpoints []float64, rotations []float64, ) float64
GetRotatedHue returns a shifted hue based on a piece wise function and the input hue.
func IsFidelity ¶
IsFidelity returns whether the scheme is a fidelity scheme
func IsMonochrome ¶
IsMonochrome returns whether the scheme is monochrome
func PlatformNames ¶
func PlatformNames() []string
PlatformNames returns a list of possible string values of Platform.
func ToneAllowsLightForeground ¶
ToneAllowsLightForeground determines if a tone allows light foreground.
func TonePolarityNames ¶
func TonePolarityNames() []string
TonePolarityNames returns a list of possible string values of TonePolarity.
func TonePrefersLightForeground ¶
TonePrefersLightForeground determines if a tone prefers light foreground.
func VariantNames ¶
func VariantNames() []string
VariantNames returns a list of possible string values of Variant.
func VersionNames ¶
func VersionNames() []string
VersionNames returns a list of possible string values of Version.
Types ¶
type ChromaMultiplier ¶
ChromaMultiplier returns a multiplier for the chroma value based on the Scheme. This is used to scale the chroma of the color and defaults to 1 when unspecified.
type Color ¶
type Color struct {
Name string
Palette TonalPaletteFunc
Tone ToneFunc
ChromaMultiplier ChromaMultiplier
IsBackground bool
Background ColorFunc
SecondBackground ColorFunc
ToneDeltaPair ToneDeltaPairFunc
ContrastCurve ContrastCurveFunc
}
Color represents a color in a dynamic color scheme
func DynamicColorFromPalette ¶
func FromPalette ¶
func FromPalette(name string, palette TonalPaletteFunc, tone ToneFunc) *Color
FromPalette creates a DynamicColor from a palette and tone function.
type ColorCalculationDelegate ¶
type ColorCalculationDelegate interface {
// GetHct returns the HCT color for the given scheme and color.
GetHct(scheme *Scheme, dc *Color) color.Hct
// GetTone returns the tone value for the given scheme and color.
GetTone(scheme *Scheme, dc *Color) float64
}
ColorCalculationDelegate provides the HCT and tone of a color within a scheme.
This interface allows different implementations of color calculation logic for different Material Design spec versions.
type ColorFunc ¶
ColorFunc returns a pointer to a Color based on the Scheme. Typically used to reference background or related colors dynamically.
type Constraint ¶
type Constraint uint
Constraint describes how to fulfill a tone delta pair constraint.
ENUM(exact, nearer, farther)
const ( // ConstraintExact is a Constraint of type Exact. ConstraintExact Constraint = 0 // ConstraintNearer is a Constraint of type Nearer. ConstraintNearer Constraint = 1 // ConstraintFarther is a Constraint of type Farther. ConstraintFarther Constraint = 2 )
func ConstraintValues ¶
func ConstraintValues() []Constraint
ConstraintValues returns a list of the values for Constraint
func ParseConstraint ¶
func ParseConstraint(name string) (Constraint, error)
ParseConstraint attempts to convert a string to a Constraint.
func (*Constraint) AppendText ¶
func (x *Constraint) AppendText(b []byte) ([]byte, error)
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Constraint) IsValid ¶
func (x Constraint) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Constraint) MarshalText ¶
func (x Constraint) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (Constraint) String ¶
func (x Constraint) String() string
String implements the Stringer interface.
func (*Constraint) UnmarshalText ¶
func (x *Constraint) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type ContrastCurve ¶
type ContrastCurve struct {
// contains filtered or unexported fields
}
ContrastCurve represents a curve that provides contrast values for different contrast levels.
func GetCurve ¶
func GetCurve(defaultContrast float64) *ContrastCurve
GetCurve returns the contrast curve for a given default contrast.
func NewContrastCurve ¶
func NewContrastCurve(low, normal, medium, high float64) *ContrastCurve
NewContrastCurve returns a new ContrastCurve with the given values for each contrast level. The low value is used for contrast level -1.0, normal for 0.0, medium for 0.5, and high for 1.0.
func (*ContrastCurve) Get ¶
func (c *ContrastCurve) Get(contrast float64) float64
Get returns the value at the given contrast level. Contrast level 0.0 is the default (normal), -1.0 is the lowest, and 1.0 is the highest. The returned value for contrast ratios is between 1.0 and 21.0.
type ContrastCurveFunc ¶
type ContrastCurveFunc func(s *Scheme) *ContrastCurve
ContrastCurveFunc returns a pointer to a ContrastCurve based on the Scheme. A ContrastCurve defines how a color's contrast behaves at various contrast levels. This is typically used in conjunction with a background color.
type MaterialColorSpec ¶
type MaterialColorSpec interface {
Background() *Color
Error() *Color
ErrorContainer() *Color
ErrorDim() *Color
HighestSurface(s *Scheme) *Color
InverseOnSurface() *Color
InversePrimary() *Color
InverseSurface() *Color
NeutralPaletteKeyColor() *Color
NeutralVariantPaletteKeyColor() *Color
OnBackground() *Color
OnError() *Color
OnErrorContainer() *Color
OnPrimary() *Color
OnPrimaryContainer() *Color
OnPrimaryFixed() *Color
OnPrimaryFixedVariant() *Color
OnSecondary() *Color
OnSecondaryContainer() *Color
OnSecondaryFixed() *Color
OnSecondaryFixedVariant() *Color
OnSurface() *Color
OnSurfaceVariant() *Color
OnTertiary() *Color
OnTertiaryContainer() *Color
OnTertiaryFixed() *Color
OnTertiaryFixedVariant() *Color
Outline() *Color
OutlineVariant() *Color
Primary() *Color
PrimaryContainer() *Color
PrimaryDim() *Color
PrimaryFixed() *Color
PrimaryFixedDim() *Color
PrimaryPaletteKeyColor() *Color
Scrim() *Color
Secondary() *Color
SecondaryContainer() *Color
SecondaryDim() *Color
SecondaryFixed() *Color
SecondaryFixedDim() *Color
SecondaryPaletteKeyColor() *Color
Shadow() *Color
Surface() *Color
SurfaceBright() *Color
SurfaceContainer() *Color
SurfaceContainerHigh() *Color
SurfaceContainerHighest() *Color
SurfaceContainerLow() *Color
SurfaceContainerLowest() *Color
SurfaceDim() *Color
SurfaceTint() *Color
SurfaceVariant() *Color
Tertiary() *Color
TertiaryContainer() *Color
TertiaryDim() *Color
TertiaryFixed() *Color
TertiaryFixedDim() *Color
TertiaryPaletteKeyColor() *Color
}
type MaterialSpec2021 ¶
type MaterialSpec2021 struct{}
func (MaterialSpec2021) Background ¶
func (m MaterialSpec2021) Background() *Color
func (MaterialSpec2021) Error ¶
func (m MaterialSpec2021) Error() *Color
func (MaterialSpec2021) ErrorContainer ¶
func (m MaterialSpec2021) ErrorContainer() *Color
func (MaterialSpec2021) ErrorDim ¶
func (m MaterialSpec2021) ErrorDim() *Color
func (MaterialSpec2021) HighestSurface ¶
func (m MaterialSpec2021) HighestSurface(s *Scheme) *Color
HighestSurface returns the highest surface color based on dark mode
func (MaterialSpec2021) InverseOnSurface ¶
func (m MaterialSpec2021) InverseOnSurface() *Color
func (MaterialSpec2021) InversePrimary ¶
func (m MaterialSpec2021) InversePrimary() *Color
func (MaterialSpec2021) InverseSurface ¶
func (m MaterialSpec2021) InverseSurface() *Color
func (MaterialSpec2021) NeutralPaletteKeyColor ¶
func (m MaterialSpec2021) NeutralPaletteKeyColor() *Color
func (MaterialSpec2021) NeutralVariantPaletteKeyColor ¶
func (m MaterialSpec2021) NeutralVariantPaletteKeyColor() *Color
func (MaterialSpec2021) OnBackground ¶
func (m MaterialSpec2021) OnBackground() *Color
func (MaterialSpec2021) OnError ¶
func (m MaterialSpec2021) OnError() *Color
func (MaterialSpec2021) OnErrorContainer ¶
func (m MaterialSpec2021) OnErrorContainer() *Color
func (MaterialSpec2021) OnPrimary ¶
func (m MaterialSpec2021) OnPrimary() *Color
func (MaterialSpec2021) OnPrimaryContainer ¶
func (m MaterialSpec2021) OnPrimaryContainer() *Color
func (MaterialSpec2021) OnPrimaryFixed ¶
func (m MaterialSpec2021) OnPrimaryFixed() *Color
func (MaterialSpec2021) OnPrimaryFixedVariant ¶
func (m MaterialSpec2021) OnPrimaryFixedVariant() *Color
func (MaterialSpec2021) OnSecondary ¶
func (m MaterialSpec2021) OnSecondary() *Color
func (MaterialSpec2021) OnSecondaryContainer ¶
func (m MaterialSpec2021) OnSecondaryContainer() *Color
func (MaterialSpec2021) OnSecondaryFixed ¶
func (m MaterialSpec2021) OnSecondaryFixed() *Color
func (MaterialSpec2021) OnSecondaryFixedVariant ¶
func (m MaterialSpec2021) OnSecondaryFixedVariant() *Color
func (MaterialSpec2021) OnSurface ¶
func (m MaterialSpec2021) OnSurface() *Color
func (MaterialSpec2021) OnSurfaceVariant ¶
func (m MaterialSpec2021) OnSurfaceVariant() *Color
func (MaterialSpec2021) OnTertiary ¶
func (m MaterialSpec2021) OnTertiary() *Color
func (MaterialSpec2021) OnTertiaryContainer ¶
func (m MaterialSpec2021) OnTertiaryContainer() *Color
func (MaterialSpec2021) OnTertiaryFixed ¶
func (m MaterialSpec2021) OnTertiaryFixed() *Color
func (MaterialSpec2021) OnTertiaryFixedVariant ¶
func (m MaterialSpec2021) OnTertiaryFixedVariant() *Color
func (MaterialSpec2021) Outline ¶
func (m MaterialSpec2021) Outline() *Color
func (MaterialSpec2021) OutlineVariant ¶
func (m MaterialSpec2021) OutlineVariant() *Color
func (MaterialSpec2021) Primary ¶
func (m MaterialSpec2021) Primary() *Color
func (MaterialSpec2021) PrimaryContainer ¶
func (m MaterialSpec2021) PrimaryContainer() *Color
func (MaterialSpec2021) PrimaryDim ¶
func (m MaterialSpec2021) PrimaryDim() *Color
func (MaterialSpec2021) PrimaryFixed ¶
func (m MaterialSpec2021) PrimaryFixed() *Color
func (MaterialSpec2021) PrimaryFixedDim ¶
func (m MaterialSpec2021) PrimaryFixedDim() *Color
func (MaterialSpec2021) PrimaryPaletteKeyColor ¶
func (m MaterialSpec2021) PrimaryPaletteKeyColor() *Color
func (MaterialSpec2021) Scrim ¶
func (m MaterialSpec2021) Scrim() *Color
func (MaterialSpec2021) Secondary ¶
func (m MaterialSpec2021) Secondary() *Color
func (MaterialSpec2021) SecondaryContainer ¶
func (m MaterialSpec2021) SecondaryContainer() *Color
func (MaterialSpec2021) SecondaryDim ¶
func (m MaterialSpec2021) SecondaryDim() *Color
func (MaterialSpec2021) SecondaryFixed ¶
func (m MaterialSpec2021) SecondaryFixed() *Color
func (MaterialSpec2021) SecondaryFixedDim ¶
func (m MaterialSpec2021) SecondaryFixedDim() *Color
func (MaterialSpec2021) SecondaryPaletteKeyColor ¶
func (m MaterialSpec2021) SecondaryPaletteKeyColor() *Color
func (MaterialSpec2021) Shadow ¶
func (m MaterialSpec2021) Shadow() *Color
func (MaterialSpec2021) Surface ¶
func (m MaterialSpec2021) Surface() *Color
func (MaterialSpec2021) SurfaceBright ¶
func (m MaterialSpec2021) SurfaceBright() *Color
func (MaterialSpec2021) SurfaceContainer ¶
func (m MaterialSpec2021) SurfaceContainer() *Color
func (MaterialSpec2021) SurfaceContainerHigh ¶
func (m MaterialSpec2021) SurfaceContainerHigh() *Color
func (MaterialSpec2021) SurfaceContainerHighest ¶
func (m MaterialSpec2021) SurfaceContainerHighest() *Color
func (MaterialSpec2021) SurfaceContainerLow ¶
func (m MaterialSpec2021) SurfaceContainerLow() *Color
func (MaterialSpec2021) SurfaceContainerLowest ¶
func (m MaterialSpec2021) SurfaceContainerLowest() *Color
func (MaterialSpec2021) SurfaceDim ¶
func (m MaterialSpec2021) SurfaceDim() *Color
func (MaterialSpec2021) SurfaceTint ¶
func (m MaterialSpec2021) SurfaceTint() *Color
func (MaterialSpec2021) SurfaceVariant ¶
func (m MaterialSpec2021) SurfaceVariant() *Color
func (MaterialSpec2021) Tertiary ¶
func (m MaterialSpec2021) Tertiary() *Color
func (MaterialSpec2021) TertiaryContainer ¶
func (m MaterialSpec2021) TertiaryContainer() *Color
func (MaterialSpec2021) TertiaryDim ¶
func (m MaterialSpec2021) TertiaryDim() *Color
func (MaterialSpec2021) TertiaryFixed ¶
func (m MaterialSpec2021) TertiaryFixed() *Color
func (MaterialSpec2021) TertiaryFixedDim ¶
func (m MaterialSpec2021) TertiaryFixedDim() *Color
func (MaterialSpec2021) TertiaryPaletteKeyColor ¶
func (m MaterialSpec2021) TertiaryPaletteKeyColor() *Color
type MaterialSpec2025 ¶
type MaterialSpec2025 struct {
MaterialSpec2021
}
func (MaterialSpec2025) Error ¶
func (m MaterialSpec2025) Error() *Color
func (MaterialSpec2025) ErrorContainer ¶
func (m MaterialSpec2025) ErrorContainer() *Color
func (MaterialSpec2025) ErrorDim ¶
func (m MaterialSpec2025) ErrorDim() *Color
func (MaterialSpec2025) InverseOnSurface ¶
func (m MaterialSpec2025) InverseOnSurface() *Color
func (MaterialSpec2025) InversePrimary ¶
func (m MaterialSpec2025) InversePrimary() *Color
func (MaterialSpec2025) InverseSurface ¶
func (m MaterialSpec2025) InverseSurface() *Color
func (MaterialSpec2025) OnError ¶
func (m MaterialSpec2025) OnError() *Color
func (MaterialSpec2025) OnErrorContainer ¶
func (m MaterialSpec2025) OnErrorContainer() *Color
func (MaterialSpec2025) OnPrimary ¶
func (m MaterialSpec2025) OnPrimary() *Color
func (MaterialSpec2025) OnPrimaryContainer ¶
func (m MaterialSpec2025) OnPrimaryContainer() *Color
func (MaterialSpec2025) OnPrimaryFixed ¶
func (m MaterialSpec2025) OnPrimaryFixed() *Color
func (MaterialSpec2025) OnPrimaryFixedVariant ¶
func (m MaterialSpec2025) OnPrimaryFixedVariant() *Color
func (MaterialSpec2025) OnSecondary ¶
func (m MaterialSpec2025) OnSecondary() *Color
func (MaterialSpec2025) OnSecondaryContainer ¶
func (m MaterialSpec2025) OnSecondaryContainer() *Color
func (MaterialSpec2025) OnSecondaryFixed ¶
func (m MaterialSpec2025) OnSecondaryFixed() *Color
func (MaterialSpec2025) OnSecondaryFixedVariant ¶
func (m MaterialSpec2025) OnSecondaryFixedVariant() *Color
func (MaterialSpec2025) OnSurface ¶
func (m MaterialSpec2025) OnSurface() *Color
func (MaterialSpec2025) OnSurfaceVariant ¶
func (m MaterialSpec2025) OnSurfaceVariant() *Color
func (MaterialSpec2025) OnTertiary ¶
func (m MaterialSpec2025) OnTertiary() *Color
func (MaterialSpec2025) OnTertiaryContainer ¶
func (m MaterialSpec2025) OnTertiaryContainer() *Color
func (MaterialSpec2025) OnTertiaryFixed ¶
func (m MaterialSpec2025) OnTertiaryFixed() *Color
func (MaterialSpec2025) OnTertiaryFixedVariant ¶
func (m MaterialSpec2025) OnTertiaryFixedVariant() *Color
func (MaterialSpec2025) Outline ¶
func (m MaterialSpec2025) Outline() *Color
func (MaterialSpec2025) OutlineVariant ¶
func (m MaterialSpec2025) OutlineVariant() *Color
func (MaterialSpec2025) Primary ¶
func (m MaterialSpec2025) Primary() *Color
func (MaterialSpec2025) PrimaryContainer ¶
func (m MaterialSpec2025) PrimaryContainer() *Color
func (MaterialSpec2025) PrimaryDim ¶
func (m MaterialSpec2025) PrimaryDim() *Color
func (MaterialSpec2025) PrimaryFixed ¶
func (m MaterialSpec2025) PrimaryFixed() *Color
func (MaterialSpec2025) PrimaryFixedDim ¶
func (m MaterialSpec2025) PrimaryFixedDim() *Color
func (MaterialSpec2025) Secondary ¶
func (m MaterialSpec2025) Secondary() *Color
func (MaterialSpec2025) SecondaryContainer ¶
func (m MaterialSpec2025) SecondaryContainer() *Color
func (MaterialSpec2025) SecondaryDim ¶
func (m MaterialSpec2025) SecondaryDim() *Color
func (MaterialSpec2025) SecondaryFixed ¶
func (m MaterialSpec2025) SecondaryFixed() *Color
func (MaterialSpec2025) SecondaryFixedDim ¶
func (m MaterialSpec2025) SecondaryFixedDim() *Color
func (MaterialSpec2025) Surface ¶
func (m MaterialSpec2025) Surface() *Color
func (MaterialSpec2025) SurfaceBright ¶
func (m MaterialSpec2025) SurfaceBright() *Color
func (MaterialSpec2025) SurfaceContainer ¶
func (m MaterialSpec2025) SurfaceContainer() *Color
func (MaterialSpec2025) SurfaceContainerHigh ¶
func (m MaterialSpec2025) SurfaceContainerHigh() *Color
func (MaterialSpec2025) SurfaceContainerHighest ¶
func (m MaterialSpec2025) SurfaceContainerHighest() *Color
func (MaterialSpec2025) SurfaceContainerLow ¶
func (m MaterialSpec2025) SurfaceContainerLow() *Color
func (MaterialSpec2025) SurfaceContainerLowest ¶
func (m MaterialSpec2025) SurfaceContainerLowest() *Color
func (MaterialSpec2025) SurfaceDim ¶
func (m MaterialSpec2025) SurfaceDim() *Color
func (MaterialSpec2025) Tertiary ¶
func (m MaterialSpec2025) Tertiary() *Color
func (MaterialSpec2025) TertiaryContainer ¶
func (m MaterialSpec2025) TertiaryContainer() *Color
func (MaterialSpec2025) TertiaryDim ¶
func (m MaterialSpec2025) TertiaryDim() *Color
func (MaterialSpec2025) TertiaryFixed ¶
func (m MaterialSpec2025) TertiaryFixed() *Color
func (MaterialSpec2025) TertiaryFixedDim ¶
func (m MaterialSpec2025) TertiaryFixedDim() *Color
type Platform ¶
type Platform uint
Platform indicates target platform for generating colors
ENUM(phone, watch)
func ParsePlatform ¶
ParsePlatform attempts to convert a string to a Platform.
func PlatformValues ¶
func PlatformValues() []Platform
PlatformValues returns a list of the values for Platform
func (*Platform) AppendText ¶
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Platform) IsValid ¶
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Platform) MarshalText ¶
MarshalText implements the text marshaller method.
func (*Platform) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.
type Scheme ¶
type Scheme struct {
// SourceColorHct is the source color of the theme as an HCT color
SourceColorHct color.Hct `json:"source_color_hct"`
// Variant is the style variant of the theme (e.g., monochrome, tonal spot,
// etc.)
Variant Variant `json:"variant"`
// Dark indicates whether the scheme is in dark mode (true) or light mode
// (false)
Dark bool `json:"dark"`
// Platform specifies the platform on which this scheme is intended to be
// used
Platform Platform `json:"platform"`
// Version specifies the version of the Material Design spec (2021 or 2025)
Version Version `json:"version"`
// Contrast represents the contrast level from -1 to 1, where:
// -1 = minimum contrast, 0 = standard contrast, 1 = maximum contrast
Contrast float64 `json:"contrast"`
// PrimaryPalette produces colors for primary UI elements. Usually colorful.
PrimaryPalette palettes.TonalPalette `json:"-"`
// SecondaryPalette produces colors for secondary UI elements. Usually less
// colorful.
SecondaryPalette palettes.TonalPalette `json:"-"`
// TertiaryPalette produces colors for tertiary UI elements. Usually a
// different hue from primary and colorful.
TertiaryPalette palettes.TonalPalette `json:"-"`
// NeutralPalette produces neutral colors for backgrounds and surfaces.
// Usually not colorful at all.
NeutralPalette palettes.TonalPalette `json:"-"`
// NeutralVariantPalette produces neutral variant colors for backgrounds and
// surfaces. Usually not colorful, but slightly more colorful than Neutral
// palette.
NeutralVariantPalette palettes.TonalPalette `json:"-"`
// ErrorPalette produces colors for error states. Usually reddish and
// colorful.
ErrorPalette palettes.TonalPalette `json:"-"`
// MaterialColor provides the material color specification implementation
// for the given version (2021 or 2025)
MaterialColor MaterialColorSpec `json:"-"`
}
Scheme represents a dynamic color scheme constructed from a set of values representing the current UI state (dark/light theme, theme style, etc.), and provides a set of TonalPalettes that create colors fitting the theme style. Used by Color to resolve into actual colors.
func NewDynamicScheme ¶
func NewDynamicScheme( sourceColorHct color.Hct, variant Variant, contrastLevel float64, dark bool, platform Platform, version Version, optPalettes ...*palettes.TonalPalette, ) *Scheme
NewDynamicScheme creates a dynamic color scheme from a source color and theme parameters. The function automatically selects the appropriate palette delegate and material color specification based on the given version (e.g., 2021 or 2025).
Parameters:
- sourceColorHct: Source color of the theme, in HCT color space.
- variant: Theme variant or style.
- contrastLevel: Contrast adjustment in the range [-1, 1]; where -1 is minimum contrast, 0 is standard, and 1 is maximum.
- dark: Whether the scheme is in dark mode.
- platform: Target platform for the scheme.
- version: Design spec version the scheme is based on.
- optPalettes: Optional TonalPalettes (up to six) in the following order: 1. primaryPalette 2. secondaryPalette 3. tertiaryPalette 4. neutralPalette 5. neutralVariantPalette 6. errorPalette
Missing palettes are generated automatically.
func (Scheme) SourceColorARGB ¶
SourceColorARGB returns ARGB version of source color.
func (Scheme) ToColorMap ¶
ToColorMap creates a map of color name as key and *Color as value.
type SchemePalettesDelegate ¶
type SchemePalettesDelegate interface {
GetPrimaryPalette(
variant Variant,
sourceColorHct color.Hct,
dark bool,
platform Platform,
contrastLevel float64,
) *palettes.TonalPalette
GetSecondaryPalette(
variant Variant,
sourceColorHct color.Hct,
dark bool,
platform Platform,
contrastLevel float64,
) *palettes.TonalPalette
GetTertiaryPalette(
variant Variant,
sourceColorHct color.Hct,
dark bool,
platform Platform,
contrastLevel float64,
) *palettes.TonalPalette
GetNeutralPalette(
variant Variant,
sourceColorHct color.Hct,
dark bool,
platform Platform,
contrastLevel float64,
) *palettes.TonalPalette
GetNeutralVariantPalette(
variant Variant,
sourceColorHct color.Hct,
dark bool,
platform Platform,
contrastLevel float64,
) *palettes.TonalPalette
GetErrorPalette(
variant Variant,
sourceColorHct color.Hct,
dark bool,
platform Platform,
contrastLevel float64,
) *palettes.TonalPalette
}
SchemePalettesDelegate is an interface for the palettes of a DynamicScheme
type TonalPaletteFunc ¶
type TonalPaletteFunc func(s *Scheme) palettes.TonalPalette
TonalPaletteFunc returns a TonalPalette based on the provided Scheme. A TonalPalette is defined by a hue and chroma, allowing chroma to be preserved when contrast adjustments are made, instead of directly specifying hue/chroma.
type ToneDeltaPair ¶
type ToneDeltaPair struct {
RoleA, RoleB *Color
Delta float64
Polarity TonePolarity
StayTogether bool
Constraint Constraint
}
ToneDeltaPair documents a constraint between two DynamicColors, in which their tones must have a certain distance from each other.
func NewToneDeltaPair ¶
func NewToneDeltaPair( roleA, roleB *Color, delta float64, polarity TonePolarity, stayTogether bool, constraint ...Constraint, ) *ToneDeltaPair
NewToneDeltaPair creates a new ToneDeltaPair with default constraint = "exact".
type ToneDeltaPairFunc ¶
type ToneDeltaPairFunc func(s *Scheme) *ToneDeltaPair
ToneDeltaPairFunc returns a pointer to a ToneDeltaPair for the given Scheme. A ToneDeltaPair enforces a tone difference constraint between two colors, where one must be the color being constructed.
type ToneFunc ¶
ToneFunc returns the tone (lightness) of the color for a given Scheme. If not explicitly provided, it defaults to the tone of the background, or 50 if there is no background.
func GetInitialToneFromBackground ¶
GetInitialToneFromBackground returns initial tone from given background ColorFunc. Returns 50 if background ColorFunc is nil.
type TonePolarity ¶
type TonePolarity uint
TonePolarity describes the difference in tone between colors.
ENUM(darker, lighter, nearer, farther, relative_darker, relative_lighter)
const ( // TonePolarityDarker is a TonePolarity of type Darker. TonePolarityDarker TonePolarity = 0 // TonePolarityLighter is a TonePolarity of type Lighter. TonePolarityLighter TonePolarity = 1 // TonePolarityNearer is a TonePolarity of type Nearer. TonePolarityNearer TonePolarity = 2 // TonePolarityFarther is a TonePolarity of type Farther. TonePolarityFarther TonePolarity = 3 // TonePolarityRelativeDarker is a TonePolarity of type Relative_darker. TonePolarityRelativeDarker TonePolarity = 4 // TonePolarityRelativeLighter is a TonePolarity of type Relative_lighter. TonePolarityRelativeLighter TonePolarity = 5 )
func ParseTonePolarity ¶
func ParseTonePolarity(name string) (TonePolarity, error)
ParseTonePolarity attempts to convert a string to a TonePolarity.
func TonePolarityValues ¶
func TonePolarityValues() []TonePolarity
TonePolarityValues returns a list of the values for TonePolarity
func (*TonePolarity) AppendText ¶
func (x *TonePolarity) AppendText(b []byte) ([]byte, error)
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (TonePolarity) IsValid ¶
func (x TonePolarity) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (TonePolarity) MarshalText ¶
func (x TonePolarity) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (TonePolarity) String ¶
func (x TonePolarity) String() string
String implements the Stringer interface.
func (*TonePolarity) UnmarshalText ¶
func (x *TonePolarity) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type Variant ¶
type Variant uint
Variant indicates type of scheme to generate
ENUM(monochrome, neutral, tonal_spot, vibrant, expressive, fidelity, content, rainbow, fruit_salad)
const ( // VariantMonochrome is a Variant of type Monochrome. VariantMonochrome Variant = 0 // VariantNeutral is a Variant of type Neutral. VariantNeutral Variant = 1 // VariantTonalSpot is a Variant of type Tonal_spot. VariantTonalSpot Variant = 2 // VariantVibrant is a Variant of type Vibrant. VariantVibrant Variant = 3 // VariantExpressive is a Variant of type Expressive. VariantExpressive Variant = 4 // VariantFidelity is a Variant of type Fidelity. VariantFidelity Variant = 5 // VariantContent is a Variant of type Content. VariantContent Variant = 6 // VariantRainbow is a Variant of type Rainbow. VariantRainbow Variant = 7 // VariantFruitSalad is a Variant of type Fruit_salad. VariantFruitSalad Variant = 8 )
func ParseVariant ¶
ParseVariant attempts to convert a string to a Variant.
func VariantValues ¶
func VariantValues() []Variant
VariantValues returns a list of the values for Variant
func (*Variant) AppendText ¶
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Variant) IsValid ¶
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Variant) MarshalText ¶
MarshalText implements the text marshaller method.
func (*Variant) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.
type Version ¶
type Version uint
Version indicates the material color specification year
ENUM(2021=2021, 2025=2025)
func ParseVersion ¶
ParseVersion attempts to convert a string to a Version.
func VersionValues ¶
func VersionValues() []Version
VersionValues returns a list of the values for Version
func (*Version) AppendText ¶
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Version) IsValid ¶
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Version) MarshalText ¶
MarshalText implements the text marshaller method.
func (*Version) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.