Standard Node infrastructure Style styles the Paint values directly from node properties
(sv *SVG)
| 313 | |
| 314 | // Style styles the Paint values directly from node properties |
| 315 | func (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 |
| 348 | func AggCSS(agg *map[string]any, css map[string]any) { |
nothing calls this directly
no test coverage detected