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

Function newChartScaleY

gui/chart.go:536–575  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

534// newChartScaleY creates and returns a pointer to a new chartScaleY for the specified
535// chart, number of lines and color
536func 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
578func (sy *chartScaleY) recalc() {

Callers 1

SetScaleYMethod · 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