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

Method Render

tensor/tensorcore/simatgrid.go:119–237  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117}
118
119func (tg *SimMatGrid) Render() {
120 if tg.SimMat == nil || tg.SimMat.Mat.Len() == 0 {
121 return
122 }
123 tg.EnsureColorMap()
124 tg.UpdateRange()
125 pc := &tg.Scene.PaintContext
126
127 pos := tg.Geom.Pos.Content
128 sz := tg.Geom.Size.Actual.Content
129
130 effsz := sz
131 effsz.X -= tg.rowMaxSz.X + LabelSpace
132 effsz.Y -= tg.colMaxSz.Y + LabelSpace
133
134 pc.FillBox(pos, sz, tg.Styles.Background)
135
136 tsr := tg.SimMat.Mat
137
138 rows, cols, _, _ := tensor.Projection2DShape(tsr.Shape(), tg.Display.OddRow)
139 rowEx := tg.rowNGps
140 colEx := tg.colNGps
141 frw := float32(rows) + float32(rowEx)*tg.Display.DimExtra // extra spacing
142 fcl := float32(cols) + float32(colEx)*tg.Display.DimExtra // extra spacing
143 tsz := math32.Vec2(fcl, frw)
144 gsz := effsz.Div(tsz)
145
146 // Render Rows
147 epos := pos
148 epos.Y += tg.colMaxSz.Y + LabelSpace
149 nr := len(tg.SimMat.Rows)
150 mx := min(nr, rows)
151 tr := paint.Text{}
152 txsty := tg.Styles.Text
153 txsty.AlignV = styles.Start
154 ygp := 0
155 prvyblk := false
156 fr := tg.Styles.FontRender()
157 for y := 0; y < mx; y++ {
158 lb := tg.SimMat.Rows[y]
159 if len(lb) == 0 {
160 prvyblk = true
161 continue
162 }
163 if prvyblk {
164 ygp++
165 prvyblk = false
166 }
167 yex := float32(ygp) * tg.Display.DimExtra
168 tr.SetString(lb, fr, &tg.Styles.UnitContext, &txsty, true, 0, 0)
169 tr.LayoutStdLR(&txsty, fr, &tg.Styles.UnitContext, tg.rowMaxSz)
170 cr := math32.Vec2(0, float32(y)+yex)
171 pr := epos.Add(cr.Mul(gsz))
172 tr.Render(pc, pr)
173 }
174
175 // Render Cols
176 epos = pos

Callers

nothing calls this directly

Calls 15

SetStringMethod · 0.95
LayoutStdLRMethod · 0.95
RenderMethod · 0.95
SetStringRot90Method · 0.95
Projection2DShapeFunction · 0.92
Vec2Function · 0.92
Projection2DValueFunction · 0.92
UniformFunction · 0.92
EnsureColorMapMethod · 0.80
FillBoxMethod · 0.80
FontRenderMethod · 0.80
ColorMethod · 0.80

Tested by

no test coverage detected