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

Method ApplyDeltaTransform

svg/image.go:151–162  ·  view source on GitHub ↗

ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scal

(sv *SVG, trans math32.Vector2, scale math32.Vector2, rot float32, pt math32.Vector2)

Source from the content-addressed store, hash-verified

149// Point is upper left corner of selection box that anchors the translation and scaling,
150// and for rotation it is the center point around which to rotate
151func (g *Image) ApplyDeltaTransform(sv *SVG, trans math32.Vector2, scale math32.Vector2, rot float32, pt math32.Vector2) {
152 crot := g.Paint.Transform.ExtractRot()
153 if rot != 0 || crot != 0 {
154 xf, lpt := g.DeltaTransform(trans, scale, rot, pt, false) // exclude self
155 g.Paint.Transform.SetMulCenter(xf, lpt)
156 g.SetProperty("transform", g.Paint.Transform.String())
157 } else {
158 xf, lpt := g.DeltaTransform(trans, scale, rot, pt, true) // include self
159 g.Pos = xf.MulVector2AsPointCenter(g.Pos, lpt)
160 g.Size = xf.MulVector2AsVector(g.Size)
161 }
162}
163
164// WriteGeom writes the geometry of the node to a slice of floating point numbers
165// the length and ordering of which is specific to each node type.

Callers

nothing calls this directly

Calls 7

ExtractRotMethod · 0.80
DeltaTransformMethod · 0.80
SetMulCenterMethod · 0.80
SetPropertyMethod · 0.80
StringMethod · 0.65
MulVector2AsVectorMethod · 0.45

Tested by

no test coverage detected