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

Method Render

svg/rect.go:51–73  ·  view source on GitHub ↗
(sv *SVG)

Source from the content-addressed store, hash-verified

49}
50
51func (g *Rect) Render(sv *SVG) {
52 vis, pc := g.PushTransform(sv)
53 if !vis {
54 return
55 }
56 // TODO: figure out a better way to do this
57 bs := styles.Border{}
58 bs.Style.Set(styles.BorderSolid)
59 bs.Width.Set(pc.StrokeStyle.Width)
60 bs.Color.Set(pc.StrokeStyle.Color)
61 bs.Radius.Set(units.Px(g.Radius.X))
62 if g.Radius.X == 0 && g.Radius.Y == 0 {
63 pc.DrawRectangle(g.Pos.X, g.Pos.Y, g.Size.X, g.Size.Y)
64 } else {
65 // todo: only supports 1 radius right now -- easy to add another
66 // SidesTODO: also support different radii for each corner
67 pc.DrawRoundedRectangle(g.Pos.X, g.Pos.Y, g.Size.X, g.Size.Y, styles.NewSideFloats(g.Radius.X))
68 }
69 pc.FillStrokeClear()
70 g.BBoxes(sv)
71 g.RenderChildren(sv)
72 pc.PopTransform()
73}
74
75// ApplyTransform applies the given 2D transform to the geometry of this node
76// each node must define this for itself

Callers

nothing calls this directly

Calls 10

PxFunction · 0.92
NewSideFloatsFunction · 0.92
DrawRectangleMethod · 0.80
DrawRoundedRectangleMethod · 0.80
FillStrokeClearMethod · 0.80
PopTransformMethod · 0.80
SetMethod · 0.65
BBoxesMethod · 0.65
PushTransformMethod · 0.45
RenderChildrenMethod · 0.45

Tested by

no test coverage detected