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

Method MinSize

tensor/tensorcore/tensorgrid.go:247–263  ·  view source on GitHub ↗

MinSize returns minimum size based on tensor and display settings

()

Source from the content-addressed store, hash-verified

245
246// MinSize returns minimum size based on tensor and display settings
247func (tg *TensorGrid) MinSize() math32.Vector2 {
248 if tg.Tensor == nil || tg.Tensor.Len() == 0 {
249 return math32.Vector2{}
250 }
251 if tg.Display.Image {
252 return math32.Vec2(float32(tg.Tensor.DimSize(1)), float32(tg.Tensor.DimSize(0)))
253 }
254 rows, cols, rowEx, colEx := tensor.Projection2DShape(tg.Tensor.Shape(), tg.Display.OddRow)
255 frw := float32(rows) + float32(rowEx)*tg.Display.DimExtra // extra spacing
256 fcl := float32(cols) + float32(colEx)*tg.Display.DimExtra // extra spacing
257 mx := float32(max(frw, fcl))
258 gsz := tg.Display.TotPrefSize / mx
259 gsz = max(gsz, tg.Display.GridMinSize)
260 gsz = min(gsz, tg.Display.GridMaxSize)
261 gsz = max(gsz, 2)
262 return math32.Vec2(gsz*float32(fcl), gsz*float32(frw))
263}
264
265// EnsureColorMap makes sure there is a valid color map that matches specified name
266func (tg *TensorGrid) EnsureColorMap() {

Callers 1

InitMethod · 0.95

Calls 5

Vec2Function · 0.92
Projection2DShapeFunction · 0.92
LenMethod · 0.65
DimSizeMethod · 0.65
ShapeMethod · 0.65

Tested by

no test coverage detected