newGraph creates and returns a pointer to a new graph for the specified chart
(chart *Chart, color *math32.Color, data []float32)
| 621 | |
| 622 | // newGraph creates and returns a pointer to a new graph for the specified chart |
| 623 | func 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 |
| 648 | func (lg *Graph) SetColor(color *math32.Color) { |
no test coverage detected