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

Method ParTransform

svg/node.go:162–185  ·  view source on GitHub ↗

ParTransform returns the full compounded 2D transform matrix for all of the parents of this node. If self is true, then include our own transform too.

(self bool)

Source from the content-addressed store, hash-verified

160// of the parents of this node. If self is true, then include our
161// own transform too.
162func (g *NodeBase) ParTransform(self bool) math32.Matrix2 {
163 pars := []Node{}
164 xf := math32.Identity2()
165 n := g.This.(Node)
166 for {
167 if n.AsTree().Parent == nil {
168 break
169 }
170 n = n.AsTree().Parent.(Node)
171 pars = append(pars, n)
172 }
173 np := len(pars)
174 if np > 0 {
175 xf = pars[np-1].AsNodeBase().PaintStyle().Transform
176 }
177 for i := np - 2; i >= 0; i-- {
178 n := pars[i]
179 xf.SetMul(n.AsNodeBase().PaintStyle().Transform)
180 }
181 if self {
182 xf.SetMul(g.Paint.Transform)
183 }
184 return xf
185}
186
187// ApplyTransform applies the given 2D transform to the geometry of this node
188// this just does a direct transform multiplication on coordinates.

Callers 2

DeltaTransformMethod · 0.95
LocalBBoxToWinMethod · 0.95

Calls 5

Identity2Function · 0.92
PaintStyleMethod · 0.80
AsTreeMethod · 0.65
AsNodeBaseMethod · 0.65
SetMulMethod · 0.45

Tested by

no test coverage detected