newChartScaleY creates and returns a pointer to a new chartScaleY for the specified chart, number of lines and color
(chart *Chart, lines int, color *math32.Color)
| 534 | // newChartScaleY creates and returns a pointer to a new chartScaleY for the specified |
| 535 | // chart, number of lines and color |
| 536 | func newChartScaleY(chart *Chart, lines int, color *math32.Color) *chartScaleY { |
| 537 | |
| 538 | if lines < 2 { |
| 539 | lines = 2 |
| 540 | } |
| 541 | sy := new(chartScaleY) |
| 542 | sy.chart = chart |
| 543 | sy.lines = lines |
| 544 | sy.uniBounds.Init("Bounds") |
| 545 | |
| 546 | // Appends left vertical line |
| 547 | positions := math32.NewArrayF32(0, 0) |
| 548 | positions.Append(0+deltaLine, 0, 0, 0+deltaLine, -1, 0) |
| 549 | |
| 550 | // Appends horizontal lines |
| 551 | step := 1 / float32(lines-1) |
| 552 | for i := 0; i < lines; i++ { |
| 553 | ny := -1 + float32(i)*step |
| 554 | if i == 0 { |
| 555 | ny += deltaLine |
| 556 | } |
| 557 | if i == lines-1 { |
| 558 | ny -= deltaLine |
| 559 | } |
| 560 | positions.Append(0, ny, 0, 1, ny, 0) |
| 561 | } |
| 562 | |
| 563 | // Creates geometry and adds VBO |
| 564 | geom := geometry.NewGeometry() |
| 565 | geom.AddVBO(gls.NewVBO(positions).AddAttrib(gls.VertexPosition)) |
| 566 | |
| 567 | // Initializes the panel with this graphic |
| 568 | gr := graphic.NewGraphic(sy, geom, gls.LINES) |
| 569 | sy.mat.Init(color) |
| 570 | gr.AddMaterial(sy, &sy.mat, 0, 0) |
| 571 | sy.Panel.InitializeGraphic(chart.ContentWidth(), chart.ContentHeight(), gr) |
| 572 | |
| 573 | sy.recalc() |
| 574 | return sy |
| 575 | } |
| 576 | |
| 577 | // recalc recalculates the position and size of this scale inside its parent |
| 578 | func (sy *chartScaleY) recalc() { |
no test coverage detected