MCPcopy
hub / github.com/g3n/engine / newChartScaleX

Function newChartScaleX

gui/chart.go:457–490  ·  view source on GitHub ↗

newChartScaleX creates and returns a pointer to a new chartScaleX for the specified chart, number of lines and color

(chart *Chart, lines int, color *math32.Color)

Source from the content-addressed store, hash-verified

455// newChartScaleX creates and returns a pointer to a new chartScaleX for the specified
456// chart, number of lines and color
457func newChartScaleX(chart *Chart, lines int, color *math32.Color) *chartScaleX {
458
459 sx := new(chartScaleX)
460 sx.chart = chart
461 sx.lines = lines
462 sx.uniBounds.Init("Bounds")
463
464 // Appends bottom horizontal line
465 positions := math32.NewArrayF32(0, 0)
466 positions.Append(0, -1+deltaLine, 0, 1, -1+deltaLine, 0)
467
468 // Appends vertical lines
469 step := 1 / float32(lines)
470 for i := 0; i < lines; i++ {
471 nx := float32(i) * step
472 if i == 0 {
473 nx += deltaLine
474 }
475 positions.Append(nx, 0, 0, nx, -1, 0)
476 }
477
478 // Creates geometry and adds VBO
479 geom := geometry.NewGeometry()
480 geom.AddVBO(gls.NewVBO(positions).AddAttrib(gls.VertexPosition))
481
482 // Initializes the panel graphic
483 gr := graphic.NewGraphic(sx, geom, gls.LINES)
484 sx.mat.Init(color)
485 gr.AddMaterial(sx, &sx.mat, 0, 0)
486 sx.Panel.InitializeGraphic(chart.ContentWidth(), chart.ContentHeight(), gr)
487
488 sx.recalc()
489 return sx
490}
491
492// recalc recalculates the position and size of this scale inside its parent
493func (sx *chartScaleX) recalc() {

Callers 1

SetScaleXMethod · 0.85

Calls 13

AppendMethod · 0.95
AddVBOMethod · 0.95
AddMaterialMethod · 0.95
NewArrayF32Function · 0.92
NewGeometryFunction · 0.92
NewVBOFunction · 0.92
NewGraphicFunction · 0.92
InitializeGraphicMethod · 0.80
ContentWidthMethod · 0.80
ContentHeightMethod · 0.80
InitMethod · 0.45
AddAttribMethod · 0.45

Tested by

no test coverage detected