MCPcopy Create free account
hub / github.com/cogentcore/core / Style

Method Style

svg/node.go:315–345  ·  view source on GitHub ↗

Standard Node infrastructure Style styles the Paint values directly from node properties

(sv *SVG)

Source from the content-addressed store, hash-verified

313
314// Style styles the Paint values directly from node properties
315func (g *NodeBase) Style(sv *SVG) {
316 pc := &g.Paint
317 pc.Defaults()
318 ctxt := colors.Context(sv)
319 pc.StyleSet = false // this is always first call, restart
320
321 var parCSSAgg map[string]any
322 if g.Parent != nil { // && g.Par != sv.Root.This
323 pn := g.Parent.(Node)
324 parCSSAgg = pn.AsNodeBase().CSSAgg
325 pp := pn.AsNodeBase().PaintStyle()
326 pc.CopyStyleFrom(pp)
327 pc.SetStyleProperties(pp, g.Properties, ctxt)
328 } else {
329 pc.SetStyleProperties(nil, g.Properties, ctxt)
330 }
331 pc.ToDotsImpl(&pc.UnitContext) // we always inherit parent's unit context -- SVG sets it once-and-for-all
332
333 if parCSSAgg != nil {
334 AggCSS(&g.CSSAgg, parCSSAgg)
335 } else {
336 g.CSSAgg = nil
337 }
338 AggCSS(&g.CSSAgg, g.CSS)
339 g.StyleCSS(sv, g.CSSAgg)
340
341 pc.StrokeStyle.Opacity *= pc.FontStyle.Opacity // applies to all
342 pc.FillStyle.Opacity *= pc.FontStyle.Opacity
343
344 pc.Off = !pc.Display || (pc.StrokeStyle.Color == nil && pc.FillStyle.Color == nil)
345}
346
347// AggCSS aggregates css properties
348func AggCSS(agg *map[string]any, css map[string]any) {

Callers

nothing calls this directly

Calls 9

StyleCSSMethod · 0.95
ContextInterface · 0.92
AggCSSFunction · 0.85
PaintStyleMethod · 0.80
CopyStyleFromMethod · 0.80
DefaultsMethod · 0.65
AsNodeBaseMethod · 0.65
SetStylePropertiesMethod · 0.45
ToDotsImplMethod · 0.45

Tested by

no test coverage detected