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

Method ApplyCSS

svg/node.go:357–375  ·  view source on GitHub ↗

ApplyCSS applies css styles to given node, using key to select sub-properties from overall properties list

(sv *SVG, key string, css map[string]any)

Source from the content-addressed store, hash-verified

355// ApplyCSS applies css styles to given node,
356// using key to select sub-properties from overall properties list
357func (g *NodeBase) ApplyCSS(sv *SVG, key string, css map[string]any) bool {
358 pp, got := css[key]
359 if !got {
360 return false
361 }
362 pmap, ok := pp.(map[string]any) // must be a properties map
363 if !ok {
364 return false
365 }
366 pc := &g.Paint
367 ctxt := colors.Context(sv)
368 if g.Parent != sv.Root.This {
369 pp := g.Parent.(Node).AsNodeBase().PaintStyle()
370 pc.SetStyleProperties(pp, pmap, ctxt)
371 } else {
372 pc.SetStyleProperties(nil, pmap, ctxt)
373 }
374 return true
375}
376
377// StyleCSS applies css style properties to given SVG node
378// parsing out type, .class, and #name selectors

Callers 1

StyleCSSMethod · 0.95

Calls 4

ContextInterface · 0.92
PaintStyleMethod · 0.80
AsNodeBaseMethod · 0.65
SetStylePropertiesMethod · 0.45

Tested by

no test coverage detected