styles

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: BSD-3-Clause Imports: 26 Imported by: 37

Documentation

Overview

Package GiSt contains the style structures for the GoGi GUI framework.

These are all based on the CSS standard: https://www.w3schools.com/cssref/default.asp

The xml struct tags provide the (lowercase) keyword for each tag -- tags can be parsed from strings using these keywords.

Index

Constants

This section is empty.

Variables

View Source
var (
	// BorderRadiusNone indicates to use no border radius,
	// which creates a fully rectangular element
	BorderRadiusNone = NewSideValues(units.Zero())
	// BorderRadiusExtraSmall indicates to use extra small
	// 4dp rounded corners
	BorderRadiusExtraSmall = NewSideValues(units.Dp(4))
	// BorderRadiusExtraSmallTop indicates to use extra small
	// 4dp rounded corners on the top of the element and no
	// border radius on the bottom of the element
	BorderRadiusExtraSmallTop = NewSideValues(units.Dp(4), units.Dp(4), units.Zero(), units.Zero())
	// BorderRadiusSmall indicates to use small
	// 8dp rounded corners
	BorderRadiusSmall = NewSideValues(units.Dp(8))
	// BorderRadiusMedium indicates to use medium
	// 12dp rounded corners
	BorderRadiusMedium = NewSideValues(units.Dp(12))
	// BorderRadiusLarge indicates to use large
	// 16dp rounded corners
	BorderRadiusLarge = NewSideValues(units.Dp(16))
	// BorderRadiusLargeEnd indicates to use large
	// 16dp rounded corners on the end (right side)
	// of the element and no border radius elsewhere
	BorderRadiusLargeEnd = NewSideValues(units.Zero(), units.Dp(16), units.Dp(16), units.Zero())
	// BorderRadiusLargeTop indicates to use large
	// 16dp rounded corners on the top of the element
	// and no border radius on the bottom of the element
	BorderRadiusLargeTop = NewSideValues(units.Dp(16), units.Dp(16), units.Zero(), units.Zero())
	// BorderRadiusExtraLarge indicates to use extra large
	// 28dp rounded corners
	BorderRadiusExtraLarge = NewSideValues(units.Dp(28))
	// BorderRadiusExtraLargeTop indicates to use extra large
	// 28dp rounded corners on the top of the element
	// and no border radius on the bottom of the element
	BorderRadiusExtraLargeTop = NewSideValues(units.Dp(28), units.Dp(28), units.Zero(), units.Zero())
	// BorderRadiusFull indicates to use a full border radius,
	// which creates a circular/pill-shaped object.
	// It is defined to be a value that the width/height of an object
	// will never exceed.
	BorderRadiusFull = NewSideValues(units.Dp(1_000_000_000))
)

Pre-configured border radius values, based on https://m3.material.io/styles/shape/shape-scale-tokens

View Source
var FontSizePoints = map[string]float32{
	"xx-small": 7,
	"x-small":  7.5,
	"small":    10,
	"smallf":   10,
	"medium":   12,
	"large":    14,
	"x-large":  18,
	"xx-large": 24,
}

FontSizePoints maps standard font names to standard point sizes -- we use dpi zoom scaling instead of rescaling "medium" font size, so generally use these values as-is. smaller and larger relative scaling can move in 2pt increments

View Source
var FontStretchNames = []string{"Normal", "UltraCondensed", "ExtraCondensed", "SemiCondensed", "SemiExpanded", "ExtraExpanded", "UltraExpanded", "Condensed", "Expanded", "Condensed", "Expanded"}

FontStretchNames contains the uppercase names of all the valid font stretches used in the regularized font names. The first name is the baseline default and will be omitted from font names. Order must have names that are subsets of other names at the end so they only match if the more specific one hasn't! And also match the FontStretch enum.

View Source
var FontStyleNames = []string{"Normal", "Italic", "Oblique"}

FontStyleNames contains the uppercase names of all the valid font styles used in the regularized font names. The first name is the baseline default and will be omitted from font names.

FontWeightNameVals is 1-to-1 index map from FontWeightNames to corresponding weight value (using more semantic term instead of numerical one)

View Source
var FontWeightNames = []string{"Normal", "Thin", "ExtraLight", "Light", "Medium", "SemiBold", "ExtraBold", "Bold", "Black"}

FontWeightNames contains the uppercase names of all the valid font weights used in the regularized font names. The first name is the baseline default and will be omitted from font names. Order must have names that are subsets of other names at the end so they only match if the more specific one hasn't!

View Source
var FontWeightToNameMap = map[FontWeights]string{
	Weight100:        "Thin",
	WeightThin:       "Thin",
	Weight200:        "ExtraLight",
	WeightExtraLight: "ExtraLight",
	Weight300:        "Light",
	WeightLight:      "Light",
	Weight400:        "",
	WeightNormal:     "",
	Weight500:        "Medium",
	WeightMedium:     "Medium",
	Weight600:        "SemiBold",
	WeightSemiBold:   "SemiBold",
	Weight700:        "Bold",
	WeightBold:       "Bold",
	Weight800:        "ExtraBold",
	WeightExtraBold:  "ExtraBold",
	Weight900:        "Black",
	WeightBlack:      "Black",
	WeightBolder:     "Medium",
	WeightLighter:    "Light",
}

FontWeightToNameMap maps all the style enums to canonical regularized font names

View Source
var LineHeightNormal = units.Dp(-1)

LineHeightNormal represents a normal line height, equal to the default height of the font being used.

View Source
var PrefFontFamily = "Roboto"

PrefFontFamily is the preferred fallback font family to use when the specified font is not available. It defaults to Roboto.

View Source
var ScrollBarWidthDefault = float32(10)

ScrollBarWidthDefault is the default width of a scrollbar in Dp

View Source
var StyleBorderFuncs = map[string]StyleFunc{

	"border-style": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Style = par.(*Border).Style
			} else if init {
				bs.Style.Set(BorderSolid)
			}
			return
		}
		switch vt := val.(type) {
		case string:
			bs.Style.SetString(vt)
		case BorderStyles:
			bs.Style.Set(vt)
		case []BorderStyles:
			bs.Style.Set(vt...)
		default:
			iv, err := laser.ToInt(val)
			if err == nil {
				bs.Style.Set(BorderStyles(iv))
			} else {
				StyleSetError(key, val, err)
			}
		}
	},
	"border-width": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Width = par.(*Border).Width
			} else if init {
				bs.Width.Zero()
			}
			return
		}
		bs.Width.SetAny(val)
	},
	"border-radius": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Radius = par.(*Border).Radius
			} else if init {
				bs.Radius.Zero()
			}
			return
		}
		bs.Radius.SetAny(val)
	},
	"border-color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Color = par.(*Border).Color
			} else if init {
				bs.Color.Set(colors.Black)
			}
			return
		}
		grr.Log(bs.Color.SetAny(val, ctxt.Base()))
	},
}

StyleBorderFuncs are functions for styling the Border object

View Source
var StyleFillFuncs = map[string]StyleFunc{
	"fill": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Fill)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Color = par.(*Fill).Color
			} else if init {
				fs.Color = colors.C(colors.Black)
			}
			return
		}
		fs.Color = grr.Log1(gradient.FromAny(val, ctxt))
	},
	"fill-opacity": StyleFuncFloat(float32(1),
		func(obj *Fill) *float32 { return &(obj.Opacity) }),
	"fill-rule": StyleFuncEnum(FillRuleNonZero,
		func(obj *Fill) enums.EnumSetter { return &(obj.Rule) }),
}

StyleFillFuncs are functions for styling the Fill object

View Source
var StyleFontFuncs = map[string]StyleFunc{
	"font-size": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Font)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Size = par.(*Font).Size
			} else if init {
				fs.Size.Set(12, units.UnitPt)
			}
			return
		}
		switch vt := val.(type) {
		case string:
			if psz, ok := FontSizePoints[vt]; ok {
				fs.Size = units.Pt(psz)
			} else {
				fs.Size.SetIFace(val, key)
			}
		default:
			fs.Size.SetIFace(val, key)
		}
	},
	"font-family": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Font)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Family = par.(*Font).Family
			} else if init {
				fs.Family = ""
			}
			return
		}
		fs.Family = laser.ToString(val)
	},
	"font-style": StyleFuncEnum(FontNormal,
		func(obj *Font) enums.EnumSetter { return &obj.Style }),
	"font-weight": StyleFuncEnum(WeightNormal,
		func(obj *Font) enums.EnumSetter { return &obj.Weight }),
	"font-stretch": StyleFuncEnum(FontStrNormal,
		func(obj *Font) enums.EnumSetter { return &obj.Stretch }),
	"font-variant": StyleFuncEnum(FontVarNormal,
		func(obj *Font) enums.EnumSetter { return &obj.Variant }),
	"baseline-shift": StyleFuncEnum(ShiftBaseline,
		func(obj *Font) enums.EnumSetter { return &obj.Shift }),
	"text-decoration": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Font)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Deco = par.(*Font).Deco
			} else if init {
				fs.Deco = DecoNone
			}
			return
		}
		switch vt := val.(type) {
		case string:
			if vt == "none" {
				fs.Deco = DecoNone
			} else {
				fs.Deco.SetString(vt)
			}
		case TextDecorations:
			fs.Deco = vt
		default:
			iv, err := laser.ToInt(val)
			if err == nil {
				fs.Deco = TextDecorations(iv)
			} else {
				StyleSetError(key, val, err)
			}
		}
	},
}

StyleFontFuncs are functions for styling the Font object

View Source
var StyleFontRenderFuncs = map[string]StyleFunc{
	"color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*FontRender)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Color = par.(*FontRender).Color
			} else if init {
				fs.Color = colors.Black
			}
			return
		}
		base := colors.Black
		if ctxt != nil {
			base = ctxt.Base()
		}
		fs.Color = grr.Log1(colors.FromAny(val, base))
	},
	"background-color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*FontRender)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Background = par.(*FontRender).Background
			} else if init {
				fs.Background = nil
			}
			return
		}
		fs.Background = grr.Log1(gradient.FromAny(val, ctxt))
	},
	"opacity": StyleFuncFloat(float32(1),
		func(obj *FontRender) *float32 { return &obj.Opacity }),
}

StyleFontRenderFuncs are _extra_ functions for styling the FontRender object in addition to base Font

View Source
var StyleLayoutFuncs = map[string]StyleFunc{
	"display": StyleFuncEnum(Flex,
		func(obj *Style) enums.EnumSetter { return &obj.Display }),
	"flex-direction": func(obj any, key string, val, par any, ctxt colors.Context) {
		s := obj.(*Style)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				s.Direction = par.(*Style).Direction
			} else if init {
				s.Direction = Row
			}
			return
		}
		str := laser.ToString(val)
		if str == "row" || str == "row-reverse" {
			s.Direction = Row
		} else {
			s.Direction = Column
		}
	},
	"wrap": StyleFuncBool(false,
		func(obj *Style) *bool { return &obj.Wrap }),
	"justify-content": StyleFuncEnum(Start,
		func(obj *Style) enums.EnumSetter { return &obj.Justify.Content }),
	"justify-items": StyleFuncEnum(Start,
		func(obj *Style) enums.EnumSetter { return &obj.Justify.Items }),
	"justify-self": StyleFuncEnum(Auto,
		func(obj *Style) enums.EnumSetter { return &obj.Justify.Self }),
	"align-content": StyleFuncEnum(Start,
		func(obj *Style) enums.EnumSetter { return &obj.Align.Content }),
	"align-items": StyleFuncEnum(Start,
		func(obj *Style) enums.EnumSetter { return &obj.Align.Items }),
	"align-self": StyleFuncEnum(Auto,
		func(obj *Style) enums.EnumSetter { return &obj.Align.Self }),
	"x": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.Pos.X }),
	"y": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.Pos.Y }),
	"width": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.Min.X }),
	"height": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.Min.Y }),
	"max-width": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.Max.X }),
	"max-height": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.Max.Y }),
	"min-width": StyleFuncUnits(units.Dp(2),
		func(obj *Style) *units.Value { return &obj.Min.X }),
	"min-height": StyleFuncUnits(units.Dp(2),
		func(obj *Style) *units.Value { return &obj.Min.Y }),
	"margin": func(obj any, key string, val any, par any, ctxt colors.Context) {
		s := obj.(*Style)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				s.Margin = par.(*Style).Margin
			} else if init {
				s.Margin.Zero()
			}
			return
		}
		s.Margin.SetAny(val)
	},
	"padding": func(obj any, key string, val any, par any, ctxt colors.Context) {
		s := obj.(*Style)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				s.Padding = par.(*Style).Padding
			} else if init {
				s.Padding.Zero()
			}
			return
		}
		s.Padding.SetAny(val)
	},

	"overflow": StyleFuncEnum(OverflowAuto,
		func(obj *Style) enums.EnumSetter { return &obj.Overflow.X }),
	"columns": StyleFuncInt(int(0),
		func(obj *Style) *int { return &obj.Columns }),
	"row": StyleFuncInt(int(0),
		func(obj *Style) *int { return &obj.Row }),
	"col": StyleFuncInt(int(0),
		func(obj *Style) *int { return &obj.Col }),
	"row-span": StyleFuncInt(int(0),
		func(obj *Style) *int { return &obj.RowSpan }),
	"col-span": StyleFuncInt(int(0),
		func(obj *Style) *int { return &obj.ColSpan }),
	"z-index": StyleFuncInt(int(0),
		func(obj *Style) *int { return &obj.ZIndex }),
	"scrollbar-width": StyleFuncUnits(units.Value{},
		func(obj *Style) *units.Value { return &obj.ScrollBarWidth }),
}

StyleLayoutFuncs are functions for styling the layout style properties; they are still stored on the main style object, but they are done separately to improve clarity

View Source
var StyleOutlineFuncs = map[string]StyleFunc{
	"outline-style": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Style = par.(*Border).Style
			} else if init {
				bs.Style.Set(BorderNone)
			}
			return
		}
		switch vt := val.(type) {
		case string:
			bs.Style.SetString(vt)
		case BorderStyles:
			bs.Style.Set(vt)
		case []BorderStyles:
			bs.Style.Set(vt...)
		default:
			iv, err := laser.ToInt(val)
			if err == nil {
				bs.Style.Set(BorderStyles(iv))
			} else {
				StyleSetError(key, val, err)
			}
		}
	},
	"outline-width": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Width = par.(*Border).Width
			} else if init {
				bs.Width.Zero()
			}
			return
		}
		bs.Width.SetAny(val)
	},
	"outline-radius": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Radius = par.(*Border).Radius
			} else if init {
				bs.Radius.Zero()
			}
			return
		}
		bs.Radius.SetAny(val)
	},
	"outline-color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		bs := obj.(*Border)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				bs.Color = par.(*Border).Color
			} else if init {
				bs.Color.Set(colors.Black)
			}
			return
		}
		grr.Log(bs.Color.SetAny(val, ctxt.Base()))
	},
}

StyleOutlineFuncs are functions for styling the OutlineStyle object

View Source
var StylePaintFuncs = map[string]StyleFunc{
	"vector-effect": StyleFuncEnum(VecEffNone,
		func(obj *Paint) enums.EnumSetter { return &(obj.VecEff) }),
	"transform": func(obj any, key string, val any, par any, ctxt colors.Context) {
		pc := obj.(*Paint)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				pc.Transform = par.(*Paint).Transform
			} else if init {
				pc.Transform = mat32.Identity2D()
			}
			return
		}
		switch vt := val.(type) {
		case string:
			pc.Transform.SetString(vt)
		case *mat32.Mat2:
			pc.Transform = *vt
		case mat32.Mat2:
			pc.Transform = vt
		}
	},
}

StylePaintFuncs are functions for styling the Stroke object

View Source
var StyleShadowFuncs = map[string]StyleFunc{
	"box-shadow.h-offset": StyleFuncUnits(units.Value{},
		func(obj *Shadow) *units.Value { return &obj.HOffset }),
	"box-shadow.v-offset": StyleFuncUnits(units.Value{},
		func(obj *Shadow) *units.Value { return &obj.VOffset }),
	"box-shadow.blur": StyleFuncUnits(units.Value{},
		func(obj *Shadow) *units.Value { return &obj.Blur }),
	"box-shadow.spread": StyleFuncUnits(units.Value{},
		func(obj *Shadow) *units.Value { return &obj.Spread }),
	"box-shadow.color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		ss := obj.(*Shadow)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				ss.Color = par.(*Shadow).Color
			} else if init {
				ss.Color = colors.Black
			}
			return
		}
		ss.Color = grr.Log1(colors.FromAny(val, ctxt.Base()))
	},
	"box-shadow.inset": StyleFuncBool(false,
		func(obj *Shadow) *bool { return &obj.Inset }),
}

StyleShadowFuncs are functions for styling the Shadow object

View Source
var StyleStrokeFuncs = map[string]StyleFunc{
	"stroke": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Stroke)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Color = par.(*Stroke).Color
			} else if init {
				fs.Color = colors.C(colors.Black)
			}
			return
		}
		fs.Color = grr.Log1(gradient.FromAny(val, ctxt))
	},
	"stroke-opacity": StyleFuncFloat(float32(1),
		func(obj *Stroke) *float32 { return &(obj.Opacity) }),
	"stroke-width": StyleFuncUnits(units.Dp(1),
		func(obj *Stroke) *units.Value { return &(obj.Width) }),
	"stroke-min-width": StyleFuncUnits(units.Dp(1),
		func(obj *Stroke) *units.Value { return &(obj.MinWidth) }),
	"stroke-dasharray": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Stroke)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Dashes = par.(*Stroke).Dashes
			} else if init {
				fs.Dashes = nil
			}
			return
		}
		switch vt := val.(type) {
		case string:
			fs.Dashes = ParseDashesString(vt)
		case []float32:
			mat32.CopyFloat32s(&fs.Dashes, vt)
		case *[]float32:
			mat32.CopyFloat32s(&fs.Dashes, *vt)
		}
	},
	"stroke-linecap": StyleFuncEnum(LineCapButt,
		func(obj *Stroke) enums.EnumSetter { return &(obj.Cap) }),
	"stroke-linejoin": StyleFuncEnum(LineJoinMiter,
		func(obj *Stroke) enums.EnumSetter { return &(obj.Join) }),
	"stroke-miterlimit": StyleFuncFloat(float32(1),
		func(obj *Stroke) *float32 { return &(obj.MiterLimit) }),
}

StyleStrokeFuncs are functions for styling the Stroke object

View Source
var StyleStyleFuncs = map[string]StyleFunc{
	"color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Style)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Color = par.(*Style).Color
			} else if init {
				fs.Color = colors.Black
			}
			return
		}
		fs.Color = grr.Log1(colors.FromAny(val, ctxt.Base()))
	},
	"background-color": func(obj any, key string, val any, par any, ctxt colors.Context) {
		fs := obj.(*Style)
		if inh, init := StyleInhInit(val, par); inh || init {
			if inh {
				fs.Background = par.(*Style).Background
			} else if init {
				fs.Background = nil
			}
			return
		}
		fs.Background = grr.Log1(gradient.FromAny(val, ctxt))
	},
	"opacity": StyleFuncFloat(float32(1),
		func(obj *Style) *float32 { return &obj.Opacity }),
}

StyleStyleFuncs are functions for styling the Style object itself

View Source
var StyleTextFuncs = map[string]StyleFunc{
	"text-align": StyleFuncEnum(Start,
		func(obj *Text) enums.EnumSetter { return &obj.Align }),
	"text-vertical-align": StyleFuncEnum(Start,
		func(obj *Text) enums.EnumSetter { return &obj.AlignV }),
	"text-anchor": StyleFuncEnum(AnchorStart,
		func(obj *Text) enums.EnumSetter { return &obj.Anchor }),
	"letter-spacing": StyleFuncUnits(units.Value{},
		func(obj *Text) *units.Value { return &obj.LetterSpacing }),
	"word-spacing": StyleFuncUnits(units.Value{},
		func(obj *Text) *units.Value { return &obj.WordSpacing }),
	"line-height": StyleFuncUnits(LineHeightNormal,
		func(obj *Text) *units.Value { return &obj.LineHeight }),
	"white-space": StyleFuncEnum(WhiteSpaceNormal,
		func(obj *Text) enums.EnumSetter { return &obj.WhiteSpace }),
	"unicode-bidi": StyleFuncEnum(BidiNormal,
		func(obj *Text) enums.EnumSetter { return &obj.UnicodeBidi }),
	"direction": StyleFuncEnum(LRTB,
		func(obj *Text) enums.EnumSetter { return &obj.Direction }),
	"writing-mode": StyleFuncEnum(LRTB,
		func(obj *Text) enums.EnumSetter { return &obj.WritingMode }),
	"glyph-orientation-vertical": StyleFuncFloat(float32(1),
		func(obj *Text) *float32 { return &obj.OrientationVert }),
	"glyph-orientation-horizontal": StyleFuncFloat(float32(1),
		func(obj *Text) *float32 { return &obj.OrientationHoriz }),
	"text-indent": StyleFuncUnits(units.Value{},
		func(obj *Text) *units.Value { return &obj.Indent }),
	"para-spacing": StyleFuncUnits(units.Value{},
		func(obj *Text) *units.Value { return &obj.ParaSpacing }),
	"tab-size": StyleFuncInt(int(4),
		func(obj *Text) *int { return &obj.TabSize }),
}

StyleTextFuncs are functions for styling the Text object

Functions

func AlignFactor added in v0.0.19

func AlignFactor(al Aligns) float32

func AlignPos added in v0.0.22

func AlignPos(align Aligns, inner, outer float32) float32

AlignPos returns the position offset based on Align.X,Y settings for given inner-sized box within given outer-sized container box.

func ClampMax added in v0.0.20

func ClampMax(v, mx float32) float32

ClampMax returns given value, not greater than given max _only if_ max > 0

func ClampMaxVec added in v0.0.20

func ClampMaxVec(v, mx mat32.Vec2) mat32.Vec2

ClampMaxVec returns given Vec2 values, not greater than given max _only if_ max > 0

func ClampMin added in v0.0.20

func ClampMin(v, mn float32) float32

ClampMin returns given value, not less than given min _only if_ min > 0

func ClampMinVec added in v0.0.20

func ClampMinVec(v, mn mat32.Vec2) mat32.Vec2

ClampMinVec returns given Vec2 values, not less than given min _only if_ min > 0

func FixFontMods

func FixFontMods(fn string) string

FixFontMods ensures that standard font modifiers have a space in front of them, and that the default is not in the name -- used for regularizing font names.

func FontNameFromMods

func FontNameFromMods(basenm string, str FontStretch, wt FontWeights, sty FontStyles) string

FontNameFromMods generates the appropriate regularized file name based on base name and modifiers

func FontNameToMods

func FontNameToMods(fn string) (basenm string, str FontStretch, wt FontWeights, sty FontStyles)

FontNameToMods parses the regularized font name and returns the appropriate base name and associated font mods.

func ParseDashesString

func ParseDashesString(str string) []float32

ParseDashesString gets a dash slice from given string

func SetClampMax added in v0.0.20

func SetClampMax(v *float32, mx float32)

SetClampMax ensures the given value is not greater than given max _only if_ max > 0

func SetClampMaxVec added in v0.0.20

func SetClampMaxVec(v *mat32.Vec2, mx mat32.Vec2)

SetClampMaxVec ensures the given Vec2 values are not greater than given max _only if_ max > 0

func SetClampMin added in v0.0.20

func SetClampMin(v *float32, mn float32)

SetClampMin ensures the given value is not less than given min _only if_ min > 0

func SetClampMinVec added in v0.0.20

func SetClampMinVec(v *mat32.Vec2, mn mat32.Vec2)

SetClampMinVec ensures the given Vec2 values are not less than given min _only if_ min > 0

func SetStylePropsXML

func SetStylePropsXML(style string, props *map[string]any)

SetStylePropsXML sets style props from XML style string, which contains ';' separated name: value pairs

func StyleInhInit

func StyleInhInit(val, par any) (inh, init bool)

StyleInhInit detects the style values of "inherit" and "initial", setting the corresponding bool return values

func StylePropsXML

func StylePropsXML(props map[string]any) string

StylePropsXML returns style props for XML style string, which contains ';' separated name: value pairs

func StyleSetError

func StyleSetError(key string, val any, err error)

StyleSetError reports that cannot set property of given key with given value due to given error

func SubProps

func SubProps(prp map[string]any, selector string) (map[string]any, bool)

SubProps returns a sub-property map from given prop map for a given styling selector (property name) -- e.g., :normal :active :hover etc -- returns false if not found

Types

type AlignSet added in v0.0.22

type AlignSet struct {
	// Content specifies the distribution of the entire collection of items within
	// any larger amount of space allocated to the container.  By contrast, Items
	// and Self specify distribution within the individual element's allocated space.
	Content Aligns

	// Items specifies the distribution within the individual element's allocated space,
	// as a default for all items within a collection.
	Items Aligns

	// Self specifies the distribution within the individual element's allocated space,
	// for this specific item.  Auto defaults to containers Items setting.
	Self Aligns
}

AlignSet specifies the 3 levels of Justify or Align: Content, Items, and Self

func (*AlignSet) Defaults added in v0.0.22

func (as *AlignSet) Defaults()

type Aligns added in v0.0.22

type Aligns int32 //enums:enum

Aligns has all different types of alignment and justification.

const (
	// Auto means the item uses the container's AlignItems value
	Auto Aligns = iota

	// Align items to the start (top, left) of layout
	Start

	// Align items to the end (bottom, right) of layout
	End

	// Align items centered
	Center

	// Align to text baselines
	Baseline

	// First and last are flush, equal space between remaining items
	SpaceBetween

	// First and last have 1/2 space at edges, full space between remaining items
	SpaceAround

	// Equal space at start, end, and between all items
	SpaceEvenly
)
const AlignsN Aligns = 8

AlignsN is the highest valid value for type Aligns, plus one.

func AlignsValues added in v0.0.22

func AlignsValues() []Aligns

AlignsValues returns all possible values for the type Aligns.

func ItemAlign added in v0.0.22

func ItemAlign(parItems, self Aligns) Aligns

ItemAlign returns the effective Aligns value between parent Items and Self

func (Aligns) Desc added in v0.0.22

func (i Aligns) Desc() string

Desc returns the description of the Aligns value.

func (Aligns) Int64 added in v0.0.22

func (i Aligns) Int64() int64

Int64 returns the Aligns value as an int64.

func (Aligns) IsValid added in v0.0.22

func (i Aligns) IsValid() bool

IsValid returns whether the value is a valid option for type Aligns.

func (Aligns) MarshalText added in v0.0.22

func (i Aligns) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Aligns) SetInt64 added in v0.0.22

func (i *Aligns) SetInt64(in int64)

SetInt64 sets the Aligns value from an int64.

func (*Aligns) SetString added in v0.0.22

func (i *Aligns) SetString(s string) error

SetString sets the Aligns value from its string representation, and returns an error if the string is invalid.

func (Aligns) String added in v0.0.22

func (i Aligns) String() string

String returns the string representation of this Aligns value.

func (*Aligns) UnmarshalText added in v0.0.22

func (i *Aligns) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Aligns) Values added in v0.0.22

func (i Aligns) Values() []enums.Enum

Values returns all possible values for the type Aligns.

type BaselineShifts

type BaselineShifts int32 //enums:enum -trim-prefix Shift

BaselineShifts are for super / sub script

const (
	ShiftBaseline BaselineShifts = iota
	ShiftSuper
	ShiftSub
)
const BaselineShiftsN BaselineShifts = 3

BaselineShiftsN is the highest valid value for type BaselineShifts, plus one.

func BaselineShiftsValues

func BaselineShiftsValues() []BaselineShifts

BaselineShiftsValues returns all possible values for the type BaselineShifts.

func (BaselineShifts) Desc

func (i BaselineShifts) Desc() string

Desc returns the description of the BaselineShifts value.

func (BaselineShifts) Int64

func (i BaselineShifts) Int64() int64

Int64 returns the BaselineShifts value as an int64.

func (BaselineShifts) IsValid

func (i BaselineShifts) IsValid() bool

IsValid returns whether the value is a valid option for type BaselineShifts.

func (BaselineShifts) MarshalText

func (i BaselineShifts) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*BaselineShifts) SetInt64

func (i *BaselineShifts) SetInt64(in int64)

SetInt64 sets the BaselineShifts value from an int64.

func (*BaselineShifts) SetString

func (i *BaselineShifts) SetString(s string) error

SetString sets the BaselineShifts value from its string representation, and returns an error if the string is invalid.

func (BaselineShifts) String

func (i BaselineShifts) String() string

String returns the string representation of this BaselineShifts value.

func (*BaselineShifts) UnmarshalText

func (i *BaselineShifts) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (BaselineShifts) Values

func (i BaselineShifts) Values() []enums.Enum

Values returns all possible values for the type BaselineShifts.

type Border

type Border struct {

	// prop: border-style = how to draw the border
	Style Sides[BorderStyles] `xml:"style"`

	// prop: border-width = width of the border
	Width SideValues `xml:"width" view:"inline"`

	// prop: border-radius = rounding of the corners
	Radius SideValues `xml:"radius" view:"inline"`

	// prop: border-color = color of the border
	Color SideColors `xml:"color" view:"inline"`
}

Border contains style parameters for borders

func (*Border) ToDots

func (bs *Border) ToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type BorderStyles

type BorderStyles int32 //enums:enum -trim-prefix Border

BorderStyles determines how to draw the border

const (
	BorderSolid BorderStyles = iota
	BorderDotted
	BorderDashed
	BorderDouble
	BorderGroove
	BorderRidge
	BorderInset
	BorderOutset
	BorderNone
	BorderHidden
)
const BorderStylesN BorderStyles = 10

BorderStylesN is the highest valid value for type BorderStyles, plus one.

func BorderStylesValues

func BorderStylesValues() []BorderStyles

BorderStylesValues returns all possible values for the type BorderStyles.

func (BorderStyles) Desc

func (i BorderStyles) Desc() string

Desc returns the description of the BorderStyles value.

func (BorderStyles) Int64

func (i BorderStyles) Int64() int64

Int64 returns the BorderStyles value as an int64.

func (BorderStyles) IsValid

func (i BorderStyles) IsValid() bool

IsValid returns whether the value is a valid option for type BorderStyles.

func (BorderStyles) MarshalText

func (i BorderStyles) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*BorderStyles) SetInt64

func (i *BorderStyles) SetInt64(in int64)

SetInt64 sets the BorderStyles value from an int64.

func (*BorderStyles) SetString

func (i *BorderStyles) SetString(s string) error

SetString sets the BorderStyles value from its string representation, and returns an error if the string is invalid.

func (BorderStyles) String

func (i BorderStyles) String() string

String returns the string representation of this BorderStyles value.

func (*BorderStyles) UnmarshalText

func (i *BorderStyles) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (BorderStyles) Values

func (i BorderStyles) Values() []enums.Enum

Values returns all possible values for the type BorderStyles.

type Directions added in v0.0.22

type Directions int32 //enums:enum

Direction specifies which way items are laid out.

const (
	Row Directions = iota
	Column
)
const DirectionsN Directions = 2

DirectionsN is the highest valid value for type Directions, plus one.

func DirectionsValues added in v0.0.22

func DirectionsValues() []Directions

DirectionsValues returns all possible values for the type Directions.

func (Directions) Desc added in v0.0.22

func (i Directions) Desc() string

Desc returns the description of the Directions value.

func (Directions) Dim added in v0.0.22

func (d Directions) Dim() mat32.Dims

func (Directions) Int64 added in v0.0.22

func (i Directions) Int64() int64

Int64 returns the Directions value as an int64.

func (Directions) IsValid added in v0.0.22

func (i Directions) IsValid() bool

IsValid returns whether the value is a valid option for type Directions.

func (Directions) MarshalText added in v0.0.22

func (i Directions) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Directions) SetInt64 added in v0.0.22

func (i *Directions) SetInt64(in int64)

SetInt64 sets the Directions value from an int64.

func (*Directions) SetString added in v0.0.22

func (i *Directions) SetString(s string) error

SetString sets the Directions value from its string representation, and returns an error if the string is invalid.

func (Directions) String added in v0.0.22

func (i Directions) String() string

String returns the string representation of this Directions value.

func (*Directions) UnmarshalText added in v0.0.22

func (i *Directions) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Directions) Values added in v0.0.22

func (i Directions) Values() []enums.Enum

Values returns all possible values for the type Directions.

type Displays added in v0.0.22

type Displays int32 //enums:enum -trim-prefix Display

Displays determines how items are displayed

const (
	// Flex is the default layout model, based on a simplified version of the
	// CSS flex layout: uses MainAxis to specify the direction, Wrap for
	// wrapping of elements, and Min, Max, and Grow values on elements to
	// determine sizing.
	Flex Displays = iota

	// Stacked is a stack of elements, with one on top that is visible
	Stacked

	// Grid is the X, Y grid layout, with Columns specifying the number
	// of elements in the X axis.
	Grid

	// NoLayout means that no automatic layout will be applied to elements,
	// which can then be managed via custom code.
	NoLayout

	// None means the item is not displayed: sets the Invisible state
	DisplayNone
)
const DisplaysN Displays = 5

DisplaysN is the highest valid value for type Displays, plus one.

func DisplaysValues added in v0.0.22

func DisplaysValues() []Displays

DisplaysValues returns all possible values for the type Displays.

func (Displays) Desc added in v0.0.22

func (i Displays) Desc() string

Desc returns the description of the Displays value.

func (Displays) Int64 added in v0.0.22

func (i Displays) Int64() int64

Int64 returns the Displays value as an int64.

func (Displays) IsValid added in v0.0.22

func (i Displays) IsValid() bool

IsValid returns whether the value is a valid option for type Displays.

func (Displays) MarshalText added in v0.0.22

func (i Displays) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Displays) SetInt64 added in v0.0.22

func (i *Displays) SetInt64(in int64)

SetInt64 sets the Displays value from an int64.

func (*Displays) SetString added in v0.0.22

func (i *Displays) SetString(s string) error

SetString sets the Displays value from its string representation, and returns an error if the string is invalid.

func (Displays) String added in v0.0.22

func (i Displays) String() string

String returns the string representation of this Displays value.

func (*Displays) UnmarshalText added in v0.0.22

func (i *Displays) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Displays) Values added in v0.0.22

func (i Displays) Values() []enums.Enum

Values returns all possible values for the type Displays.

type Fill

type Fill struct {

	// prop: fill = fill color image specification; filling is off if nil
	Color image.Image `xml:"fill"`

	// prop: fill-opacity = global alpha opacity / transparency factor between 0 and 1
	Opacity float32 `xml:"fill-opacity"`

	// prop: fill-rule = rule for how to fill more complex shapes with crossing lines
	Rule FillRules `xml:"fill-rule"`
}

Fill contains all the properties for filling a region

func (*Fill) Defaults

func (pf *Fill) Defaults()

Defaults initializes default values for paint fill

func (*Fill) ToDots

func (fs *Fill) ToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type FillRules

type FillRules int32 //enums:enum -trim-prefix FillRule
const (
	FillRuleNonZero FillRules = iota
	FillRuleEvenOdd
)
const FillRulesN FillRules = 2

FillRulesN is the highest valid value for type FillRules, plus one.

func FillRulesValues

func FillRulesValues() []FillRules

FillRulesValues returns all possible values for the type FillRules.

func (FillRules) Desc

func (i FillRules) Desc() string

Desc returns the description of the FillRules value.

func (FillRules) Int64

func (i FillRules) Int64() int64

Int64 returns the FillRules value as an int64.

func (FillRules) IsValid

func (i FillRules) IsValid() bool

IsValid returns whether the value is a valid option for type FillRules.

func (FillRules) MarshalText

func (i FillRules) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FillRules) SetInt64

func (i *FillRules) SetInt64(in int64)

SetInt64 sets the FillRules value from an int64.

func (*FillRules) SetString

func (i *FillRules) SetString(s string) error

SetString sets the FillRules value from its string representation, and returns an error if the string is invalid.

func (FillRules) String

func (i FillRules) String() string

String returns the string representation of this FillRules value.

func (*FillRules) UnmarshalText

func (i *FillRules) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FillRules) Values

func (i FillRules) Values() []enums.Enum

Values returns all possible values for the type FillRules.

type Font

type Font struct {

	// prop: font-size (inherited) = size of font to render -- convert to points when getting font to use
	Size units.Value `xml:"font-size" inherit:"true"`

	// prop: font-family = font family -- ordered list of comma-separated names from more general to more specific to use -- use split on , to parse
	Family string `xml:"font-family" inherit:"true"`

	// prop: font-style (inherited) = style -- normal, italic, etc
	Style FontStyles `xml:"font-style" inherit:"true"`

	// prop: font-weight (inherited) = weight: normal, bold, etc
	Weight FontWeights `xml:"font-weight" inherit:"true"`

	// prop: font-stretch = font stretch / condense options
	Stretch FontStretch `xml:"font-stretch" inherit:"true"`

	// prop: font-variant = normal or small caps
	Variant FontVariants `xml:"font-variant" inherit:"true"`

	// prop: text-decoration = underline, line-through, etc -- not inherited
	Deco TextDecorations `xml:"text-decoration"`

	// prop: baseline-shift = super / sub script -- not inherited
	Shift BaselineShifts `xml:"baseline-shift"`

	// full font information including enhanced metrics and actual font codes for drawing text -- this is a pointer into FontLibrary of loaded fonts
	Face *FontFace `view:"-"`
}

Font contains all font styling information. Most of font information is inherited. Font does not include all information needed for rendering -- see FontRender for that.

func (*Font) Defaults

func (fs *Font) Defaults()

func (*Font) InheritFields

func (fs *Font) InheritFields(par *Font)

InheritFields from parent: Manual inheriting of values is much faster than automatic version!

func (*Font) SetDeco

func (fs *Font) SetDeco(deco TextDecorations)

SetDeco sets decoration (underline, etc), which uses bitflag to allow multiple combinations

func (*Font) SetStyleProps

func (fs *Font) SetStyleProps(parent *Font, props map[string]any, ctxt colors.Context)

SetStyleProps sets font style values based on given property map (name: value pairs), inheriting elements as appropriate from parent, and also having a default style for the "initial" setting.

func (*Font) SetUnitContext

func (fs *Font) SetUnitContext(ctxt *units.Context)

SetUnitContext sets the font-specific information in the given units.Context, based on the currently-loaded face.

func (*Font) StyleFromProps

func (fs *Font) StyleFromProps(par *Font, props map[string]any, ctxt colors.Context)

func (*Font) ToDots

func (fs *Font) ToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type FontFace

type FontFace struct {

	// The full FaceName that the font is accessed by
	Name string

	// The integer font size in raw dots
	Size int

	// The system image.Font font rendering interface
	Face font.Face

	// enhanced metric information for the font
	Metrics FontMetrics
}

FontFace is our enhanced Font Face structure which contains the enhanced computed metrics in addition to the font.Face face

func NewFontFace

func NewFontFace(nm string, sz int, face font.Face) *FontFace

NewFontFace returns a new font face

func (*FontFace) ComputeMetrics

func (fs *FontFace) ComputeMetrics()

ComputeMetrics computes the Height, Em, Ex, Ch and Rem metrics associated with current font and overall units context

type FontMetrics

type FontMetrics struct {

	// reference 1.0 spacing line height of font in dots -- computed from font as ascent + descent + lineGap, where lineGap is specified by the font as the recommended line spacing
	Height float32

	// Em size of font -- this is NOT actually the width of the letter M, but rather the specified point size of the font (in actual display dots, not points) -- it does NOT include the descender and will not fit the entire height of the font
	Em float32

	// Ex size of font -- this is the actual height of the letter x in the font
	Ex float32

	// Ch size of font -- this is the actual width of the 0 glyph in the font
	Ch float32
}

FontMetrics are our enhanced dot-scale font metrics compared to what is available in the standard font.Metrics lib, including Ex and Ch being defined in terms of the actual letter x and 0

type FontRender

type FontRender struct {
	Font

	// prop: color (inherited) = text color -- also defines the currentColor variable value
	Color color.RGBA `xml:"color" inherit:"true"`

	// prop: background-color = background color -- not inherited, transparent by default
	Background image.Image `xml:"background-color"`

	// prop: opacity = alpha value between 0 and 1 to apply to the foreground and background of this element and all of its children
	Opacity float32 `xml:"opacity"`
}

FontRender contains all font styling information that is needed for SVG text rendering. It is passed to Paint and Style functions. It should typically not be used by end-user code -- see Font for that. It stores all values as pointers so that they correspond to the values of the style object it was derived from.

func (*FontRender) Defaults

func (fr *FontRender) Defaults()

func (*FontRender) InheritFields

func (fr *FontRender) InheritFields(par *FontRender)

InheritFields from parent

func (*FontRender) SetStyleProps

func (fr *FontRender) SetStyleProps(parent *FontRender, props map[string]any, ctxt colors.Context)

SetStyleProps sets font style values based on given property map (name: value pairs), inheriting elements as appropriate from parent, and also having a default style for the "initial" setting.

func (*FontRender) StyleRenderFromProps

func (fs *FontRender) StyleRenderFromProps(par *FontRender, props map[string]any, ctxt colors.Context)

type FontStretch

type FontStretch int32 //enums:enum -trim-prefix FontStr

FontStretch are different stretch levels of font. These are less typically available on most platforms by default.

const (
	FontStrNormal FontStretch = iota
	FontStrUltraCondensed
	FontStrExtraCondensed
	FontStrSemiCondensed
	FontStrSemiExpanded
	FontStrExtraExpanded
	FontStrUltraExpanded
	FontStrCondensed
	FontStrExpanded
	FontStrNarrower
	FontStrWider
)
const FontStretchN FontStretch = 11

FontStretchN is the highest valid value for type FontStretch, plus one.

func FontStretchValues

func FontStretchValues() []FontStretch

FontStretchValues returns all possible values for the type FontStretch.

func (FontStretch) Desc

func (i FontStretch) Desc() string

Desc returns the description of the FontStretch value.

func (FontStretch) Int64

func (i FontStretch) Int64() int64

Int64 returns the FontStretch value as an int64.

func (FontStretch) IsValid

func (i FontStretch) IsValid() bool

IsValid returns whether the value is a valid option for type FontStretch.

func (FontStretch) MarshalText

func (i FontStretch) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FontStretch) SetInt64

func (i *FontStretch) SetInt64(in int64)

SetInt64 sets the FontStretch value from an int64.

func (*FontStretch) SetString

func (i *FontStretch) SetString(s string) error

SetString sets the FontStretch value from its string representation, and returns an error if the string is invalid.

func (FontStretch) String

func (i FontStretch) String() string

String returns the string representation of this FontStretch value.

func (*FontStretch) UnmarshalText

func (i *FontStretch) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FontStretch) Values

func (i FontStretch) Values() []enums.Enum

Values returns all possible values for the type FontStretch.

type FontStyles

type FontStyles int32 //enums:enum -trim-prefix Font

FontStyles styles of font: normal, italic, etc

const (
	FontNormal FontStyles = iota
	FontItalic
	FontOblique
)
const FontStylesN FontStyles = 3

FontStylesN is the highest valid value for type FontStyles, plus one.

func FontStylesValues

func FontStylesValues() []FontStyles

FontStylesValues returns all possible values for the type FontStyles.

func (FontStyles) Desc

func (i FontStyles) Desc() string

Desc returns the description of the FontStyles value.

func (FontStyles) Int64

func (i FontStyles) Int64() int64

Int64 returns the FontStyles value as an int64.

func (FontStyles) IsValid

func (i FontStyles) IsValid() bool

IsValid returns whether the value is a valid option for type FontStyles.

func (FontStyles) MarshalText

func (i FontStyles) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FontStyles) SetInt64

func (i *FontStyles) SetInt64(in int64)

SetInt64 sets the FontStyles value from an int64.

func (*FontStyles) SetString

func (i *FontStyles) SetString(s string) error

SetString sets the FontStyles value from its string representation, and returns an error if the string is invalid.

func (FontStyles) String

func (i FontStyles) String() string

String returns the string representation of this FontStyles value.

func (*FontStyles) UnmarshalText

func (i *FontStyles) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FontStyles) Values

func (i FontStyles) Values() []enums.Enum

Values returns all possible values for the type FontStyles.

type FontVariants

type FontVariants int32 //enums:enum -trim-prefix FontVar

FontVariants is just normal vs. small caps. todo: not currently supported

const (
	FontVarNormal FontVariants = iota
	FontVarSmallCaps
)
const FontVariantsN FontVariants = 2

FontVariantsN is the highest valid value for type FontVariants, plus one.

func FontVariantsValues

func FontVariantsValues() []FontVariants

FontVariantsValues returns all possible values for the type FontVariants.

func (FontVariants) Desc

func (i FontVariants) Desc() string

Desc returns the description of the FontVariants value.

func (FontVariants) Int64

func (i FontVariants) Int64() int64

Int64 returns the FontVariants value as an int64.

func (FontVariants) IsValid

func (i FontVariants) IsValid() bool

IsValid returns whether the value is a valid option for type FontVariants.

func (FontVariants) MarshalText

func (i FontVariants) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FontVariants) SetInt64

func (i *FontVariants) SetInt64(in int64)

SetInt64 sets the FontVariants value from an int64.

func (*FontVariants) SetString

func (i *FontVariants) SetString(s string) error

SetString sets the FontVariants value from its string representation, and returns an error if the string is invalid.

func (FontVariants) String

func (i FontVariants) String() string

String returns the string representation of this FontVariants value.

func (*FontVariants) UnmarshalText

func (i *FontVariants) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FontVariants) Values

func (i FontVariants) Values() []enums.Enum

Values returns all possible values for the type FontVariants.

type FontWeights

type FontWeights int32 //enums:enum -trim-prefix Weight -no-line-comment

FontWeights are the valid names for different weights of font, with both the numeric and standard names given. The regularized font names in the font library use the names, as those are typically found in the font files.

const (
	WeightNormal FontWeights = iota
	Weight100
	WeightThin // (Hairline)
	Weight200
	WeightExtraLight // (UltraLight)
	Weight300
	WeightLight
	Weight400
	Weight500
	WeightMedium
	Weight600
	WeightSemiBold // (DemiBold)
	Weight700
	WeightBold
	Weight800
	WeightExtraBold // (UltraBold)
	Weight900
	WeightBlack
	WeightBolder
	WeightLighter
)
const FontWeightsN FontWeights = 20

FontWeightsN is the highest valid value for type FontWeights, plus one.

func FontWeightsValues

func FontWeightsValues() []FontWeights

FontWeightsValues returns all possible values for the type FontWeights.

func (FontWeights) Desc

func (i FontWeights) Desc() string

Desc returns the description of the FontWeights value.

func (FontWeights) Int64

func (i FontWeights) Int64() int64

Int64 returns the FontWeights value as an int64.

func (FontWeights) IsValid

func (i FontWeights) IsValid() bool

IsValid returns whether the value is a valid option for type FontWeights.

func (FontWeights) MarshalText

func (i FontWeights) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FontWeights) SetInt64

func (i *FontWeights) SetInt64(in int64)

SetInt64 sets the FontWeights value from an int64.

func (*FontWeights) SetString

func (i *FontWeights) SetString(s string) error

SetString sets the FontWeights value from its string representation, and returns an error if the string is invalid.

func (FontWeights) String

func (i FontWeights) String() string

String returns the string representation of this FontWeights value.

func (*FontWeights) UnmarshalText

func (i *FontWeights) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FontWeights) Values

func (i FontWeights) Values() []enums.Enum

Values returns all possible values for the type FontWeights.

type LineCaps

type LineCaps int32 //enums:enum -trim-prefix LineCap

end-cap of a line: stroke-linecap property in SVG

const (
	LineCapButt LineCaps = iota
	LineCapRound
	LineCapSquare
	// rasterx extension
	LineCapCubic
	// rasterx extension
	LineCapQuadratic
)
const LineCapsN LineCaps = 5

LineCapsN is the highest valid value for type LineCaps, plus one.

func LineCapsValues

func LineCapsValues() []LineCaps

LineCapsValues returns all possible values for the type LineCaps.

func (LineCaps) Desc

func (i LineCaps) Desc() string

Desc returns the description of the LineCaps value.

func (LineCaps) Int64

func (i LineCaps) Int64() int64

Int64 returns the LineCaps value as an int64.

func (LineCaps) IsValid

func (i LineCaps) IsValid() bool

IsValid returns whether the value is a valid option for type LineCaps.

func (LineCaps) MarshalText

func (i LineCaps) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*LineCaps) SetInt64

func (i *LineCaps) SetInt64(in int64)

SetInt64 sets the LineCaps value from an int64.

func (*LineCaps) SetString

func (i *LineCaps) SetString(s string) error

SetString sets the LineCaps value from its string representation, and returns an error if the string is invalid.

func (LineCaps) String

func (i LineCaps) String() string

String returns the string representation of this LineCaps value.

func (*LineCaps) UnmarshalText

func (i *LineCaps) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (LineCaps) Values

func (i LineCaps) Values() []enums.Enum

Values returns all possible values for the type LineCaps.

type LineJoins

type LineJoins int32 //enums:enum -trim-prefix LineJoin

the way in which lines are joined together: stroke-linejoin property in SVG

const (
	LineJoinMiter LineJoins = iota
	LineJoinMiterClip
	LineJoinRound
	LineJoinBevel
	LineJoinArcs
	// rasterx extension
	LineJoinArcsClip
)
const LineJoinsN LineJoins = 6

LineJoinsN is the highest valid value for type LineJoins, plus one.

func LineJoinsValues

func LineJoinsValues() []LineJoins

LineJoinsValues returns all possible values for the type LineJoins.

func (LineJoins) Desc

func (i LineJoins) Desc() string

Desc returns the description of the LineJoins value.

func (LineJoins) Int64

func (i LineJoins) Int64() int64

Int64 returns the LineJoins value as an int64.

func (LineJoins) IsValid

func (i LineJoins) IsValid() bool

IsValid returns whether the value is a valid option for type LineJoins.

func (LineJoins) MarshalText

func (i LineJoins) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*LineJoins) SetInt64

func (i *LineJoins) SetInt64(in int64)

SetInt64 sets the LineJoins value from an int64.

func (*LineJoins) SetString

func (i *LineJoins) SetString(s string) error

SetString sets the LineJoins value from its string representation, and returns an error if the string is invalid.

func (LineJoins) String

func (i LineJoins) String() string

String returns the string representation of this LineJoins value.

func (*LineJoins) UnmarshalText

func (i *LineJoins) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (LineJoins) Values

func (i LineJoins) Values() []enums.Enum

Values returns all possible values for the type LineJoins.

type ObjectFits added in v0.0.22

type ObjectFits int32 //enums:enum -trim-prefix Fit

ObjectFits are the different ways in which a replaced element (image, video, etc) can be fit into its containing box.

const (
	// FitFill indicates that the replaced object will fill
	// the element's entire content box, stretching if necessary.
	FitFill ObjectFits = iota

	// FitContain indicates that the replaced object will resize
	// as large as possible while fully fitting within the element's
	// content box and maintaining its aspect ratio. Therefore,
	// it may not fill the entire element.
	FitContain

	// FitCover indicates that the replaced object will fill
	// the element's entire content box, clipping if necessary.
	FitCover

	// FitNone indicates that the replaced object will not resize.
	FitNone

	// FitScaleDown indicates that the replaced object will size
	// as if [FitNone] or [FitContain] was specified, using
	// whichever will result in a smaller final size.
	FitScaleDown
)
const ObjectFitsN ObjectFits = 5

ObjectFitsN is the highest valid value for type ObjectFits, plus one.

func ObjectFitsValues added in v0.0.22

func ObjectFitsValues() []ObjectFits

ObjectFitsValues returns all possible values for the type ObjectFits.

func (ObjectFits) Desc added in v0.0.22

func (i ObjectFits) Desc() string

Desc returns the description of the ObjectFits value.

func (ObjectFits) Int64 added in v0.0.22

func (i ObjectFits) Int64() int64

Int64 returns the ObjectFits value as an int64.

func (ObjectFits) IsValid added in v0.0.22

func (i ObjectFits) IsValid() bool

IsValid returns whether the value is a valid option for type ObjectFits.

func (ObjectFits) MarshalText added in v0.0.22

func (i ObjectFits) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*ObjectFits) SetInt64 added in v0.0.22

func (i *ObjectFits) SetInt64(in int64)

SetInt64 sets the ObjectFits value from an int64.

func (*ObjectFits) SetString added in v0.0.22

func (i *ObjectFits) SetString(s string) error

SetString sets the ObjectFits value from its string representation, and returns an error if the string is invalid.

func (ObjectFits) String added in v0.0.22

func (i ObjectFits) String() string

String returns the string representation of this ObjectFits value.

func (*ObjectFits) UnmarshalText added in v0.0.22

func (i *ObjectFits) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ObjectFits) Values added in v0.0.22

func (i ObjectFits) Values() []enums.Enum

Values returns all possible values for the type ObjectFits.

type Overflows added in v0.0.22

type Overflows int32 //enums:enum -trim-prefix Overflow

overflow type -- determines what happens when there is too much stuff in a layout

const (
	// OverflowVisible makes the overflow visible, meaning that the size
	// of the container is always at least the Min size of its contents.
	// No scrollbars are shown.
	OverflowVisible Overflows = iota

	// OverflowHidden hides the overflow and doesn't present scrollbars.
	OverflowHidden

	// OverflowAuto automatically determines if scrollbars should be added to show
	// the overflow.  Scrollbars are added only if the actual content size is greater
	// than the currently available size.
	OverflowAuto

	// OverflowScroll means that scrollbars are always visible,
	// and is otherwise identical to Auto.  However, only during Viewport PrefSize call,
	// the actual content size is used -- otherwise it behaves just like Auto.
	OverflowScroll
)
const OverflowsN Overflows = 4

OverflowsN is the highest valid value for type Overflows, plus one.

func OverflowsValues added in v0.0.22

func OverflowsValues() []Overflows

OverflowsValues returns all possible values for the type Overflows.

func (Overflows) Desc added in v0.0.22

func (i Overflows) Desc() string

Desc returns the description of the Overflows value.

func (Overflows) Int64 added in v0.0.22

func (i Overflows) Int64() int64

Int64 returns the Overflows value as an int64.

func (Overflows) IsValid added in v0.0.22

func (i Overflows) IsValid() bool

IsValid returns whether the value is a valid option for type Overflows.

func (Overflows) MarshalText added in v0.0.22

func (i Overflows) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Overflows) SetInt64 added in v0.0.22

func (i *Overflows) SetInt64(in int64)

SetInt64 sets the Overflows value from an int64.

func (*Overflows) SetString added in v0.0.22

func (i *Overflows) SetString(s string) error

SetString sets the Overflows value from its string representation, and returns an error if the string is invalid.

func (Overflows) String added in v0.0.22

func (i Overflows) String() string

String returns the string representation of this Overflows value.

func (*Overflows) UnmarshalText added in v0.0.22

func (i *Overflows) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Overflows) Values added in v0.0.22

func (i Overflows) Values() []enums.Enum

Values returns all possible values for the type Overflows.

type Paint

type Paint struct {

	// prop: display:none -- node and everything below it are off, non-rendering
	Off bool

	// todo big enum of how to display item -- controls layout etc
	Display bool `xml:"display"`

	// stroke (line drawing) parameters
	StrokeStyle Stroke

	// fill (region filling) parameters
	FillStyle Fill

	// font also has global opacity setting, along with generic color, background-color settings, which can be copied into stroke / fill as needed
	FontStyle FontRender

	// font also has global opacity setting, along with generic color, background-color settings, which can be copied into stroke / fill as needed
	TextStyle Text

	// prop: vector-effect = various rendering special effects settings
	VecEff VectorEffects `xml:"vector-effect"`

	// prop: transform = our additions to transform -- pushed to render state
	Transform mat32.Mat2 `xml:"transform"`

	// units context -- parameters necessary for anchoring relative units
	UnContext units.Context `xml:"-"`

	// have the styles already been set?
	StyleSet bool

	PropsNil bool
	// contains filtered or unexported fields
}

Paint provides the styling parameters for SVG-style rendering

func (*Paint) CopyStyleFrom

func (pc *Paint) CopyStyleFrom(cp *Paint)

CopyStyleFrom copies styles from another paint

func (*Paint) Defaults

func (pc *Paint) Defaults()

func (*Paint) FromStyle added in v0.0.28

func (pc *Paint) FromStyle(st *Style)

func (*Paint) InheritFields

func (pc *Paint) InheritFields(par *Paint)

InheritFields from parent: Manual inheriting of values is much faster than automatic version!

func (*Paint) SetStyleProps

func (pc *Paint) SetStyleProps(par *Paint, props map[string]any, ctxt colors.Context)

SetStyleProps sets paint values based on given property map (name: value pairs), inheriting elements as appropriate from parent, and also having a default style for the "initial" setting

func (*Paint) SetUnitContextExt

func (pc *Paint) SetUnitContextExt(size image.Point)

SetUnitContextExt sets the unit context for external usage of paint outside of a Viewport, based on overall size of painting canvas. caches everything out in terms of raw pixel dots for rendering call at start of render.

func (*Paint) StyleFromProps

func (pc *Paint) StyleFromProps(par *Paint, props map[string]any, ctxt colors.Context)

StyleFromProps sets style field values based on map[string]any properties

func (*Paint) ToDots

func (pc *Paint) ToDots()

ToDots runs ToDots on unit values, to compile down to raw pixels

func (*Paint) ToDotsImpl

func (pc *Paint) ToDotsImpl(uc *units.Context)

ToDotsImpl runs ToDots on unit values, to compile down to raw pixels

type SetStringer

type SetStringer interface {
	SetString(str string) error
}

SetStringer is a type that can be set from a string

type Shadow

type Shadow struct {

	// prop: .h-offset = horizontal offset of shadow -- positive = right side, negative = left side
	HOffset units.Value `xml:".h-offset"`

	// prop: .v-offset = vertical offset of shadow -- positive = below, negative = above
	VOffset units.Value `xml:".v-offset"`

	// prop: .blur = blur radius -- higher numbers = more blurry
	Blur units.Value `xml:".blur"`

	// prop: .spread = spread radius -- positive number increases size of shadow, negative decreases size
	Spread units.Value `xml:".spread"`

	// prop: .color = color of the shadow
	Color color.RGBA `xml:".color"`

	// prop: .inset = shadow is inset within box instead of outset outside of box
	Inset bool `xml:".inset"`
}

style parameters for shadows

func BoxShadow0

func BoxShadow0() []Shadow

BoxShadow0 returns the shadows to be used on Elevation 0 elements. There are no shadows part of BoxShadow0, so applying it is purely semantic.

func BoxShadow1

func BoxShadow1() []Shadow

BoxShadow1 contains the shadows to be used on Elevation 1 elements.

func BoxShadow2

func BoxShadow2() []Shadow

BoxShadow2 returns the shadows to be used on Elevation 2 elements.

func BoxShadow3

func BoxShadow3() []Shadow

BoxShadow3 returns the shadows to be used on Elevation 3 elements.

func BoxShadow4

func BoxShadow4() []Shadow

BoxShadow4 returns the shadows to be used on Elevation 4 elements.

func BoxShadow5

func BoxShadow5() []Shadow

BoxShadow5 returns the shadows to be used on Elevation 5 elements.

func (*Shadow) BasePos

func (s *Shadow) BasePos(startPos mat32.Vec2) mat32.Vec2

BasePos returns the position at which the base box shadow (the actual solid, unblurred box part) should be rendered if the shadow is on an element with the given starting position.

func (*Shadow) BaseSize

func (s *Shadow) BaseSize(startSize mat32.Vec2) mat32.Vec2

BaseSize returns the total size the base box shadow (the actual solid, unblurred part) should be if the shadow is on an element with the given starting size.

func (*Shadow) HasShadow

func (s *Shadow) HasShadow() bool

func (*Shadow) Margin

func (s *Shadow) Margin() SideFloats

Margin returns the effective margin created by the shadow on each side in terms of raw display dots. It should be added to margin for sizing considerations.

func (*Shadow) Pos

func (s *Shadow) Pos(startPos mat32.Vec2) mat32.Vec2

Pos returns the position at which the blurred box shadow should start if the shadow is on an element with the given starting position.

func (*Shadow) Size

func (s *Shadow) Size(startSize mat32.Vec2) mat32.Vec2

Size returns the total size occupied by the blurred box shadow if the shadow is on an element with the given starting size.

func (*Shadow) ToDots

func (s *Shadow) ToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type SideColors

type SideColors struct {
	Sides[color.RGBA]
}

SideColors contains color values for each side/corner of a box

func NewSideColors

func NewSideColors(vals ...color.RGBA) SideColors

NewSideColors is a helper that creates new side/corner colors and calls Set on them with the given values. It does not return any error values and just logs them.

func (SideColors) AllSame

func (s SideColors) AllSame() bool

AllSame returns whether all of the sides/corners are the same

func (SideColors) IsZero

func (s SideColors) IsZero() bool

IsZero returns whether all of the sides/corners are equal to zero

func (*SideColors) SetAny

func (s *SideColors) SetAny(a any, base color.Color) error

SetAny sets the sides/corners from the given value of any type

func (*SideColors) SetString

func (s *SideColors) SetString(str string, base color.Color) error

SetString sets the sides/corners from the given string value

func (*SideColors) Zero added in v0.0.18

func (s *SideColors) Zero() *SideColors

Zero sets the values of all of the sides to zero.

type SideFloats

type SideFloats struct {
	Sides[float32]
}

SideFloats contains float32 values for each side/corner of a box

func BoxShadowMargin

func BoxShadowMargin(shadows []Shadow) SideFloats

BoxShadowMargin returns the maximum effective box shadow margin of the given box shadows, calculated through Shadow.Margin.

func NewSideFloats

func NewSideFloats(vals ...float32) SideFloats

NewSideFloats is a helper that creates new side/corner floats and calls Set on them with the given values.

func (SideFloats) Add

func (sf SideFloats) Add(other SideFloats) SideFloats

Add adds the side floats to the other side floats and returns the result

func (SideFloats) AllSame

func (sf SideFloats) AllSame() bool

AllSame returns whether all of the sides/corners are the same

func (SideFloats) IsZero

func (sf SideFloats) IsZero() bool

IsZero returns whether all of the sides/corners are equal to zero

func (SideFloats) Max

func (sf SideFloats) Max(other SideFloats) SideFloats

Max returns a new side floats containing the maximum values of the two side floats

func (SideFloats) Min

func (sf SideFloats) Min(other SideFloats) SideFloats

Min returns a new side floats containing the minimum values of the two side floats

func (SideFloats) Pos

func (sf SideFloats) Pos() mat32.Vec2

Pos returns the position offset casued by the side/corner values (Left, Top)

func (SideFloats) Size

func (sf SideFloats) Size() mat32.Vec2

Size returns the toal size the side/corner values take up (Left + Right, Top + Bottom)

func (SideFloats) Sub

func (sf SideFloats) Sub(other SideFloats) SideFloats

Sub subtracts the other side floats from the side floats and returns the result

func (SideFloats) ToValues

func (sf SideFloats) ToValues() SideValues

ToValues returns the side floats a SideValues composed of units.UnitDot values

func (*SideFloats) Zero added in v0.0.18

func (sf *SideFloats) Zero() *SideFloats

Zero sets the values of all of the sides to zero.

type SideIndexes added in v0.0.22

type SideIndexes int32 //enums:enum

SideIndexes provides names for the Sides in order defined

const (
	Top SideIndexes = iota
	Right
	Bottom
	Left
)
const SideIndexesN SideIndexes = 4

SideIndexesN is the highest valid value for type SideIndexes, plus one.

func SideIndexesValues added in v0.0.22

func SideIndexesValues() []SideIndexes

SideIndexesValues returns all possible values for the type SideIndexes.

func (SideIndexes) Desc added in v0.0.22

func (i SideIndexes) Desc() string

Desc returns the description of the SideIndexes value.

func (SideIndexes) Int64 added in v0.0.22

func (i SideIndexes) Int64() int64

Int64 returns the SideIndexes value as an int64.

func (SideIndexes) IsValid added in v0.0.22

func (i SideIndexes) IsValid() bool

IsValid returns whether the value is a valid option for type SideIndexes.

func (SideIndexes) MarshalText added in v0.0.22

func (i SideIndexes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*SideIndexes) SetInt64 added in v0.0.22

func (i *SideIndexes) SetInt64(in int64)

SetInt64 sets the SideIndexes value from an int64.

func (*SideIndexes) SetString added in v0.0.22

func (i *SideIndexes) SetString(s string) error

SetString sets the SideIndexes value from its string representation, and returns an error if the string is invalid.

func (SideIndexes) String added in v0.0.22

func (i SideIndexes) String() string

String returns the string representation of this SideIndexes value.

func (*SideIndexes) UnmarshalText added in v0.0.22

func (i *SideIndexes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SideIndexes) Values added in v0.0.22

func (i SideIndexes) Values() []enums.Enum

Values returns all possible values for the type SideIndexes.

type SideValues

type SideValues struct {
	Sides[units.Value]
}

SideValues contains units.Value values for each side/corner of a box

func NewSideValues

func NewSideValues(vals ...units.Value) SideValues

NewSideValues is a helper that creates new side/corner values and calls Set on them with the given values.

func (SideValues) Dots

func (sv SideValues) Dots() SideFloats

Dots returns the dot values of the sides/corners as a SideFloats. It does not compute them; see ToDots for that.

func (*SideValues) ToDots

func (sv *SideValues) ToDots(uc *units.Context) SideFloats

ToDots converts the values for each of the sides/corners to raw display pixels (dots) and sets the Dots field for each of the values. It returns the dot values as a SideFloats.

func (*SideValues) Zero added in v0.0.18

func (sv *SideValues) Zero() *SideValues

Zero sets the values of all of the sides to zero.

type Sides

type Sides[T any] struct {

	// top/top-left value
	Top T `xml:"top"`

	// right/top-right value
	Right T `xml:"right"`

	// bottom/bottom-right value
	Bottom T `xml:"bottom"`

	// left/bottom-left value
	Left T `xml:"left"`
}

Sides contains values for each side or corner of a box. If Sides contains sides, the struct field names correspond directly to the side values (ie: Top = top side value). If Sides contains corners, the struct field names correspond to the corners as follows: Top = top left, Right = top right, Bottom = bottom right, Left = bottom left.

func NewSides

func NewSides[T any](vals ...T) *Sides[T]

NewSides is a helper that creates new sides/corners of the given type and calls Set on them with the given values.

func (*Sides[T]) Set

func (s *Sides[T]) Set(vals ...T) *Sides[T]

Set sets the values of the sides/corners from the given list of 0 to 4 values. If 0 values are provided, all sides/corners are set to the zero value of the type. If 1 value is provided, all sides/corners are set to that value. If 2 values are provided, the top/top-left and bottom/bottom-right are set to the first value and the right/top-right and left/bottom-left are set to the second value. If 3 values are provided, the top/top-left is set to the first value, the right/top-right and left/bottom-left are set to the second value, and the bottom/bottom-right is set to the third value. If 4 values are provided, the top/top-left is set to the first value, the right/top-right is set to the second value, the bottom/bottom-right is set to the third value, and the left/bottom-left is set to the fourth value. If more than 4 values are provided, the behavior is the same as with 4 values, but Set also logs a programmer error. This behavior is based on the CSS multi-side/corner setting syntax, like that with padding and border-radius (see https://www.w3schools.com/css/css_padding.asp and https://www.w3schools.com/cssref/css3_pr_border-radius.php)

func (*Sides[T]) SetAll

func (s *Sides[T]) SetAll(val T) *Sides[T]

SetAll sets the values for all of the sides/corners to the given value

func (*Sides[T]) SetAny

func (s *Sides[T]) SetAny(a any) error

SetAny sets the sides/corners from the given value of any type

func (*Sides[T]) SetBottom

func (s *Sides[T]) SetBottom(bottom T) *Sides[T]

SetBottom sets the bottom side to the given value

func (*Sides[T]) SetHoriz

func (s *Sides[T]) SetHoriz(val T) *Sides[T]

SetHoriz sets the values for the sides/corners in the horizontal/diagonally ascending direction (right/top-right and left/bottom-left) to the given value

func (*Sides[T]) SetLeft

func (s *Sides[T]) SetLeft(left T) *Sides[T]

SetLeft sets the left side to the given value

func (*Sides[T]) SetRight

func (s *Sides[T]) SetRight(right T) *Sides[T]

SetRight sets the right side to the given value

func (*Sides[T]) SetString

func (s *Sides[T]) SetString(str string) error

SetString sets the sides/corners from the given string value

func (*Sides[T]) SetTop

func (s *Sides[T]) SetTop(top T) *Sides[T]

SetTop sets the top side to the given value

func (*Sides[T]) SetVert

func (s *Sides[T]) SetVert(val T) *Sides[T]

SetVert sets the values for the sides/corners in the vertical/diagonally descending direction (top/top-left and bottom/bottom-right) to the given value

type Stroke

type Stroke struct {

	// prop: stroke = stroke color image specification; stroking is off if nil
	Color image.Image `xml:"stroke"`

	// prop: stroke-opacity = global alpha opacity / transparency factor between 0 and 1
	Opacity float32 `xml:"stroke-opacity"`

	// prop: stroke-width = line width
	Width units.Value `xml:"stroke-width"`

	// prop: stroke-min-width = minimum line width used for rendering -- if width is > 0, then this is the smallest line width -- this value is NOT subject to transforms so is in absolute dot values, and is ignored if vector-effects non-scaling-stroke is used -- this is an extension of the SVG / CSS standard
	MinWidth units.Value `xml:"stroke-min-width"`

	// prop: stroke-dasharray = dash pattern, in terms of alternating on and off distances -- e.g., = 4 pixels on, 4 pixels off.  Currently only supporting raw pixel numbers, but in principle should support units.
	Dashes []float32 `xml:"stroke-dasharray"`

	// prop: stroke-linecap = how to draw the end cap of lines
	Cap LineCaps `xml:"stroke-linecap"`

	// prop: stroke-linejoin = how to join line segments
	Join LineJoins `xml:"stroke-linejoin"`

	// prop: stroke-miterlimit = limit of how far to miter -- must be 1 or larger
	MiterLimit float32 `xml:"stroke-miterlimit" min:"1"`
}

Stroke contains all the properties for painting a line

func (*Stroke) Defaults

func (ps *Stroke) Defaults()

Defaults initializes default values for paint stroke

func (*Stroke) ToDots

func (ss *Stroke) ToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type Style

type Style struct {
	// State holds style-relevant state flags, for convenient styling access,
	// given that styles typically depend on element states.
	State states.States

	// Abilities specifies the abilities of this element, which determine
	// which kinds of states the element can express.
	// This is used by the goosi/events system.  Putting this info next
	// to the State info makes it easy to configure and manage.
	Abilities abilities.Abilities

	// the cursor to switch to upon hovering over the element (inherited)
	Cursor cursors.Cursor

	// Padding is the transparent space around central content of box,
	// which is _included_ in the size of the standard box rendering.
	Padding SideValues `view:"inline"`

	// Margin is the outer-most transparent space around box element,
	// which is _excluded_ from standard box rendering.
	Margin SideValues `view:"inline"`

	// Display controls how items are displayed, in terms of layout
	Display Displays

	// Direction specifies the order elements are organized:
	// Row is horizontal, Col is vertical.
	// See also [Wrap]
	Direction Directions

	// Wrap causes elements to wrap around in the CrossAxis dimension
	// to fit within sizing constraints (on by default).
	Wrap bool

	// Justify specifies the distribution of elements along the main axis,
	// i.e., the same as Direction, for Flex Display.  For Grid, the main axis is
	// given by the writing direction (e.g., Row-wise for latin based languages).
	Justify AlignSet `view:"inline"`

	// Align specifies the cross-axis alignment of elements, orthogonal to the
	// main Direction axis. For Grid, the cross-axis is orthogonal to the
	// writing direction (e.g., Column-wise for latin based languages).
	Align AlignSet `view:"inline"`

	// Min is the minimum size of the actual content, exclusive of additional space
	// from padding, border, margin; 0 = default is sum of Min for all content
	// (which _includes_ space for all sub-elements).
	// This is equivalent to the Basis for the CSS flex styling model.
	Min units.XY `view:"inline"`

	// Max is the maximum size of the actual content, exclusive of additional space
	// from padding, border, margin; 0 = default provides no Max size constraint
	Max units.XY `view:"inline"`

	// Grow is the proportional amount that the element can grow (stretch)
	// if there is more space available.  0 = default = no growth.
	// Extra available space is allocated as: Grow / sum (all Grow).
	// Important: grow elements absorb available space and thus are not
	// subject to alignment (Center, End).
	Grow mat32.Vec2

	// GrowWrap is a special case for Text elements where it grows initially
	// in the horizontal axis to allow for longer, word wrapped text to fill
	// the available space, but then it does not grow thereafter, so that alignment
	// operations still work (Grow elements do not align because they absorb all
	// available space).
	GrowWrap bool

	// FillMargin determines is whether to fill the margin with
	// the surrounding background color before rendering the element itself.
	// This is typically necessary to prevent text, border, and box shadow from rendering
	// over themselves. It should be kept at its default value of true
	// in most circumstances, but it can be set to false when the element
	// is fully managed by something that is guaranteed to render the
	// appropriate background color for the element.
	FillMargin bool

	// Overflow determines how to handle overflowing content in a layout.
	// Default is OverflowVisible.  Set to OverflowAuto to enable scrollbars.
	Overflow XY[Overflows]

	// For layouts, extra space added between elements in the layout.
	Gap units.XY `view:"inline"`

	// For grid layouts, the number of columns to use.
	// If > 0, number of rows is computed as N elements / Columns.
	// Used as a constraint in layout if individual elements
	// do not specify their row, column positions
	Columns int

	// If this object is a replaced object (image, video, etc)
	// or has a background image, ObjectFit specifies the way
	// in which the replaced object should be fit into the element.
	ObjectFit ObjectFits

	// Border is a line border around the box element
	Border Border

	// MaxBorder is the largest border that will ever be rendered
	// around the element, the size of which is used for computing
	// the effective margin to allocate for the element.
	MaxBorder Border

	// BoxShadow is the box shadows to render around box (can have multiple)
	BoxShadow []Shadow

	// MaxBoxShadow contains the largest shadows that will ever be rendered
	// around the element, the size of which are used for computing the
	// effective margin to allocate for the element.
	MaxBoxShadow []Shadow

	// Color specifies the text / content color, and it is inherited.
	Color color.RGBA `inherit:"true"`

	// Background specifies the background of the element. It is not inherited,
	// and it is nil (transparent) by default.
	Background image.Image

	// prop: opacity = alpha value between 0 and 1 to apply to the foreground and background of this element and all of its children
	Opacity float32

	// StateLayer, if above zero, indicates to create a state layer over the element with this much opacity (on a scale of 0-1) and the
	// color Color (or StateColor if it defined). It is automatically set based on State, but can be overridden in stylers.
	StateLayer float32

	// StateColor, if not the zero color, is the color to use for the StateLayer instead of Color. If you want to disable state layers
	// for an element, do not use this; instead, set StateLayer to 0.
	StateColor color.RGBA

	// ActualBackground is the computed actual background rendered for the element,
	// taking into account its Background, Opacity, StateLayer, and parent
	// ActualBackground. It is automatically computed and should not be set manually.
	ActualBackground image.Image

	// position is only used for Layout = Nil cases
	Pos units.XY `view:"inline"`

	// ordering factor for rendering depth -- lower numbers rendered first.
	// Sort children according to this factor
	ZIndex int

	// prop: row = specifies the row that this element should appear within a grid layout
	Row int

	// prop: col = specifies the column that this element should appear within a grid layout
	Col int

	// specifies the number of sequential rows that this element should occupy
	// within a grid layout (todo: not currently supported)
	RowSpan int

	// specifies the number of sequential columns that this element should occupy
	// within a grid layout
	ColSpan int

	// width of a layout scrollbar
	ScrollBarWidth units.Value

	// font parameters -- no xml prefix -- also has color, background-color
	Font Font

	// text parameters -- no xml prefix
	Text Text

	// units context -- parameters necessary for anchoring relative units
	UnContext units.Context
}

Style has all the CSS-based style elements -- used for widget-type GUI objects.

var StyleDefault Style

StyleDefault is default style can be used when property specifies "default"

func NewStyle

func NewStyle() *Style

NewStyle returns a new Style object with default values

func (*Style) AbilityIs added in v0.0.28

func (s *Style) AbilityIs(able abilities.Abilities) bool

AbilityIs returns whether the given abilities.Abilities flag is set

func (*Style) AddBoxShadow

func (s *Style) AddBoxShadow(shadow ...Shadow)

AddBoxShadow adds the given box shadows to the style

func (*Style) BoxShadowMargin

func (s *Style) BoxShadowMargin() SideFloats

BoxShadowMargin returns the effective box shadow margin of the style, calculated through Shadow.Margin

func (*Style) BoxShadowToDots

func (s *Style) BoxShadowToDots(uc *units.Context)

BoxShadowToDots runs ToDots on all box shadow unit values to compile down to raw pixels

func (*Style) BoxSpace

func (s *Style) BoxSpace() SideFloats

BoxSpace returns extra space around the central content in the box model, in dots

func (*Style) ComputeActualBackground added in v0.0.34

func (s *Style) ComputeActualBackground(pabg image.Image)

ComputeActualBackground sets [Style.ActualBackground] based on the given parent actual background and the properties of the style object.

func (*Style) ComputeActualBackgroundFor added in v0.0.34

func (s *Style) ComputeActualBackgroundFor(bg, pabg image.Image) image.Image

ComputeActualBackgroundFor returns the actual background for the given background based on the given parent actual background and the properties of the style object.

func (*Style) CopyFrom

func (s *Style) CopyFrom(cp *Style)

CopyFrom copies from another style, while preserving relevant local state

func (*Style) Defaults

func (s *Style) Defaults()

func (*Style) FontRender

func (s *Style) FontRender() *FontRender

FontRender returns the font-rendering-related styles of the style object as a FontRender

func (*Style) HasBoxShadow

func (s *Style) HasBoxShadow() bool

HasBoxShadow returns whether the style has any box shadows

func (*Style) InheritFields

func (s *Style) InheritFields(par *Style)

InheritFields from parent: Manual inheriting of values is much faster than automatic version!

func (*Style) Is

func (s *Style) Is(st states.States) bool

Is returns whether the given states.States flag is set

func (*Style) IsFlexWrap added in v0.0.22

func (st *Style) IsFlexWrap() bool

func (*Style) LayoutDefaults

func (s *Style) LayoutDefaults()

func (*Style) LayoutHasParSizing added in v0.0.19

func (s *Style) LayoutHasParSizing() bool

LayoutHasParSizing returns true if the layout parameters use parent-relative sizing units, which requires additional updating during layout

func (*Style) LayoutToDots

func (s *Style) LayoutToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

func (*Style) MaxBoxShadowMargin

func (s *Style) MaxBoxShadowMargin() SideFloats

MaxBoxShadowMargin returns the maximum effective box shadow margin of the style, calculated through Shadow.Margin

func (*Style) ResizeImage added in v0.0.22

func (st *Style) ResizeImage(img image.Image, size mat32.Vec2) image.Image

ResizeImage resizes the given image according to [Style.ObjectFit] in an object of the given size.

func (*Style) SetAbilities

func (s *Style) SetAbilities(on bool, able ...abilities.Abilities)

SetAbilities sets the given states.State flags to the given value

func (*Style) SetEnabled added in v0.0.33

func (s *Style) SetEnabled(on bool) *Style

SetEnabled sets the Disabled State flag according to given bool

func (*Style) SetNonSelectable added in v0.0.19

func (st *Style) SetNonSelectable()

SetNonSelectable turns off the Selectable and DoubleClicable abilities and sets the Cursor to None.

func (*Style) SetState added in v0.0.28

func (s *Style) SetState(on bool, state ...states.States) *Style

SetState sets the given states.State flags to the given value

func (*Style) SetTextWrap added in v0.0.19

func (st *Style) SetTextWrap(wrap bool)

SetTextWrap sets the Text.WhiteSpace and GrowWrap properties in a coordinated manner. If wrap == true, then WhiteSpaceNormal and GrowWrap = true; else WhiteSpaceNowrap and GrowWrap = false, which are typically the two desired stylings.

func (*Style) StyleFromProp added in v0.0.19

func (s *Style) StyleFromProp(par *Style, key string, val any, ctxt colors.Context)

StyleFromProp sets style field values based on the given property key and value

func (*Style) ToDots

func (s *Style) ToDots()

ToDots caches all style elements in terms of raw pixel dots for rendering.

func (*Style) ToDotsImpl

func (s *Style) ToDotsImpl(uc *units.Context)

ToDotsImpl runs ToDots on unit values, to compile down to raw pixels

func (*Style) TotalMargin

func (s *Style) TotalMargin() SideFloats

TotalMargin returns the total effective margin of the element holding the style, using the sum of the actual margin, the max border width, and the max box shadow effective margin. If the values for the max border width / box shadow are unset, the current values are used instead, which allows for the omission of the max properties when the values do not change.

type StyleFunc

type StyleFunc func(obj any, key string, val any, par any, ctxt colors.Context)

func StyleFuncBool

func StyleFuncBool[T any](initVal bool, getField func(obj *T) *bool) StyleFunc

StyleFuncBool returns a style function for a bool value

func StyleFuncEnum

func StyleFuncEnum[T any](initVal enums.Enum, getField func(obj *T) enums.EnumSetter) StyleFunc

StyleFuncEnum returns a style function for any enum value

func StyleFuncFloat

func StyleFuncFloat[T any, F num.Float](initVal F, getField func(obj *T) *F) StyleFunc

StyleFuncFloat returns a style function for any numerical value

func StyleFuncInt

func StyleFuncInt[T any, F num.Integer](initVal F, getField func(obj *T) *F) StyleFunc

StyleFuncInt returns a style function for any numerical value

func StyleFuncUnits

func StyleFuncUnits[T any](initVal units.Value, getField func(obj *T) *units.Value) StyleFunc

StyleFuncUnits returns a style function for units.Value

type Text

type Text struct {

	// prop: text-align (inherited) = how to align text, horizontally.
	// This *only* applies to the text within its containing element,
	// and is typically relevant only for multi-line text:
	// for single-line text, if element does not have a specified size
	// that is different from the text size, then this has *no effect*.
	Align Aligns `xml:"text-align" inherit:"true"`

	// prop: text-vertical-align (inherited) = vertical alignment of text.
	// This is only applicable for SVG styling, not regular CSS / GoGi,
	// which uses the global Align.Y.  It *only* applies to the text within
	// its containing element: if that element does not have a specified size
	// that is different from the text size, then this has *no effect*.
	AlignV Aligns `xml:"text-vertical-align" inherit:"true"`

	// prop: text-anchor (inherited) = for svg rendering only:
	// determines the alignment relative to text position coordinate.
	// For RTL start is right, not left, and start is top for TB
	Anchor TextAnchors `xml:"text-anchor" inherit:"true"`

	// prop: letter-spacing = spacing between characters and lines
	LetterSpacing units.Value `xml:"letter-spacing"`

	// prop: word-spacing (inherited) = extra space to add between words
	WordSpacing units.Value `xml:"word-spacing" inherit:"true"`

	// prop: line-height (inherited) = specified height of a line of text; text is centered within the overall lineheight; the standard way to specify line height is in terms of em
	LineHeight units.Value `xml:"line-height" inherit:"true"`

	// prop: white-space (*not* inherited) specifies how white space is processed,
	// and how lines are wrapped.  If set to WhiteSpaceNormal (default) lines are wrapped.
	// See info about interactions with Grow.X setting for this and the NoWrap case.
	WhiteSpace WhiteSpaces `xml:"white-space"`

	// prop: unicode-bidi (inherited) = determines how to treat unicode bidirectional information
	UnicodeBidi UnicodeBidi `xml:"unicode-bidi" inherit:"true"`

	// prop: direction (inherited) = direction of text -- only applicable for unicode-bidi = bidi-override or embed -- applies to all text elements
	Direction TextDirections `xml:"direction" inherit:"true"`

	// prop: writing-mode (inherited) = overall writing mode -- only for text elements, not span
	WritingMode TextDirections `xml:"writing-mode" inherit:"true"`

	// prop: glyph-orientation-vertical (inherited) = for TBRL writing mode (only), determines orientation of alphabetic characters -- 90 is default (rotated) -- 0 means keep upright
	OrientationVert float32 `xml:"glyph-orientation-vertical" inherit:"true"`

	// prop: glyph-orientation-horizontal (inherited) = for horizontal LR/RL writing mode (only), determines orientation of all characters -- 0 is default (upright)
	OrientationHoriz float32 `xml:"glyph-orientation-horizontal" inherit:"true"`

	// prop: text-indent (inherited) = how much to indent the first line in a paragraph
	Indent units.Value `xml:"text-indent" inherit:"true"`

	// prop: para-spacing (inherited) = extra spacing between paragraphs -- copied from Style.Margin per CSS spec if that is non-zero, else can be set directly with para-spacing
	ParaSpacing units.Value `xml:"para-spacing" inherit:"true"`

	// prop: tab-size (inherited) = tab size, in number of characters
	TabSize int `xml:"tab-size" inherit:"true"`
}

Text is used for layout-level (widget, html-style) text styling -- FontStyle contains all the lower-level text rendering info used in SVG -- most of these are inherited

func (*Text) AlignFactors

func (ts *Text) AlignFactors() (ax, ay float32)

AlignFactors gets basic text alignment factors

func (*Text) Defaults

func (ts *Text) Defaults()

func (*Text) EffLineHeight

func (ts *Text) EffLineHeight(fontHeight float32) float32

EffLineHeight returns the effective line height for the given font height, handling the LineHeightNormal special case.

func (*Text) HasPre

func (ts *Text) HasPre() bool

HasPre returns true if current white space option preserves existing whitespace (or at least requires that parser in case of PreLine, which is intermediate)

func (*Text) HasWordWrap

func (ts *Text) HasWordWrap() bool

HasWordWrap returns true if current white space option supports word wrap

func (*Text) InheritFields

func (ts *Text) InheritFields(par *Text)

InheritFields from parent: Manual inheriting of values is much faster than automatic version!

func (*Text) ToDots

func (ts *Text) ToDots(uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type TextAnchors

type TextAnchors int32 //enums:enum -trim-prefix Anchor

TextAnchors are for direction of text writing, used in direction and writing-mode styles

const (
	AnchorStart TextAnchors = iota
	AnchorMiddle
	AnchorEnd
)
const TextAnchorsN TextAnchors = 3

TextAnchorsN is the highest valid value for type TextAnchors, plus one.

func TextAnchorsValues

func TextAnchorsValues() []TextAnchors

TextAnchorsValues returns all possible values for the type TextAnchors.

func (TextAnchors) Desc

func (i TextAnchors) Desc() string

Desc returns the description of the TextAnchors value.

func (TextAnchors) Int64

func (i TextAnchors) Int64() int64

Int64 returns the TextAnchors value as an int64.

func (TextAnchors) IsValid

func (i TextAnchors) IsValid() bool

IsValid returns whether the value is a valid option for type TextAnchors.

func (TextAnchors) MarshalText

func (i TextAnchors) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TextAnchors) SetInt64

func (i *TextAnchors) SetInt64(in int64)

SetInt64 sets the TextAnchors value from an int64.

func (*TextAnchors) SetString

func (i *TextAnchors) SetString(s string) error

SetString sets the TextAnchors value from its string representation, and returns an error if the string is invalid.

func (TextAnchors) String

func (i TextAnchors) String() string

String returns the string representation of this TextAnchors value.

func (*TextAnchors) UnmarshalText

func (i *TextAnchors) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TextAnchors) Values

func (i TextAnchors) Values() []enums.Enum

Values returns all possible values for the type TextAnchors.

type TextDecorations

type TextDecorations int64 //enums:bitflag -trim-prefix Deco

TextDecorations are underline, line-through, etc -- operates as bit flags -- also used for additional layout hints for RuneRender

const (
	DecoNone TextDecorations = iota
	DecoUnderline
	DecoOverline
	DecoLineThrough
	// Blink is not currently supported (and probably a bad idea generally ;)
	DecoBlink

	// DottedUnderline is used for abbr tag -- otherwise not a standard text-decoration option afaik
	DecoDottedUnderline

	// DecoParaStart at start of a SpanRender indicates that it should be
	// styled as the start of a new paragraph and not just the start of a new
	// line
	DecoParaStart
	// DecoSuper indicates super-scripted text
	DecoSuper
	// DecoSub indicates sub-scripted text
	DecoSub
	// DecoBackgroundColor indicates that a bg color has been set -- for use in optimizing rendering
	DecoBackgroundColor
)
const TextDecorationsN TextDecorations = 10

TextDecorationsN is the highest valid value for type TextDecorations, plus one.

func TextDecorationsValues

func TextDecorationsValues() []TextDecorations

TextDecorationsValues returns all possible values for the type TextDecorations.

func (TextDecorations) BitIndexString

func (i TextDecorations) BitIndexString() string

BitIndexString returns the string representation of this TextDecorations value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (TextDecorations) Desc

func (i TextDecorations) Desc() string

Desc returns the description of the TextDecorations value.

func (TextDecorations) HasFlag

func (i TextDecorations) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (TextDecorations) Int64

func (i TextDecorations) Int64() int64

Int64 returns the TextDecorations value as an int64.

func (TextDecorations) IsValid

func (i TextDecorations) IsValid() bool

IsValid returns whether the value is a valid option for type TextDecorations.

func (TextDecorations) MarshalText

func (i TextDecorations) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TextDecorations) SetFlag

func (i *TextDecorations) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*TextDecorations) SetInt64

func (i *TextDecorations) SetInt64(in int64)

SetInt64 sets the TextDecorations value from an int64.

func (*TextDecorations) SetString

func (i *TextDecorations) SetString(s string) error

SetString sets the TextDecorations value from its string representation, and returns an error if the string is invalid.

func (*TextDecorations) SetStringOr

func (i *TextDecorations) SetStringOr(s string) error

SetStringOr sets the TextDecorations value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (TextDecorations) String

func (i TextDecorations) String() string

String returns the string representation of this TextDecorations value.

func (*TextDecorations) UnmarshalText

func (i *TextDecorations) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TextDecorations) Values

func (i TextDecorations) Values() []enums.Enum

Values returns all possible values for the type TextDecorations.

type TextDirections

type TextDirections int32 //enums:enum

TextDirections are for direction of text writing, used in direction and writing-mode styles

const (
	LRTB TextDirections = iota
	RLTB
	TBRL
	LR
	RL
	TB
	LTR
	RTL
)
const TextDirectionsN TextDirections = 8

TextDirectionsN is the highest valid value for type TextDirections, plus one.

func TextDirectionsValues

func TextDirectionsValues() []TextDirections

TextDirectionsValues returns all possible values for the type TextDirections.

func (TextDirections) Desc

func (i TextDirections) Desc() string

Desc returns the description of the TextDirections value.

func (TextDirections) Int64

func (i TextDirections) Int64() int64

Int64 returns the TextDirections value as an int64.

func (TextDirections) IsValid

func (i TextDirections) IsValid() bool

IsValid returns whether the value is a valid option for type TextDirections.

func (TextDirections) MarshalText

func (i TextDirections) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TextDirections) SetInt64

func (i *TextDirections) SetInt64(in int64)

SetInt64 sets the TextDirections value from an int64.

func (*TextDirections) SetString

func (i *TextDirections) SetString(s string) error

SetString sets the TextDirections value from its string representation, and returns an error if the string is invalid.

func (TextDirections) String

func (i TextDirections) String() string

String returns the string representation of this TextDirections value.

func (*TextDirections) UnmarshalText

func (i *TextDirections) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TextDirections) Values

func (i TextDirections) Values() []enums.Enum

Values returns all possible values for the type TextDirections.

type UnicodeBidi

type UnicodeBidi int32 //enums:enum -trim-prefix Bidi

https://godoc.org/golang.org/x/text/unicode/bidi UnicodeBidi determines how

const (
	BidiNormal UnicodeBidi = iota
	BidiEmbed
	BidiBidiOverride
)
const UnicodeBidiN UnicodeBidi = 3

UnicodeBidiN is the highest valid value for type UnicodeBidi, plus one.

func UnicodeBidiValues

func UnicodeBidiValues() []UnicodeBidi

UnicodeBidiValues returns all possible values for the type UnicodeBidi.

func (UnicodeBidi) Desc

func (i UnicodeBidi) Desc() string

Desc returns the description of the UnicodeBidi value.

func (UnicodeBidi) Int64

func (i UnicodeBidi) Int64() int64

Int64 returns the UnicodeBidi value as an int64.

func (UnicodeBidi) IsValid

func (i UnicodeBidi) IsValid() bool

IsValid returns whether the value is a valid option for type UnicodeBidi.

func (UnicodeBidi) MarshalText

func (i UnicodeBidi) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*UnicodeBidi) SetInt64

func (i *UnicodeBidi) SetInt64(in int64)

SetInt64 sets the UnicodeBidi value from an int64.

func (*UnicodeBidi) SetString

func (i *UnicodeBidi) SetString(s string) error

SetString sets the UnicodeBidi value from its string representation, and returns an error if the string is invalid.

func (UnicodeBidi) String

func (i UnicodeBidi) String() string

String returns the string representation of this UnicodeBidi value.

func (*UnicodeBidi) UnmarshalText

func (i *UnicodeBidi) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (UnicodeBidi) Values

func (i UnicodeBidi) Values() []enums.Enum

Values returns all possible values for the type UnicodeBidi.

type VectorEffects

type VectorEffects int32 //enums:enum -trim-prefix VecEff

VectorEffects contains special effects for rendering

const (
	VecEffNone VectorEffects = iota

	// VecEffNonScalingStroke means that the stroke width is not affected by
	// transform properties
	VecEffNonScalingStroke
)
const VectorEffectsN VectorEffects = 2

VectorEffectsN is the highest valid value for type VectorEffects, plus one.

func VectorEffectsValues

func VectorEffectsValues() []VectorEffects

VectorEffectsValues returns all possible values for the type VectorEffects.

func (VectorEffects) Desc

func (i VectorEffects) Desc() string

Desc returns the description of the VectorEffects value.

func (VectorEffects) Int64

func (i VectorEffects) Int64() int64

Int64 returns the VectorEffects value as an int64.

func (VectorEffects) IsValid

func (i VectorEffects) IsValid() bool

IsValid returns whether the value is a valid option for type VectorEffects.

func (VectorEffects) MarshalText

func (i VectorEffects) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*VectorEffects) SetInt64

func (i *VectorEffects) SetInt64(in int64)

SetInt64 sets the VectorEffects value from an int64.

func (*VectorEffects) SetString

func (i *VectorEffects) SetString(s string) error

SetString sets the VectorEffects value from its string representation, and returns an error if the string is invalid.

func (VectorEffects) String

func (i VectorEffects) String() string

String returns the string representation of this VectorEffects value.

func (*VectorEffects) UnmarshalText

func (i *VectorEffects) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (VectorEffects) Values

func (i VectorEffects) Values() []enums.Enum

Values returns all possible values for the type VectorEffects.

type WhiteSpaces

type WhiteSpaces int32 //enums:enum -trim-prefix WhiteSpace

WhiteSpaces determine how white space is processed

const (
	// WhiteSpaceNormal means that all white space is collapsed to a single
	// space, and text wraps when necessary.  To get full word wrapping to
	// expand to all available space, you also need to set Grow.X = 1.
	// Use the SetTextWrap convenience method to set both.
	WhiteSpaceNormal WhiteSpaces = iota

	// WhiteSpaceNowrap means that sequences of whitespace will collapse into
	// a single whitespace. Text will never wrap to the next line except
	// if there is an explicit line break via a <br> tag.  In general you
	// also don't want simple non-wrapping text labels to Grow (Grow.X = 0).
	// Use the SetTextWrap method to set both.
	WhiteSpaceNowrap

	// WhiteSpacePre means that whitespace is preserved by the browser. Text
	// will only wrap on line breaks. Acts like the <pre> tag in HTML.  This
	// invokes a different hand-written parser because the default golang
	// parser automatically throws away whitespace
	WhiteSpacePre

	// WhiteSpacePreLine means that sequences of whitespace will collapse
	// into a single whitespace. Text will wrap when necessary, and on line
	// breaks
	WhiteSpacePreLine

	// WhiteSpacePreWrap means that whitespace is preserved by the
	// browser. Text will wrap when necessary, and on line breaks
	WhiteSpacePreWrap
)
const WhiteSpacesN WhiteSpaces = 5

WhiteSpacesN is the highest valid value for type WhiteSpaces, plus one.

func WhiteSpacesValues

func WhiteSpacesValues() []WhiteSpaces

WhiteSpacesValues returns all possible values for the type WhiteSpaces.

func (WhiteSpaces) Desc

func (i WhiteSpaces) Desc() string

Desc returns the description of the WhiteSpaces value.

func (WhiteSpaces) Int64

func (i WhiteSpaces) Int64() int64

Int64 returns the WhiteSpaces value as an int64.

func (WhiteSpaces) IsValid

func (i WhiteSpaces) IsValid() bool

IsValid returns whether the value is a valid option for type WhiteSpaces.

func (WhiteSpaces) MarshalText

func (i WhiteSpaces) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*WhiteSpaces) SetInt64

func (i *WhiteSpaces) SetInt64(in int64)

SetInt64 sets the WhiteSpaces value from an int64.

func (*WhiteSpaces) SetString

func (i *WhiteSpaces) SetString(s string) error

SetString sets the WhiteSpaces value from its string representation, and returns an error if the string is invalid.

func (WhiteSpaces) String

func (i WhiteSpaces) String() string

String returns the string representation of this WhiteSpaces value.

func (*WhiteSpaces) UnmarshalText

func (i *WhiteSpaces) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (WhiteSpaces) Values

func (i WhiteSpaces) Values() []enums.Enum

Values returns all possible values for the type WhiteSpaces.

type XY added in v0.0.19

type XY[T any] struct {
	// X is the horizontal axis value
	X T

	// Y is the vertical axis value
	Y T
}

XY represents X,Y values

func (*XY[T]) Dim added in v0.0.19

func (xy *XY[T]) Dim(d mat32.Dims) T

return the value for given dimension

func (*XY[T]) Set added in v0.0.19

func (xy *XY[T]) Set(v ...T)

Set sets the X, Y values according to the given values. no values: set to 0. 1 value: set both to that value. 2 values, set X, Y to the two values respectively.

func (*XY[T]) SetDim added in v0.0.19

func (xy *XY[T]) SetDim(d mat32.Dims, val T)

set the value for given dimension

func (*XY[T]) String added in v0.0.19

func (xy *XY[T]) String() string

String implements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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