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 ¶
- Variables
- func CopyGradient(dst, src *rasterx.Gradient)
- func FixFontMods(fn string) string
- func FixGradientStops(grad *rasterx.Gradient)
- func FontNameFromMods(basenm string, str FontStretch, wt FontWeights, sty FontStyles) string
- func FontNameToMods(fn string) (basenm string, str FontStretch, wt FontWeights, sty FontStyles)
- func HSLSortedColorNames() []string
- func HSLtoRGBf32(h, s, l float32) (r, g, b float32)
- func IsAlignEnd(a Align) bool
- func IsAlignMiddle(a Align) bool
- func IsAlignStart(a Align) bool
- func MatToRasterx(mat *mat32.Mat2) rasterx.Matrix2D
- func ParseDashesString(str string) []float64
- func RGBtoHSLf32(r, g, b float32) (h, s, l float32)
- func RasterxToMat(mat *rasterx.Matrix2D) mat32.Mat2
- func SetGradientBounds(grad *rasterx.Gradient, bounds image.Rectangle)
- func SetStylePropsXML(style string, props *ki.Props)
- func StyleInhInit(val, par interface{}) (inh, init bool)
- func StylePropsXML(props ki.Props) string
- func StyleSetError(key string, val interface{})
- func SubProps(prp ki.Props, selector string) (ki.Props, bool)
- func XMLAttr(name string, attrs []xml.Attr) string
- type Align
- type BaselineShifts
- type Border
- type BorderStyles
- type BoxSides
- type Color
- func (c *Color) Add(dc Color)
- func (c *Color) Blend(pct float32, clr color.Color) Color
- func (c *Color) Clearer(pct float32) Color
- func (c *Color) Darker(pct float32) Color
- func (c *Color) HexString() string
- func (c *Color) Highlight(pct float32) Color
- func (c *Color) Inverse() Color
- func (c *Color) IsBlack() bool
- func (c *Color) IsDark() bool
- func (c *Color) IsNil() bool
- func (c *Color) IsWhite() bool
- func (c *Color) Lighter(pct float32) Color
- func (c *Color) Opaquer(pct float32) Color
- func (c *Color) ParseHex(x string) error
- func (c *Color) Pastel(pct float32) Color
- func (c Color) RGBA() (r, g, b, a uint32)
- func (c *Color) Samelight(pct float32) Color
- func (c *Color) Saturate(pct float32) Color
- func (c *Color) SetAlphaPreFix() bool
- func (c *Color) SetAlphaPreMult() bool
- func (c *Color) SetColor(ci color.Color)
- func (c *Color) SetFloat32(r, g, b, a float32)
- func (c *Color) SetFloat64(r, g, b, a float64)
- func (c *Color) SetHSL(h, s, l float32)
- func (c *Color) SetHSLA(h, s, l, a float32)
- func (c *Color) SetIFace(val interface{}, ctxt Context, key string) error
- func (c *Color) SetInt(r, g, b, a int)
- func (c *Color) SetNPFloat32(r, g, b, a float32)
- func (c *Color) SetName(name string) error
- func (c *Color) SetNotAlphaPreMult() bool
- func (c *Color) SetString(str string, base color.Color) error
- func (c *Color) SetStringStyle(str string, base color.Color, ctxt Context) error
- func (c *Color) SetToNil()
- func (c *Color) SetUInt32(r, g, b, a uint32)
- func (c *Color) SetUInt8(r, g, b, a uint8)
- func (c *Color) String() string
- func (c *Color) Sub(dc Color)
- func (c *Color) ToFloat32() (r, g, b, a float32)
- func (c *Color) ToHSLA() (h, s, l, a float32)
- func (c *Color) ToNPFloat32() (r, g, b, a float32)
- type ColorSources
- type ColorSpec
- func (c *ColorSpec) ApplyXForm(xf mat32.Mat2)
- func (c *ColorSpec) ApplyXFormPt(xf mat32.Mat2, pt mat32.Vec2)
- func (cs *ColorSpec) ColorOrNil() color.Color
- func (cs *ColorSpec) CopyFrom(cp *ColorSpec)
- func (cs *ColorSpec) CopyStopsFrom(cp *ColorSpec)
- func (cs *ColorSpec) IsNil() bool
- func (cs *ColorSpec) NewLinearGradient()
- func (cs *ColorSpec) NewRadialGradient()
- func (cs *ColorSpec) ReadGradAttr(attr xml.Attr) (err error)
- func (cs *ColorSpec) ReadXML(reader io.Reader) error
- func (cs *ColorSpec) RenderColor(opacity float32, bounds image.Rectangle, xform mat32.Mat2) interface{}
- func (cs *ColorSpec) SetColor(cl color.Color)
- func (cs *ColorSpec) SetGradientPoints(bbox mat32.Box2)
- func (c *ColorSpec) SetIFace(val interface{}, ctxt Context, key string) error
- func (cs *ColorSpec) SetName(name string)
- func (cs *ColorSpec) SetShadowGradient(cl color.Color, dir string)
- func (cs *ColorSpec) SetString(clrstr string, ctxt Context) bool
- func (cs *ColorSpec) UnmarshalXML(decoder *xml.Decoder, se xml.StartElement) error
- type Context
- type Fill
- type FillRules
- type Font
- func (fs *Font) ClearDeco(deco TextDecorations)
- func (fs *Font) CopyNonDefaultProps(node ki.Ki)
- func (fs *Font) Defaults()
- func (fs *Font) InheritFields(par *Font)
- func (fs *Font) SetDeco(deco TextDecorations)
- func (fs *Font) SetStylePost(props ki.Props)
- func (fs *Font) SetStyleProps(parent *Font, props ki.Props, ctxt Context)
- func (fs *Font) SetUnitContext(ctxt *units.Context)
- func (fs *Font) StyleFromProps(par *Font, props ki.Props, ctxt Context)
- func (fs *Font) ToDots(uc *units.Context)
- type FontFace
- type FontMetrics
- type FontStretch
- type FontStyles
- type FontVariants
- type FontWeights
- type GradientPoints
- type HSLA
- type Layout
- func (ls *Layout) AlignDim(d mat32.Dims) Align
- func (ls *Layout) Defaults()
- func (ls *Layout) MaxSizeDots() mat32.Vec2
- func (ls *Layout) MinSizeDots() mat32.Vec2
- func (ls *Layout) PosDots() mat32.Vec2
- func (ls *Layout) SetStylePost(props ki.Props)
- func (ls *Layout) SizeDots() mat32.Vec2
- func (ly *Layout) ToDots(uc *units.Context)
- type LineCaps
- type LineJoins
- type NRGBAf32
- type Overflow
- type Paint
- func (pc *Paint) CopyStyleFrom(cp *Paint)
- func (pc *Paint) Defaults()
- func (pc *Paint) HasFill() bool
- func (pc *Paint) HasNoStrokeOrFill() bool
- func (pc *Paint) HasStroke() bool
- func (pc *Paint) InheritFields(par *Paint)
- func (pc *Paint) SetStyleProps(par *Paint, props ki.Props, ctxt Context)
- func (pc *Paint) SetUnitContextExt(size image.Point)
- func (pc *Paint) StyleFromProps(par *Paint, props ki.Props, ctxt Context)
- func (pc *Paint) StyleToDots(uc *units.Context)
- func (pc *Paint) ToDots()
- func (pc *Paint) ToDotsImpl(uc *units.Context)
- type Painter
- type Prefs
- type RGBAf32
- type Shadow
- type SizePrefs
- type Stroke
- type Style
- func (s *Style) BoxSpace() float32
- func (s *Style) CopyFrom(cp *Style)
- func (s *Style) CopyUnitContext(ctxt *units.Context)
- func (s *Style) Defaults()
- func (s *Style) FromTemplate() (hasTemplate bool, saveTemplate bool)
- func (s *Style) InheritFields(par *Style)
- func (s *Style) SaveTemplate()
- func (s *Style) SetStyleProps(par *Style, props ki.Props, ctxt Context)
- func (s *Style) StyleFromProps(par *Style, props ki.Props, ctxt Context)
- func (s *Style) StyleToDots(uc *units.Context)
- func (s *Style) ToDots()
- func (s *Style) ToDotsImpl(uc *units.Context)
- type StyleFunc
- type Styler
- type Text
- func (ts *Text) AlignFactors() (ax, ay float32)
- func (ts *Text) Defaults()
- func (ts *Text) EffLineHeight() float32
- func (ts *Text) HasPre() bool
- func (ts *Text) HasWordWrap() bool
- func (ts *Text) InheritFields(par *Text)
- func (ts *Text) SetStylePost(props ki.Props)
- func (ts *Text) ToDots(uc *units.Context)
- type TextAnchors
- type TextDecorations
- type TextDirections
- type UnicodeBidi
- type VectorEffects
- type WhiteSpaces
Constants ¶
This section is empty.
Variables ¶
var ( NilColor Color White = Color{255, 255, 255, 255} Black = Color{0, 0, 0, 255} Transparent = Color{255, 255, 255, 0} )
var ( ColorModel color.Model = color.ModelFunc(colorModel) RGBAf32Model color.Model = color.ModelFunc(rgbaf32Model) NRGBAf32Model color.Model = color.ModelFunc(nrgbaf32Model) HSLAModel color.Model = color.ModelFunc(hslaf32Model) )
var ColorProps = ki.Props{ "style-prop": true, }
var ColorSpecCache map[string]*ColorSpec
ColorSpecCache is a cache of named color specs -- only a few are constantly re-used so we save them in the cache instead of constantly recomputing!
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
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.
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.
var FontWeightNameVals = []FontWeights{WeightNormal, WeightThin, WeightExtraLight, WeightLight, WeightMedium, WeightSemiBold, WeightExtraBold, WeightBold, WeightBlack}
FontWeightNameVals is 1-to-1 index map from FontWeightNames to corresponding weight value (using more semantic term instead of numerical one)
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!
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
var GradientDegToSides = map[string]string{
"0deg": "top",
"360deg": "top",
"45deg": "top right",
"-315deg": "top right",
"90deg": "right",
"-270deg": "right",
"135deg": "bottom right",
"-225deg": "bottom right",
"180deg": "bottom",
"-180deg": "bottom",
"225deg": "bottom left",
"-135deg": "bottom left",
"270deg": "left",
"-90deg": "left",
"315deg": "top left",
"-45deg": "top left",
}
GradientDegToSides maps gradient degree notation to side notation
var KiT_Align = kit.Enums.AddEnumAltLower(AlignN, kit.NotBitFlag, StylePropProps, "Align")
var KiT_BaselineShifts = kit.Enums.AddEnumAltLower(BaselineShiftsN, kit.NotBitFlag, StylePropProps, "Shift")
var KiT_BorderStyles = kit.Enums.AddEnumAltLower(BorderN, kit.NotBitFlag, StylePropProps, "Border")
var KiT_BoxSides = kit.Enums.AddEnumAltLower(BoxN, kit.NotBitFlag, StylePropProps, "Box")
var KiT_Color = kit.Types.AddType(&Color{}, ColorProps)
var KiT_ColorSources = kit.Enums.AddEnumAltLower(ColorSourcesN, kit.NotBitFlag, StylePropProps, "")
var KiT_ColorSpec = kit.Types.AddType(&ColorSpec{}, nil)
var KiT_FillRules = kit.Enums.AddEnumAltLower(FillRulesN, kit.NotBitFlag, StylePropProps, "FillRules")
var KiT_FontStretch = kit.Enums.AddEnumAltLower(FontStretchN, kit.NotBitFlag, StylePropProps, "FontStr")
var KiT_FontStyles = kit.Enums.AddEnumAltLower(FontStylesN, kit.NotBitFlag, StylePropProps, "Font")
var KiT_FontVariants = kit.Enums.AddEnumAltLower(FontVariantsN, kit.NotBitFlag, StylePropProps, "FontVar")
var KiT_FontWeights = kit.Enums.AddEnumAltLower(FontWeightsN, kit.NotBitFlag, StylePropProps, "Weight")
var KiT_LineCaps = kit.Enums.AddEnumAltLower(LineCapsN, kit.NotBitFlag, StylePropProps, "LineCaps")
var KiT_LineJoins = kit.Enums.AddEnumAltLower(LineJoinsN, kit.NotBitFlag, StylePropProps, "LineJoins")
var KiT_Overflow = kit.Enums.AddEnumAltLower(OverflowN, kit.NotBitFlag, StylePropProps, "Overflow")
var KiT_TextAnchors = kit.Enums.AddEnumAltLower(TextAnchorsN, kit.NotBitFlag, StylePropProps, "Anchor")
var KiT_TextDecorations = kit.Enums.AddEnumAltLower(TextDecorationsN, kit.BitFlag, StylePropProps, "Deco")
var KiT_TextDirections = kit.Enums.AddEnumAltLower(TextDirectionsN, kit.NotBitFlag, StylePropProps, "")
var KiT_UnicodeBidi = kit.Enums.AddEnumAltLower(UnicodeBidiN, kit.NotBitFlag, StylePropProps, "Bidi")
var KiT_VectorEffects = kit.Enums.AddEnumAltLower(VecEffN, kit.NotBitFlag, StylePropProps, "VecEff")
var KiT_WhiteSpaces = kit.Enums.AddEnumAltLower(WhiteSpacesN, kit.NotBitFlag, StylePropProps, "WhiteSpace")
var RebuildDefaultStyles bool
RebuildDefaultStyles is a global state var used by Prefs to trigger rebuild of all the default styles, which are otherwise compiled and not updated
var ScrollBarWidthDefault = float32(16)
ScrollBarWidthDefault is the default width of a scrollbar in pixels
var StyleBorderFuncs = map[string]StyleFunc{ "border-style": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Style = par.(*Border).Style } else if init { bs.Style = BorderSolid } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&bs.Style, vt) case BorderStyles: bs.Style = vt default: if iv, ok := kit.ToInt(val); ok { bs.Style = BorderStyles(iv) } else { StyleSetError(key, val) } } }, "border-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Width = par.(*Border).Width } else if init { bs.Width.Val = 0 } return } bs.Width.SetIFace(val, key) }, "border-radius": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Radius = par.(*Border).Radius } else if init { bs.Radius.Val = 0 } return } bs.Radius.SetIFace(val, key) }, "border-color": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Color = par.(*Border).Color } else if init { bs.Color = Black } return } bs.Color.SetIFace(val, ctxt, key) }, }
StyleBorderFuncs are functions for styling the Border object
var StyleFillFuncs = map[string]StyleFunc{ "fill": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Fill) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*Fill).Color } else if init { fs.SetColor(Black) } return } fs.Color.SetIFace(val, ctxt, key) }, "fill-opacity": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Fill) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Opacity = par.(*Fill).Opacity } else if init { fs.Opacity = 1 } return } if iv, ok := kit.ToFloat32(val); ok { fs.Opacity = iv } }, "fill-rule": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Fill) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Rule = par.(*Fill).Rule } else if init { fs.Rule = FillRuleNonZero } return } switch vt := val.(type) { case string: fs.Rule.FromString(vt) case FillRules: fs.Rule = vt default: if iv, ok := kit.ToInt(val); ok { fs.Rule = FillRules(iv) } else { StyleSetError(key, val) } } }, }
StyleFillFuncs are functions for styling the Fill object
var StyleFontFuncs = map[string]StyleFunc{ "color": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*Font).Color } else if init { fs.Color = Black } return } fs.Color.SetIFace(val, ctxt, key) }, "background-color": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.BgColor = par.(*Font).BgColor } else if init { fs.BgColor = ColorSpec{} } return } fs.BgColor.SetIFace(val, ctxt, key) }, "opacity": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Opacity = par.(*Font).Opacity } else if init { fs.Opacity = 1 } return } if iv, ok := kit.ToFloat32(val); ok { fs.Opacity = iv } }, "font-size": func(obj interface{}, key string, val interface{}, par interface{}, ctxt 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.Pt) } return } switch vt := val.(type) { case string: if psz, ok := FontSizePoints[vt]; ok { fs.Size = units.NewPt(psz) } else { fs.Size.SetIFace(val, key) } default: fs.Size.SetIFace(val, key) } }, "font-family": func(obj interface{}, key string, val interface{}, par interface{}, ctxt 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 = kit.ToString(val) }, "font-style": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Style = par.(*Font).Style } else if init { fs.Style = FontNormal } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&fs.Style, vt) case FontStyles: fs.Style = vt default: if iv, ok := kit.ToInt(val); ok { fs.Style = FontStyles(iv) } else { StyleSetError(key, val) } } }, "font-weight": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Weight = par.(*Font).Weight } else if init { fs.Weight = WeightNormal } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&fs.Weight, vt) case FontWeights: fs.Weight = vt default: if iv, ok := kit.ToInt(val); ok { fs.Weight = FontWeights(iv) } else { StyleSetError(key, val) } } }, "font-stretch": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Stretch = par.(*Font).Stretch } else if init { fs.Stretch = FontStrNormal } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&fs.Stretch, vt) case FontStretch: fs.Stretch = vt default: if iv, ok := kit.ToInt(val); ok { fs.Stretch = FontStretch(iv) } else { StyleSetError(key, val) } } }, "font-variant": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Variant = par.(*Font).Variant } else if init { fs.Variant = FontVarNormal } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&fs.Variant, vt) case FontVariants: fs.Variant = vt default: if iv, ok := kit.ToInt(val); ok { fs.Variant = FontVariants(iv) } else { StyleSetError(key, val) } } }, "text-decoration": func(obj interface{}, key string, val interface{}, par interface{}, ctxt 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 { kit.Enums.SetAnyEnumIfaceFromString(&fs.Deco, vt) } case TextDecorations: fs.Deco = vt default: if iv, ok := kit.ToInt(val); ok { fs.Deco = TextDecorations(iv) } else { StyleSetError(key, val) } } }, "baseline-shift": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Shift = par.(*Font).Shift } else if init { fs.Shift = ShiftBaseline } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&fs.Shift, vt) case BaselineShifts: fs.Shift = vt default: if iv, ok := kit.ToInt(val); ok { fs.Shift = BaselineShifts(iv) } else { StyleSetError(key, val) } } }, }
StyleFontFuncs are functions for styling the Font object
var StyleLayoutFuncs = map[string]StyleFunc{ "z-index": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.ZIndex = par.(*Layout).ZIndex } else if init { ly.ZIndex = 0 } return } if iv, ok := kit.ToInt(val); ok { ly.ZIndex = int(iv) } }, "horizontal-align": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.AlignH = par.(*Layout).AlignH } else if init { ly.AlignH = AlignLeft } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ly.AlignH, vt) case Align: ly.AlignH = vt default: if iv, ok := kit.ToInt(val); ok { ly.AlignH = Align(iv) } else { StyleSetError(key, val) } } }, "vertical-align": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.AlignV = par.(*Layout).AlignV } else if init { ly.AlignV = AlignMiddle } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ly.AlignV, vt) case Align: ly.AlignV = vt default: if iv, ok := kit.ToInt(val); ok { ly.AlignV = Align(iv) } else { StyleSetError(key, val) } } }, "x": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.PosX = par.(*Layout).PosX } else if init { ly.PosX.Val = 0 } return } ly.PosX.SetIFace(val, key) }, "y": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.PosY = par.(*Layout).PosY } else if init { ly.PosY.Val = 0 } return } ly.PosY.SetIFace(val, key) }, "width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Width = par.(*Layout).Width } else if init { ly.Width.Val = 0 } return } ly.Width.SetIFace(val, key) }, "height": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Height = par.(*Layout).Height } else if init { ly.Height.Val = 0 } return } ly.Height.SetIFace(val, key) }, "max-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.MaxWidth = par.(*Layout).MaxWidth } else if init { ly.MaxWidth.Val = 0 } return } ly.MaxWidth.SetIFace(val, key) }, "max-height": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.MaxHeight = par.(*Layout).MaxHeight } else if init { ly.MaxHeight.Val = 0 } return } ly.MaxHeight.SetIFace(val, key) }, "min-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.MinWidth = par.(*Layout).MinWidth } else if init { ly.MinWidth.Set(2, units.Px) } return } ly.MinWidth.SetIFace(val, key) }, "min-height": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.MinHeight = par.(*Layout).MinHeight } else if init { ly.MinHeight.Set(2, units.Px) } return } ly.MinHeight.SetIFace(val, key) }, "margin": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Margin = par.(*Layout).Margin } else if init { ly.Margin.Val = 0 } return } ly.Margin.SetIFace(val, key) }, "padding": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Padding = par.(*Layout).Padding } else if init { ly.Padding.Val = 0 } return } ly.Padding.SetIFace(val, key) }, "overflow": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Overflow = par.(*Layout).Overflow } else if init { ly.Overflow = OverflowAuto } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ly.Overflow, vt) case Overflow: ly.Overflow = vt default: if iv, ok := kit.ToInt(val); ok { ly.Overflow = Overflow(iv) } else { StyleSetError(key, val) } } }, "columns": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Columns = par.(*Layout).Columns } else if init { ly.Columns = 0 } return } if iv, ok := kit.ToInt(val); ok { ly.Columns = int(iv) } }, "row": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Row = par.(*Layout).Row } else if init { ly.Row = 0 } return } if iv, ok := kit.ToInt(val); ok { ly.Row = int(iv) } }, "col": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.Col = par.(*Layout).Col } else if init { ly.Col = 0 } return } if iv, ok := kit.ToInt(val); ok { ly.Col = int(iv) } }, "row-span": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.RowSpan = par.(*Layout).RowSpan } else if init { ly.RowSpan = 0 } return } if iv, ok := kit.ToInt(val); ok { ly.RowSpan = int(iv) } }, "col-span": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.ColSpan = par.(*Layout).ColSpan } else if init { ly.ColSpan = 0 } return } if iv, ok := kit.ToInt(val); ok { ly.ColSpan = int(iv) } }, "scrollbar-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ly := obj.(*Layout) if inh, init := StyleInhInit(val, par); inh || init { if inh { ly.ScrollBarWidth = par.(*Layout).ScrollBarWidth } else if init { ly.ScrollBarWidth.Val = 0 } return } ly.ScrollBarWidth.SetIFace(val, key) }, }
StyleLayoutFuncs are functions for styling the Layout object
var StyleOutlineFuncs = map[string]StyleFunc{ "outline-style": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Style = par.(*Border).Style } else if init { bs.Style = BorderNone } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&bs.Style, vt) case BorderStyles: bs.Style = vt default: if iv, ok := kit.ToInt(val); ok { bs.Style = BorderStyles(iv) } else { StyleSetError(key, val) } } }, "outline-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Width = par.(*Border).Width } else if init { bs.Width.Val = 0 } return } bs.Width.SetIFace(val, key) }, "outline-radius": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Radius = par.(*Border).Radius } else if init { bs.Radius.Val = 0 } return } bs.Radius.SetIFace(val, key) }, "outline-color": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Color = par.(*Border).Color } else if init { bs.Color = Black } return } bs.Color.SetIFace(val, ctxt, key) }, }
StyleOutlineFuncs are functions for styling the OutlineStyle object
var StylePaintFuncs = map[string]StyleFunc{ "vector-effect": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { pc := obj.(*Paint) if inh, init := StyleInhInit(val, par); inh || init { if inh { pc.VecEff = par.(*Paint).VecEff } else if init { pc.VecEff = VecEffNone } return } switch vt := val.(type) { case string: pc.VecEff.FromString(vt) case VectorEffects: pc.VecEff = vt default: if iv, ok := kit.ToInt(val); ok { pc.VecEff = VectorEffects(iv) } else { StyleSetError(key, val) } } }, "transform": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { pc := obj.(*Paint) if inh, init := StyleInhInit(val, par); inh || init { if inh { pc.XForm = par.(*Paint).XForm } else if init { pc.XForm = mat32.Identity2D() } return } switch vt := val.(type) { case string: pc.XForm.SetString(vt) case *mat32.Mat2: pc.XForm = *vt case mat32.Mat2: pc.XForm = vt } }, }
StylePaintFuncs are functions for styling the Stroke object
var StylePropProps = ki.Props{ "style-prop": true, }
StylePropProps should be set as type props for any enum (not struct types, which must have their own props) that is useful as a styling property -- use this for selecting types to add to Props
var StyleShadowFuncs = map[string]StyleFunc{ "box-shadow.h-offset": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.HOffset = par.(*Shadow).HOffset } else if init { ss.HOffset.Val = 0 } return } ss.HOffset.SetIFace(val, key) }, "box-shadow.v-offset": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.VOffset = par.(*Shadow).VOffset } else if init { ss.VOffset.Val = 0 } return } ss.VOffset.SetIFace(val, key) }, "box-shadow.blur": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.Blur = par.(*Shadow).Blur } else if init { ss.Blur.Val = 0 } return } ss.Blur.SetIFace(val, key) }, "box-shadow.spread": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.Spread = par.(*Shadow).Spread } else if init { ss.Spread.Val = 0 } return } ss.Spread.SetIFace(val, key) }, "box-shadow.color": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.Color = par.(*Shadow).Color } else if init { ss.Color = Black } return } ss.Color.SetIFace(val, ctxt, key) }, "box-shadow.inset": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.Inset = par.(*Shadow).Inset } else if init { ss.Inset = false } return } if bv, ok := kit.ToBool(val); ok { ss.Inset = bv } }, }
StyleShadowFuncs are functions for styling the Shadow object
var StyleStrokeFuncs = map[string]StyleFunc{ "stroke": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*Stroke).Color } else if init { fs.SetColor(Black) } return } fs.Color.SetIFace(val, ctxt, key) }, "stroke-opacity": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Opacity = par.(*Stroke).Opacity } else if init { fs.Opacity = 1 } return } if iv, ok := kit.ToFloat32(val); ok { fs.Opacity = iv } }, "stroke-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Width = par.(*Stroke).Width } else if init { fs.Width.Set(1, units.Px) } return } fs.Width.SetIFace(val, key) }, "stroke-min-width": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.MinWidth = par.(*Stroke).MinWidth } else if init { fs.MinWidth.Set(1, units.Px) } return } fs.MinWidth.SetIFace(val, key) }, "stroke-dasharray": func(obj interface{}, key string, val interface{}, par interface{}, ctxt 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 []float64: mat32.CopyFloat64s(&fs.Dashes, vt) case *[]float64: mat32.CopyFloat64s(&fs.Dashes, *vt) } }, "stroke-linecap": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Cap = par.(*Stroke).Cap } else if init { fs.Cap = LineCapButt } return } switch vt := val.(type) { case string: fs.Cap.FromString(vt) case LineCaps: fs.Cap = vt default: if iv, ok := kit.ToInt(val); ok { fs.Cap = LineCaps(iv) } else { StyleSetError(key, val) } } }, "stroke-linejoin": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Join = par.(*Stroke).Join } else if init { fs.Join = LineJoinMiter } return } switch vt := val.(type) { case string: fs.Join.FromString(vt) case LineJoins: fs.Join = vt default: if iv, ok := kit.ToInt(val); ok { fs.Join = LineJoins(iv) } else { StyleSetError(key, val) } } }, "stroke-miterlimit": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.MiterLimit = par.(*Stroke).MiterLimit } else if init { fs.MiterLimit = 1 } return } if iv, ok := kit.ToFloat32(val); ok { fs.MiterLimit = iv } }, }
StyleStrokeFuncs are functions for styling the Stroke object
var StyleStyleFuncs = map[string]StyleFunc{ "display": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.Display = par.(*Style).Display } else if init { s.Display = true } return } if kit.ToString(val) == "none" { s.Display = false } else { if bv, ok := kit.ToBool(val); ok { s.Display = bv } } }, "visible": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.Visible = par.(*Style).Visible } else if init { s.Visible = false } return } if bv, ok := kit.ToBool(val); ok { s.Visible = bv } }, "inactive": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.Inactive = par.(*Style).Inactive } else if init { s.Inactive = false } return } if bv, ok := kit.ToBool(val); ok { s.Inactive = bv } }, "pointer-events": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.PointerEvents = par.(*Style).PointerEvents } else if init { s.PointerEvents = true } return } if bv, ok := kit.ToBool(val); ok { s.PointerEvents = bv } }, }
StyleStyleFuncs are functions for styling the Style object itself
var StyleTemplates map[string]*Style
StyleTemplates are cached styles used for styling large numbers of identical elements in views
var StyleTemplatesMu sync.RWMutex
StyleTemplatesMu is a mutex protecting updates to StyleTemplates
var StyleTextFuncs = map[string]StyleFunc{ "text-align": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.Align = par.(*Text).Align } else if init { ts.Align = AlignLeft } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.Align, vt) case Align: ts.Align = vt default: if iv, ok := kit.ToInt(val); ok { ts.Align = Align(iv) } else { StyleSetError(key, val) } } }, "text-vertical-align": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.AlignV = par.(*Text).Align } else if init { ts.AlignV = AlignTop } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.AlignV, vt) case Align: ts.AlignV = vt default: if iv, ok := kit.ToInt(val); ok { ts.AlignV = Align(iv) } else { StyleSetError(key, val) } } }, "text-anchor": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.Anchor = par.(*Text).Anchor } else if init { ts.Anchor = AnchorStart } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.Anchor, vt) case TextAnchors: ts.Anchor = vt default: if iv, ok := kit.ToInt(val); ok { ts.Anchor = TextAnchors(iv) } else { StyleSetError(key, val) } } }, "letter-spacing": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.LetterSpacing = par.(*Text).LetterSpacing } else if init { ts.LetterSpacing.Val = 0 } return } ts.LetterSpacing.SetIFace(val, key) }, "word-spacing": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.WordSpacing = par.(*Text).WordSpacing } else if init { ts.WordSpacing.Val = 0 } return } ts.WordSpacing.SetIFace(val, key) }, "line-height": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.LineHeight = par.(*Text).LineHeight } else if init { ts.LineHeight = 1 } return } if iv, ok := kit.ToFloat32(val); ok { ts.LineHeight = iv } }, "white-space": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.WhiteSpace = par.(*Text).WhiteSpace } else if init { ts.WhiteSpace = WhiteSpaceNormal } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.WhiteSpace, vt) case WhiteSpaces: ts.WhiteSpace = vt default: if iv, ok := kit.ToInt(val); ok { ts.WhiteSpace = WhiteSpaces(iv) } else { StyleSetError(key, val) } } }, "unicode-bidi": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.UnicodeBidi = par.(*Text).UnicodeBidi } else if init { ts.UnicodeBidi = BidiNormal } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.UnicodeBidi, vt) case UnicodeBidi: ts.UnicodeBidi = vt default: if iv, ok := kit.ToInt(val); ok { ts.UnicodeBidi = UnicodeBidi(iv) } else { StyleSetError(key, val) } } }, "direction": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.Direction = par.(*Text).Direction } else if init { ts.Direction = LRTB } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.Direction, vt) case TextDirections: ts.Direction = vt default: if iv, ok := kit.ToInt(val); ok { ts.Direction = TextDirections(iv) } else { StyleSetError(key, val) } } }, "writing-mode": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.WritingMode = par.(*Text).WritingMode } else if init { ts.WritingMode = LRTB } return } switch vt := val.(type) { case string: kit.Enums.SetAnyEnumIfaceFromString(&ts.WritingMode, vt) case TextDirections: ts.WritingMode = vt default: if iv, ok := kit.ToInt(val); ok { ts.WritingMode = TextDirections(iv) } else { StyleSetError(key, val) } } }, "glyph-orientation-vertical": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.OrientationVert = par.(*Text).OrientationVert } else if init { ts.OrientationVert = 1 } return } if iv, ok := kit.ToFloat32(val); ok { ts.OrientationVert = iv } }, "glyph-orientation-horizontal": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.OrientationHoriz = par.(*Text).OrientationHoriz } else if init { ts.OrientationHoriz = 1 } return } if iv, ok := kit.ToFloat32(val); ok { ts.OrientationHoriz = iv } }, "text-indent": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.Indent = par.(*Text).Indent } else if init { ts.Indent.Val = 0 } return } ts.Indent.SetIFace(val, key) }, "para-spacing": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.ParaSpacing = par.(*Text).ParaSpacing } else if init { ts.ParaSpacing.Val = 0 } return } ts.ParaSpacing.SetIFace(val, key) }, "tab-size": func(obj interface{}, key string, val interface{}, par interface{}, ctxt Context) { ts := obj.(*Text) if inh, init := StyleInhInit(val, par); inh || init { if inh { ts.TabSize = par.(*Text).TabSize } else if init { ts.TabSize = 4 } return } if iv, ok := kit.ToInt(val); ok { ts.TabSize = int(iv) } }, }
StyleTextFuncs are functions for styling the Text object
Functions ¶
func CopyGradient ¶
CopyGradient copies a gradient, making new copies of the stops instead of re-using pointers
func FixFontMods ¶
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 FixGradientStops ¶
FixGradientStops applies the CSS rules to regularize the gradient stops: https://www.w3.org/TR/css3-images/#color-stop-syntax
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 HSLSortedColorNames ¶ added in v1.2.3
func HSLSortedColorNames() []string
HSLSortedColorNames returns color names sorted first by overall lightness and saturation, then hue within that. This is cached after first call, so it will be fast to call after that point.
func HSLtoRGBf32 ¶
HSLtoRGBf32 converts HSL values to RGB float32 0..1 values (non alpha-premultiplied) -- based on https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion, https://www.w3.org/TR/css-color-3/ and github.com/lucasb-eyer/go-colorful
func IsAlignEnd ¶
is this a generalized alignment to end of container?
func IsAlignMiddle ¶
is this a generalized alignment to middle of container?
func IsAlignStart ¶
is this a generalized alignment to start of container?
func ParseDashesString ¶
ParseDashesString gets a dash slice from given string
func RGBtoHSLf32 ¶
RGBtoHSLf32 converts RGB 0..1 values (non alpha-premultiplied) to HSL -- based on https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion, https://www.w3.org/TR/css-color-3/ and github.com/lucasb-eyer/go-colorful
func SetGradientBounds ¶
SetGradientBounds sets bounds of the gradient
func SetStylePropsXML ¶
SetStylePropsXML sets style props from XML style string, which contains ';' separated name: value pairs
func StyleInhInit ¶
func StyleInhInit(val, par interface{}) (inh, init bool)
StyleInhInit detects the style values of "inherit" and "initial", setting the corresponding bool return values
func StylePropsXML ¶ added in v1.2.0
StylePropsXML returns style props for XML style string, which contains ';' separated name: value pairs
func StyleSetError ¶
func StyleSetError(key string, val interface{})
StyleSetError reports that cannot set property of given key with given value
Types ¶
type Align ¶
type Align int32
Align has all different types of alignment -- only some are applicable to different contexts, but there is also so much overlap that it makes sense to have them all in one list -- some are not standard CSS and used by layout
const ( AlignLeft Align = iota AlignTop AlignCenter // middle = vertical version of center AlignMiddle AlignRight AlignBottom AlignBaseline // same as CSS space-between AlignJustify AlignSpaceAround AlignFlexStart AlignFlexEnd AlignTextTop AlignTextBottom // align to subscript AlignSub // align to superscript AlignSuper AlignN )
func (*Align) FromString ¶
func (Align) MarshalJSON ¶
func (*Align) UnmarshalJSON ¶
type BaselineShifts ¶
type BaselineShifts int32
BaselineShifts are for super / sub script
const ( ShiftBaseline BaselineShifts = iota ShiftSuper ShiftSub BaselineShiftsN )
func (*BaselineShifts) FromString ¶
func (i *BaselineShifts) FromString(s string) error
func (BaselineShifts) MarshalJSON ¶
func (ev BaselineShifts) MarshalJSON() ([]byte, error)
func (BaselineShifts) String ¶
func (i BaselineShifts) String() string
func (*BaselineShifts) UnmarshalJSON ¶
func (ev *BaselineShifts) UnmarshalJSON(b []byte) error
type Border ¶
type Border struct { Style BorderStyles `xml:"style" desc:"prop: border-style = how to draw the border"` Width units.Value `xml:"width" desc:"prop: border-width = width of the border"` Radius units.Value `xml:"radius" desc:"prop: border-radius = rounding of the corners"` Color Color `xml:"color" desc:"prop: border-color = color of the border"` }
Border contains style parameters for borders
type BorderStyles ¶
type BorderStyles int32
BorderStyles determines how to draw the border
const ( BorderSolid BorderStyles = iota BorderDotted BorderDashed BorderDouble BorderGroove BorderRidge BorderInset BorderOutset BorderNone BorderHidden BorderN )
func (*BorderStyles) FromString ¶
func (i *BorderStyles) FromString(s string) error
func (BorderStyles) MarshalJSON ¶
func (ev BorderStyles) MarshalJSON() ([]byte, error)
func (BorderStyles) String ¶
func (i BorderStyles) String() string
func (*BorderStyles) UnmarshalJSON ¶
func (ev *BorderStyles) UnmarshalJSON(b []byte) error
type BoxSides ¶
type BoxSides int32
BoxSides specifies sides of a box -- some properties can be specified per each side (e.g., border) or not
func (*BoxSides) FromString ¶
func (BoxSides) MarshalJSON ¶
func (*BoxSides) UnmarshalJSON ¶
type Color ¶
type Color struct {
R, G, B, A uint8
}
Color extends image/color.RGBA with more methods for converting to / from strings etc -- it has standard uint8 0..255 color values
func ColorFromColor ¶ added in v1.2.3
ColorFromColor returns a new gist.Color from image/color.Color
func ColorFromName ¶
ColorFromName returns a new color set from given name.
func ColorFromString ¶
ColorFromString returns a new color set from given string and optional base color for transforms -- see SetString
func (*Color) Blend ¶
Blend returns a color that is the given percent blend between current color and given clr -- 10 = 10% of the clr and 90% of the current color, etc -- blending is done directly on non-pre-multiplied RGB values
func (*Color) Clearer ¶
Clearer returns a color that is given percent more transparent (lower alpha value) relative to current alpha level
func (*Color) Darker ¶
Darker returns a color that is darker by the given percent, e.g., 50 = 50% darker, relative to maximum possible darkness -- converts to HSL, multiplies the L factor, and then converts back to RGBA
func (*Color) HexString ¶
HexString returns colors using standard 2-hexadecimal-digits-per-component string
func (*Color) Highlight ¶
Highlight returns a color that is either lighter or darker by the given percent, e.g., 50 = 50% change relative to maximum possible lightness, depending on how light the color is already -- if lightness > 50% then goes darker, and vice-versa
func (*Color) Inverse ¶ added in v1.2.2
Inverse returns inverse current color (255 - each component) does not change the alpha channel.
func (*Color) IsDark ¶
IsDark checks if HSL lightness value is < .6, which is a good value for distinguishing when white vs. black text should be used as a contrast color.
func (*Color) IsNil ¶
IsNil checks if color is the nil initial default color -- a = 0 means fully transparent black
func (*Color) Lighter ¶
Lighter returns a color that is lighter by the given percent, e.g., 50 = 50% lighter, relative to maximum possible lightness -- converts to HSL, multiplies the L factor, and then converts back to RGBA
func (*Color) Opaquer ¶
Opaquer returns a color that is given percent more opaque (higher alpha value) relative to current alpha level
func (*Color) Pastel ¶
Pastel returns a color that is less saturated (more pastel-like) by the given percent: 100 = 100% less saturated (i.e., grey) -- converts to HSL, multiplies the S factor, and then converts back to RGBA
func (*Color) Samelight ¶
Samelight is the opposite of Highlight -- makes a color darker if already darker than 50%, and lighter if already lighter than 50%
func (*Color) Saturate ¶
Saturate returns a color that is more saturated by the given percent: 100 = 100% more saturated, etc -- converts to HSL, multiplies the S factor, and then converts back to RGBA
func (*Color) SetAlphaPreFix ¶
AlphaPreFix detects if the color is not alpha-premultiplied (i.e., any RGB > A), and converts to alpha-premultiplied if so. Returns true if fixed.
func (*Color) SetAlphaPreMult ¶
SetAlphaPreMult converts a non-alpha-premultiplied color to a premultiplied one. Returns true if a change was made (i.e., if A < 255).
func (*Color) SetFloat32 ¶
SetFloat32 converts from 0-1 normalized floating point numbers (alpha-premultiplied)
func (*Color) SetFloat64 ¶
SetFloat64 convert from 0-1 normalized floating point numbers (alpha-premultiplied)
func (*Color) SetHSL ¶
SetHSL converts from HSL: [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values
func (*Color) SetHSLA ¶
SetHSLA converts from HSLA: [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values
func (*Color) SetIFace ¶
SetIFace sets the color from given interface value, e.g., for ki.Props key is an optional property key for error -- always logs errors
func (*Color) SetNPFloat32 ¶
SetNPFloat converts from 0-1 normalized floating point numbers, non alpha-premultiplied
func (*Color) SetName ¶
SetName sets color value from a standard color name. returns error if name not found. use ColorName type to present user with a chooser.
func (*Color) SetNotAlphaPreMult ¶
SetNotAlphaPreMult converts a alpha-premultiplied color to a non-premultiplied one. Returns true if a change was made (i.e., if A < 255).
func (*Color) SetString ¶
SetString sets color value from string, including # hex specs, standard color names, "none" or "off", or the following transformations (which use a non-nil base color as the starting point, if it is provided): inverse = inverse of base color
* lighter-PCT or darker-PCT: PCT is amount to lighten or darken (using HSL), e.g., 10=10% * saturate-PCT or pastel-PCT: manipulates the saturation level in HSL by PCT * clearer-PCT or opaquer-PCT: manipulates the alpha level by PCT * blend-PCT-color: blends given percent of given color name relative to base (or current)
func (*Color) SetStringStyle ¶
SetStringStyle is the version of SetString used for styling. it includes advanced support for contextual names such as "currentcolor"
func (*Color) SetUInt32 ¶
SetUInt32 sets components from unsigned 32bit integers (alpha-premultiplied)
func (*Color) SetUInt8 ¶
SetUInt8 sets components from unsigned 8 bit integers (alpha-premultiplied)
func (*Color) ToFloat32 ¶
ToFloat32 converts to 0-1 normalized floating point numbers, still alpha-premultiplied
func (*Color) ToHSLA ¶
ToHSLA converts to HSLA: [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values
func (*Color) ToNPFloat32 ¶
ToNPFloat32 converts to 0-1 normalized floating point numbers, not alpha premultiplied
type ColorSources ¶
type ColorSources int32
ColorSources determine how the color is generated -- used in FillStyle and StrokeStyle
const ( SolidColor ColorSources = iota LinearGradient RadialGradient ColorSourcesN )
func (*ColorSources) FromString ¶
func (i *ColorSources) FromString(s string) error
func (ColorSources) MarshalJSON ¶
func (ev ColorSources) MarshalJSON() ([]byte, error)
func (ColorSources) String ¶
func (i ColorSources) String() string
func (*ColorSources) UnmarshalJSON ¶
func (ev *ColorSources) UnmarshalJSON(b []byte) error
type ColorSpec ¶
type ColorSpec struct { Source ColorSources `desc:"source of color (solid, gradient)"` Color Color `desc:"color for solid color source"` Gradient *rasterx.Gradient `desc:"gradient parameters for gradient color source"` }
ColorSpec fully specifies the color for rendering -- used in FillStyle and StrokeStyle
func (*ColorSpec) ApplyXForm ¶ added in v1.2.0
ApplyXForm transforms the points for a UserSpaceOnUse gradient
func (*ColorSpec) ApplyXFormPt ¶ added in v1.2.0
ApplyXFormPt transforms the points for a UserSpaceOnUse gradient relative to a given center point
func (*ColorSpec) ColorOrNil ¶
ColorOrNil returns the solid color if non-nil, or nil otherwise -- for consumers that handle nil colors
func (*ColorSpec) CopyFrom ¶
Copy copies a gradient, making new copies of the stops instead of re-using pointers
func (*ColorSpec) CopyStopsFrom ¶ added in v1.2.0
CopyStopsFrom copies gradient stops from other color spec, if both have gradient stops
func (*ColorSpec) NewLinearGradient ¶ added in v1.2.3
func (cs *ColorSpec) NewLinearGradient()
NewLinearGradient creates a new Linear gradient in spec, sets Source to LinearGradient.
func (*ColorSpec) NewRadialGradient ¶ added in v1.2.3
func (cs *ColorSpec) NewRadialGradient()
NewRadialGradient creates a new Radial gradient in spec, sets Source to RadialGradient.
func (*ColorSpec) RenderColor ¶
func (cs *ColorSpec) RenderColor(opacity float32, bounds image.Rectangle, xform mat32.Mat2) interface{}
RenderColor gets the color for rendering, applying opacity and bounds for gradients
func (*ColorSpec) SetGradientPoints ¶ added in v1.2.3
SetGradientPoints sets UserSpaceOnUse points for gradient based on given bounding box
func (*ColorSpec) SetIFace ¶
SetIFace sets the color spec from given interface value, e.g., for ki.Props key is an optional property key for error -- always logs errors
func (*ColorSpec) SetShadowGradient ¶
SetShadowGradient sets a linear gradient starting at given color and going down to transparent based on given color and direction spec (defaults to "to down")
func (*ColorSpec) SetString ¶
SetString sets the color spec from a standard CSS-formatted string -- see https://www.w3schools.com/css/css3_gradients.asp -- see UnmarshalXML for XML-based version
func (*ColorSpec) UnmarshalXML ¶
UnmarshalXML parses the given XML-formatted string to set the color specification
type Context ¶
type Context interface { // ContextColor returns the current Color activated in the context. // Color has support for special color names that are relative to // this current color. ContextColor() Color // ContextColorSpecByURL returns a ColorSpec from given URL expression // used in color specifications: url(#name) is typical, where name // is the name of a node with a ColorSpec in it. ContextColorSpecByURL(url string) *ColorSpec }
Context provides external contextual information needed for styles
type Fill ¶
type Fill struct { On bool `desc:"is fill active -- if property is none then false"` Color ColorSpec `xml:"fill" desc:"prop: fill = fill color specification"` Opacity float32 `xml:"fill-opacity" desc:"prop: fill-opacity = global alpha opacity / transparency factor"` Rule FillRules `xml:"fill-rule" desc:"prop: fill-rule = rule for how to fill more complex shapes with crossing lines"` }
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) SetColorSpec ¶
SetColorSpec sets full color spec from source
func (*Fill) SetStylePost ¶
SetStylePost does some updating after setting the style from user properties
type FillRules ¶
type FillRules int
func (*FillRules) FromString ¶
func (FillRules) MarshalJSON ¶
func (*FillRules) UnmarshalJSON ¶
type Font ¶
type Font struct { Color Color `xml:"color" inherit:"true" desc:"prop: color (inherited) = text color -- also defines the currentColor variable value"` BgColor ColorSpec `xml:"background-color" desc:"prop: background-color = background color -- not inherited, transparent by default"` Opacity float32 `xml:"opacity" desc:"prop: opacity = alpha value to apply to all elements"` Size units.Value `` /* 135-byte string literal not displayed */ Family string `` /* 181-byte string literal not displayed */ Style FontStyles `xml:"font-style" inherit:"true" desc:"prop: font-style = style -- normal, italic, etc"` Weight FontWeights `xml:"font-weight" inherit:"true" desc:"prop: font-weight = weight: normal, bold, etc"` Stretch FontStretch `xml:"font-stretch" inherit:"true" desc:"prop: font-stretch = font stretch / condense options"` Variant FontVariants `xml:"font-variant" inherit:"true" desc:"prop: font-variant = normal or small caps"` Deco TextDecorations `xml:"text-decoration" desc:"prop: text-decoration = underline, line-through, etc -- not inherited"` Shift BaselineShifts `xml:"baseline-shift" desc:"prop: baseline-shift = super / sub script -- not inherited"` Face *FontFace `` /* 157-byte string literal not displayed */ Rem float32 `desc:"Rem size of font -- 12pt converted to same effective DPI as above measurements"` }
Font contains all font styling information, including everything that is used in SVG text rendering -- used in Paint and in Style. Most of font information is inherited.
func (*Font) ClearDeco ¶
func (fs *Font) ClearDeco(deco TextDecorations)
ClearDeco clears decoration (underline, etc), which uses bitflag to allow multiple combinations
func (*Font) CopyNonDefaultProps ¶
CopyNonDefaultProps does SetProp on given node for all of the style settings that are not at their default values.
func (*Font) InheritFields ¶
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) SetStylePost ¶
SetStylePost does any updates after generic xml-tag property setting -- use for anything that also has non-standard values that might not be processed properly by default
func (*Font) SetStyleProps ¶
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 ¶
SetUnitContext sets the font-specific information in the given units.Context, based on the currently-loaded face.
func (*Font) StyleFromProps ¶
type FontFace ¶
type FontFace struct { Name string `desc:"The full FaceName that the font is accessed by"` Size int `desc:"The integer font size in raw dots"` Face font.Face `desc:"The system image.Font font rendering interface"` Metrics FontMetrics `desc:"enhanced metric information for the font"` }
FontFace is our enhanced Font Face structure which contains the enhanced computed metrics in addition to the font.Face face
func NewFontFace ¶
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 { Height float32 `` /* 180-byte string literal not displayed */ Em float32 `` /* 242-byte string literal not displayed */ Ex float32 `desc:"Ex size of font -- this is the actual height of the letter x in the font"` Ch float32 `desc:"Ch size of font -- this is the actual width of the 0 glyph in the font"` }
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 FontStretch ¶
type FontStretch int32
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 FontStretchN )
func (*FontStretch) FromString ¶
func (i *FontStretch) FromString(s string) error
func (FontStretch) MarshalJSON ¶
func (ev FontStretch) MarshalJSON() ([]byte, error)
func (FontStretch) String ¶
func (i FontStretch) String() string
func (*FontStretch) UnmarshalJSON ¶
func (ev *FontStretch) UnmarshalJSON(b []byte) error
type FontStyles ¶
type FontStyles int32
FontStyles styles of font: normal, italic, etc
const ( FontNormal FontStyles = iota FontItalic FontOblique FontStylesN )
func (*FontStyles) FromString ¶
func (i *FontStyles) FromString(s string) error
func (FontStyles) MarshalJSON ¶
func (ev FontStyles) MarshalJSON() ([]byte, error)
func (FontStyles) String ¶
func (i FontStyles) String() string
func (*FontStyles) UnmarshalJSON ¶
func (ev *FontStyles) UnmarshalJSON(b []byte) error
type FontVariants ¶
type FontVariants int32
FontVariants is just normal vs. small caps. todo: not currently supported
const ( FontVarNormal FontVariants = iota FontVarSmallCaps FontVariantsN )
func (*FontVariants) FromString ¶
func (i *FontVariants) FromString(s string) error
func (FontVariants) MarshalJSON ¶
func (ev FontVariants) MarshalJSON() ([]byte, error)
func (FontVariants) String ¶
func (i FontVariants) String() string
func (*FontVariants) UnmarshalJSON ¶
func (ev *FontVariants) UnmarshalJSON(b []byte) error
type FontWeights ¶
type FontWeights int32
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 FontWeightsN )
func (*FontWeights) FromString ¶
func (i *FontWeights) FromString(s string) error
func (FontWeights) MarshalJSON ¶
func (ev FontWeights) MarshalJSON() ([]byte, error)
func (FontWeights) String ¶
func (i FontWeights) String() string
func (*FontWeights) UnmarshalJSON ¶
func (ev *FontWeights) UnmarshalJSON(b []byte) error
type GradientPoints ¶
type GradientPoints int32
GradientPoints defines points within the gradient
const ( GpX1 GradientPoints = iota GpY1 GpX2 GpY2 GradientPointsN )
type HSLA ¶
type HSLA struct {
H, S, L, A float32
}
HSLA represents the Hue [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values
type Layout ¶
type Layout struct { ZIndex int `` /* 146-byte string literal not displayed */ AlignH Align `` /* 297-byte string literal not displayed */ AlignV Align `` /* 300-byte string literal not displayed */ PosX units.Value `xml:"x" desc:"prop: x = horizontal position -- often superseded by layout but otherwise used"` PosY units.Value `xml:"y" desc:"prop: y = vertical position -- often superseded by layout but otherwise used"` Width units.Value `xml:"width" desc:"prop: width = specified size of element -- 0 if not specified"` Height units.Value `xml:"height" desc:"prop: height = specified size of element -- 0 if not specified"` MaxWidth units.Value `` /* 132-byte string literal not displayed */ MaxHeight units.Value `` /* 133-byte string literal not displayed */ MinWidth units.Value `xml:"min-width" desc:"prop: min-width = specified minimum size of element -- 0 if not specified"` MinHeight units.Value `xml:"min-height" desc:"prop: min-height = specified minimum size of element -- 0 if not specified"` Margin units.Value `xml:"margin" desc:"prop: margin = outer-most transparent space around box element -- todo: can be specified per side"` Padding units.Value `` /* 201-byte string literal not displayed */ Overflow Overflow `` /* 164-byte string literal not displayed */ Columns int `` /* 194-byte string literal not displayed */ Row int `xml:"row" desc:"prop: row = specifies the row that this element should appear within a grid layout"` Col int `xml:"col" desc:"prop: col = specifies the column that this element should appear within a grid layout"` RowSpan int `` /* 163-byte string literal not displayed */ ColSpan int `` /* 134-byte string literal not displayed */ ScrollBarWidth units.Value `xml:"scrollbar-width" desc:"prop: scrollbar-width = width of a layout scrollbar"` }
Layout contains style preferences on the layout of the element.
func (*Layout) SetStylePost ¶
type LineCaps ¶
type LineCaps int
end-cap of a line: stroke-linecap property in SVG
func (*LineCaps) FromString ¶
func (LineCaps) MarshalJSON ¶
func (*LineCaps) UnmarshalJSON ¶
type LineJoins ¶
type LineJoins int
the way in which lines are joined together: stroke-linejoin property in SVG
func (*LineJoins) FromString ¶
func (LineJoins) MarshalJSON ¶
func (*LineJoins) UnmarshalJSON ¶
type NRGBAf32 ¶
type NRGBAf32 struct {
R, G, B, A float32
}
NRGBAf32 stores non-alpha-premultiplied RGBA values in float32 0..1 normalized format -- more useful for converting to other spaces
type Overflow ¶
type Overflow int32
overflow type -- determines what happens when there is too much stuff in a layout
const ( // 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. Typically, an outer-most Layout will scale // up and add scrollbars to accommodate the Min needs of its child elements, // so if you want to have scrollbars show up on inner elements, they need to // have a style setting that restricts their Min size, but also allows them to // stretch so they use whatever space they are allocated. OverflowAuto Overflow = iota // OverflowScroll means add scrollbars when necessary, and is essentially // identical to Auto. However, only during Viewport PrefSize call, // the actual content size is used -- otherwise it behaves just like Auto. OverflowScroll // OverflowVisible makes the overflow visible -- this is generally unsafe // and not very feasible and will be ignored as long as possible. // Currently it falls back on Auto, but could go to Hidden if that works // better overall. OverflowVisible // OverflowHidden hides the overflow and doesn't present scrollbars (supported). OverflowHidden OverflowN )
func (*Overflow) FromString ¶
func (Overflow) MarshalJSON ¶
func (*Overflow) UnmarshalJSON ¶
type Paint ¶
type Paint struct { Off bool `desc:"prop: display:none -- node and everything below it are off, non-rendering"` Display bool `xml:"display" desc:"todo big enum of how to display item -- controls layout etc"` StrokeStyle Stroke `desc:"stroke (line drawing) parameters"` FillStyle Fill `desc:"fill (region filling) parameters"` FontStyle Font `` /* 146-byte string literal not displayed */ TextStyle Text `` /* 146-byte string literal not displayed */ VecEff VectorEffects `xml:"vector-effect" desc:"prop: vector-effect = various rendering special effects settings"` XForm mat32.Mat2 `xml:"transform" desc:"prop: transform = our additions to transform -- pushed to render state"` UnContext units.Context `xml:"-" desc:"units context -- parameters necessary for anchoring relative units"` StyleSet bool `desc:"have the styles already been set?"` PropsNil bool `desc:"set to true if parent node has no props -- allows optimization of styling"` // contains filtered or unexported fields }
Paint provides the styling parameters for rendering
func (*Paint) CopyStyleFrom ¶
CopyStyleFrom copies styles from another paint
func (*Paint) HasNoStrokeOrFill ¶
does the current Paint not have either a stroke or fill? in which case, often we just skip it
func (*Paint) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Paint) SetStyleProps ¶
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 ¶
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 ¶
StyleFromProps sets style field values based on ki.Props properties
func (*Paint) StyleToDots ¶
StyleToDots runs ToDots on unit values, to compile down to raw pixels
func (*Paint) ToDots ¶
func (pc *Paint) ToDots()
ToDots runs ToDots on unit values, to compile down to raw pixels
func (*Paint) ToDotsImpl ¶
ToDotsImpl runs ToDots on unit values, to compile down to raw pixels
type Painter ¶
type Painter interface {
Paint() *Paint
}
Painter defines an interface for anything that has a Paint style on it
type Prefs ¶
type Prefs interface { // PrefColor returns preference color of given name // std names are: font, background, shadow, border, control, icon, select, highlight, link // nil if not found PrefColor(name string) *Color // PrefFontFamily returns the default FontFamily PrefFontFamily() string }
Prefs defines the interface to preferences for style-relevant prefs
var ThePrefs Prefs
ThePrefs is the prefs object to use to get preferences
type RGBAf32 ¶
type RGBAf32 struct {
R, G, B, A float32
}
RGBAf32 stores alpha-premultiplied RGBA values in float32 0..1 normalized format -- more useful for converting to other spaces
type Shadow ¶
type Shadow struct { HOffset units.Value `xml:".h-offset" desc:"prop: .h-offset = horizontal offset of shadow -- positive = right side, negative = left side"` VOffset units.Value `xml:".v-offset" desc:"prop: .v-offset = vertical offset of shadow -- positive = below, negative = above"` Blur units.Value `xml:".blur" desc:"prop: .blur = blur radius -- higher numbers = more blurry"` Spread units.Value `xml:".spread" desc:"prop: .spread = spread radius -- positive number increases size of shadow, negative decreases size"` Color Color `xml:".color" desc:"prop: .color = color of the shadow"` Inset bool `xml:".inset" desc:"prop: .inset = shadow is inset within box instead of outset outside of box"` }
style parameters for shadows
type SizePrefs ¶
type SizePrefs struct { Need mat32.Vec2 `desc:"minimum size needed -- set to at least computed allocsize"` Pref mat32.Vec2 `desc:"preferred size -- start here for layout"` Max mat32.Vec2 `desc:"maximum size -- will not be greater than this -- 0 = no constraint, neg = stretch"` }
SizePrefs represents size preferences
func (SizePrefs) CanStretchNeed ¶
return true if Pref > Need meaning can stretch more along given dimension
type Stroke ¶
type Stroke struct { On bool `desc:"is stroke active -- if property is none then false"` Color ColorSpec `xml:"stroke" desc:"prop: stroke = stroke color specification"` Opacity float32 `xml:"stroke-opacity" desc:"prop: stroke-opacity = global alpha opacity / transparency factor"` Width units.Value `xml:"stroke-width" desc:"prop: stroke-width = line width"` MinWidth units.Value `` /* 332-byte string literal not displayed */ Dashes []float64 `` /* 242-byte string literal not displayed */ Cap LineCaps `xml:"stroke-linecap" desc:"prop: stroke-linecap = how to draw the end cap of lines"` Join LineJoins `xml:"stroke-linejoin" desc:"prop: stroke-linejoin = how to join line segments"` MiterLimit float32 `xml:"stroke-miterlimit" min:"1" desc:"prop: stroke-miterlimit = limit of how far to miter -- must be 1 or larger"` }
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) SetColorSpec ¶
SetColorSpec sets full color spec from source
func (*Stroke) SetStylePost ¶
SetStylePost does some updating after setting the style from user properties
type Style ¶
type Style struct { Template string `` /* 162-byte string literal not displayed */ Display bool `xml:"display" desc:"todo big enum of how to display item -- controls layout etc"` Visible bool `xml:"visible" desc:"is the item visible or not"` Inactive bool `xml:"inactive" desc:"make a control inactive so it does not respond to input"` Layout Layout `desc:"layout styles -- do not prefix with any xml"` Border Border `xml:"border" desc:"border around the box element -- todo: can have separate ones for different sides"` BoxShadow Shadow `xml:"box-shadow" desc:"prop: box-shadow = type of shadow to render around box"` Font Font `desc:"font parameters -- no xml prefix -- also has color, background-color"` Text Text `desc:"text parameters -- no xml prefix"` Outline Border `xml:"outline" desc:"prop: outline = draw an outline around an element -- mostly same styles as border -- default to none"` PointerEvents bool `xml:"pointer-events" desc:"prop: pointer-events = does this element respond to pointer events -- default is true"` UnContext units.Context `xml:"-" desc:"units context -- parameters necessary for anchoring relative units"` IsSet bool `desc:"has this style been set from object values yet?"` PropsNil bool `desc:"set to true if parent node has no props -- allows optimization of styling"` // contains filtered or unexported fields }
Style has all the CSS-based style elements -- used for widget-type objects
var StyleDefault Style
StyleDefault is default style can be used when property specifies "default"
func (*Style) BoxSpace ¶
BoxSpace returns extra space around the central content in the box model, in dots -- todo: must complicate this if we want different spacing on different sides box outside-in: margin | border | padding | content
func (*Style) CopyUnitContext ¶
CopyUnitContext copies unit context from another, update with our font info, and then cache everything out in terms of raw pixel dots for rendering -- call at start of render
func (*Style) FromTemplate ¶
FromTemplate checks if there is a template for this style, returning false for hasTemplate if not (in which case usual styling should proceed). If there is a template, and it has already been saved, the style is copied from the existing template. If there is a template name set but no existing template has yet been saved, then saveTemplate = true and the SaveTemplate call should be made on this style after it has gone through the usual styling process.
func (*Style) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Style) SaveTemplate ¶
func (s *Style) SaveTemplate()
SaveTemplate should only be called for styles that have template but none has yet been saved, as determined by FromTemplate call.
func (*Style) SetStyleProps ¶
SetStyleProps sets style values based on given property map (name: value pairs), inheriting elements as appropriate from parent
func (*Style) StyleFromProps ¶
StyleFromProps sets style field values based on ki.Props properties
func (*Style) StyleToDots ¶
StyleToDots runs ToDots on unit values, to compile down to raw pixels
func (*Style) ToDots ¶
func (s *Style) ToDots()
ToDots caches all style elements in terms of raw pixel dots for rendering.
func (*Style) ToDotsImpl ¶
ToDotsImpl runs ToDots on unit values, to compile down to raw pixels
type Styler ¶
type Styler interface { Style() *Style // StyleRLock does a read-lock for reading the style StyleRLock() // StyleRUnlock unlocks the read-lock StyleRUnlock() }
Styler defines an interface for anything that has a Style on it
type Text ¶
type Text struct { Align Align `` /* 346-byte string literal not displayed */ AlignV Align `` /* 285-byte string literal not displayed */ Anchor TextAnchors `` /* 216-byte string literal not displayed */ LetterSpacing units.Value `xml:"letter-spacing" desc:"prop: letter-spacing = spacing between characters and lines"` WordSpacing units.Value `xml:"word-spacing" inherit:"true" desc:"prop: word-spacing (inherited) = extra space to add between words"` LineHeight float32 `` /* 308-byte string literal not displayed */ WhiteSpace WhiteSpaces `` /* 128-byte string literal not displayed */ UnicodeBidi UnicodeBidi `` /* 131-byte string literal not displayed */ Direction TextDirections `` /* 178-byte string literal not displayed */ WritingMode TextDirections `` /* 131-byte string literal not displayed */ OrientationVert float32 `` /* 230-byte string literal not displayed */ OrientationHoriz float32 `` /* 214-byte string literal not displayed */ Indent units.Value `xml:"text-indent" inherit:"true" desc:"prop: text-indent (inherited) = how much to indent the first line in a paragraph"` ParaSpacing units.Value `` /* 218-byte string literal not displayed */ TabSize int `xml:"tab-size" inherit:"true" desc:"prop: tab-size (inherited) = tab size, in number of characters"` }
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 ¶
AlignFactors gets basic text alignment factors
func (*Text) EffLineHeight ¶
EffLineHeight returns the effective line height (taking into account 0 value)
func (*Text) HasPre ¶
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 ¶
HasWordWrap returns true if current white space option supports word wrap
func (*Text) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Text) SetStylePost ¶
SetStylePost applies any updates after generic xml-tag property setting
type TextAnchors ¶
type TextAnchors int32
TextAnchors are for direction of text writing, used in direction and writing-mode styles
const ( AnchorStart TextAnchors = iota AnchorMiddle AnchorEnd TextAnchorsN )
func (*TextAnchors) FromString ¶
func (i *TextAnchors) FromString(s string) error
func (TextAnchors) MarshalJSON ¶
func (ev TextAnchors) MarshalJSON() ([]byte, error)
func (TextAnchors) String ¶
func (i TextAnchors) String() string
func (*TextAnchors) UnmarshalJSON ¶
func (ev *TextAnchors) UnmarshalJSON(b []byte) error
type TextDecorations ¶
type TextDecorations int32
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 // DecoBgColor indicates that a bg color has been set -- for use in optimizing rendering DecoBgColor TextDecorationsN )
func (*TextDecorations) FromString ¶
func (i *TextDecorations) FromString(s string) error
func (TextDecorations) MarshalJSON ¶
func (ev TextDecorations) MarshalJSON() ([]byte, error)
func (TextDecorations) String ¶
func (i TextDecorations) String() string
func (*TextDecorations) UnmarshalJSON ¶
func (ev *TextDecorations) UnmarshalJSON(b []byte) error
type TextDirections ¶
type TextDirections int32
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 TextDirectionsN )
func (*TextDirections) FromString ¶
func (i *TextDirections) FromString(s string) error
func (TextDirections) MarshalJSON ¶
func (ev TextDirections) MarshalJSON() ([]byte, error)
func (TextDirections) String ¶
func (i TextDirections) String() string
func (*TextDirections) UnmarshalJSON ¶
func (ev *TextDirections) UnmarshalJSON(b []byte) error
type UnicodeBidi ¶
type UnicodeBidi int32
https://godoc.org/golang.org/x/text/unicode/bidi UnicodeBidi determines how
const ( BidiNormal UnicodeBidi = iota BidiEmbed BidiBidiOverride UnicodeBidiN )
func (*UnicodeBidi) FromString ¶
func (i *UnicodeBidi) FromString(s string) error
func (UnicodeBidi) MarshalJSON ¶
func (ev UnicodeBidi) MarshalJSON() ([]byte, error)
func (UnicodeBidi) String ¶
func (i UnicodeBidi) String() string
func (*UnicodeBidi) UnmarshalJSON ¶
func (ev *UnicodeBidi) UnmarshalJSON(b []byte) error
type VectorEffects ¶
type VectorEffects int32
VectorEffects contains special effects for rendering
const ( VecEffNone VectorEffects = iota // VecEffNonScalingStroke means that the stroke width is not affected by // transform properties VecEffNonScalingStroke VecEffN )
func (*VectorEffects) FromString ¶
func (i *VectorEffects) FromString(s string) error
func (VectorEffects) MarshalJSON ¶
func (ev VectorEffects) MarshalJSON() ([]byte, error)
func (VectorEffects) String ¶
func (i VectorEffects) String() string
func (*VectorEffects) UnmarshalJSON ¶
func (ev *VectorEffects) UnmarshalJSON(b []byte) error
type WhiteSpaces ¶
type WhiteSpaces int32
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 WhiteSpaceNormal WhiteSpaces = iota // WhiteSpaceNowrap means that sequences of whitespace will collapse into // a single whitespace. Text will never wrap to the next line. The text // continues on the same line until a <br> tag is encountered 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 WhiteSpacesN )
func (*WhiteSpaces) FromString ¶
func (i *WhiteSpaces) FromString(s string) error
func (WhiteSpaces) MarshalJSON ¶
func (ev WhiteSpaces) MarshalJSON() ([]byte, error)
func (WhiteSpaces) String ¶
func (i WhiteSpaces) String() string
func (*WhiteSpaces) UnmarshalJSON ¶
func (ev *WhiteSpaces) UnmarshalJSON(b []byte) error
Source Files ¶
- align_string.go
- baselineshifts_string.go
- borderstyles_string.go
- box.go
- boxsides_string.go
- color.go
- colorparse.go
- colorsources_string.go
- colorspec.go
- context.go
- doc.go
- fillrules_string.go
- font.go
- fontmetrics.go
- fontstretch_string.go
- fontstyles_string.go
- fontvariants_string.go
- fontweights_string.go
- layout.go
- linecaps_string.go
- linejoins_string.go
- overflow_string.go
- paint.go
- paint_props.go
- prefs.go
- style.go
- style_props.go
- text.go
- textanchors_string.go
- textdecorations_string.go
- textdirections_string.go
- unicodebidi_string.go
- vectoreffects_string.go
- whitespaces_string.go