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

Function newGraph

gui/chart.go:623–645  ·  view source on GitHub ↗

newGraph creates and returns a pointer to a new graph for the specified chart

(chart *Chart, color *math32.Color, data []float32)

Source from the content-addressed store, hash-verified

621
622// newGraph creates and returns a pointer to a new graph for the specified chart
623func newGraph(chart *Chart, color *math32.Color, data []float32) *Graph {
624
625 lg := new(Graph)
626 lg.uniBounds.Init("Bounds")
627 lg.chart = chart
628 lg.color = *color
629 lg.data = data
630
631 // Creates geometry and adds VBO with positions
632 geom := geometry.NewGeometry()
633 lg.positions = math32.NewArrayF32(0, 0)
634 lg.vbo = gls.NewVBO(lg.positions).AddAttrib(gls.VertexPosition)
635 geom.AddVBO(lg.vbo)
636
637 // Initializes the panel with this graphic
638 gr := graphic.NewGraphic(lg, geom, gls.LINE_STRIP)
639 lg.mat.Init(&lg.color)
640 gr.AddMaterial(lg, &lg.mat, 0, 0)
641 lg.Panel.InitializeGraphic(lg.chart.ContentWidth(), lg.chart.ContentHeight(), gr)
642
643 lg.SetData(data)
644 return lg
645}
646
647// SetColor sets the color of the graph
648func (lg *Graph) SetColor(color *math32.Color) {

Callers 1

AddLineGraphMethod · 0.85

Calls 12

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

Tested by

no test coverage detected