MinSize returns minimum size based on tensor and display settings
()
| 245 | |
| 246 | // MinSize returns minimum size based on tensor and display settings |
| 247 | func (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 |
| 266 | func (tg *TensorGrid) EnsureColorMap() { |