Documentation ¶
Overview ¶
Package graph contains data structures and functions to help draw runes on to a canvas.
Index ¶
- func DrawBraillePatterns(m *canvas.Model, p canvas.Point, b [][]rune, s lipgloss.Style)
- func DrawBrailleRune(m *canvas.Model, p canvas.Point, r rune, s lipgloss.Style)
- func DrawCandlestickBottomToTop(m *canvas.Model, p canvas.Point, l, bl, bh, h float64, s lipgloss.Style)
- func DrawCandlestickRune(m *canvas.Model, p canvas.Point, r rune, s lipgloss.Style)
- func DrawColumnBottomToTop(m *canvas.Model, p canvas.Point, v float64, s lipgloss.Style)
- func DrawColumnRune(m *canvas.Model, p canvas.Point, r rune, s lipgloss.Style)
- func DrawColumns(m *canvas.Model, p canvas.Point, seqLen []float64, s lipgloss.Style)
- func DrawHorizonalLineLeft(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawHorizonalLineRight(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawLinePoints(m *canvas.Model, points []canvas.Point, ls runes.LineStyle, s lipgloss.Style)
- func DrawLineRune(m *canvas.Model, p canvas.Point, r rune, ls runes.LineStyle, s lipgloss.Style)
- func DrawLineSequence(m *canvas.Model, startYAxis bool, startX int, seqY []int, ls runes.LineStyle, ...)
- func DrawLineSequenceLeftToRight(m *canvas.Model, a canvas.Point, b canvas.Point, ls runes.LineStyle, ...)
- func DrawRowLeftToRight(m *canvas.Model, p canvas.Point, v float64, s lipgloss.Style)
- func DrawRowRune(m *canvas.Model, p canvas.Point, r rune, s lipgloss.Style)
- func DrawRows(m *canvas.Model, p canvas.Point, seqLen []float64, s lipgloss.Style)
- func DrawVerticalLineDown(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawVerticalLineUp(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawXYAxis(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawXYAxisAll(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawXYAxisDown(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func DrawXYAxisLeft(m *canvas.Model, p canvas.Point, s lipgloss.Style)
- func GetCirclePoints(c canvas.Point, r int) (p []canvas.Point)
- func GetFullCirclePoints(c canvas.Point, r int) (p []canvas.Point)
- func GetLinePoints(p1 canvas.Point, p2 canvas.Point) []canvas.Point
- type BrailleGrid
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawBraillePatterns ¶
DrawBraillePatterns draws braille runes from a [][]rune representing a 2D grid of Braille Pattern runes. The runes will be drawn onto the canvas from starting from top left of the grid to the bottom right of the grid starting at the given canvas Point. Given style will be applied to all runes drawn. This function can be used with the output [][]rune from PatternDotsGrid.BraillePatterns().
func DrawBrailleRune ¶
DrawBrailleRune draws a braille rune on to the canvas at given (X,Y) coordinates with given style. The function checks for existing braille runes already on the canvas and will draw a new braille pattern with the dot patterns of both the existing and given runes. Does nothing if given rune is Null or is not a braille rune.
func DrawCandlestickBottomToTop ¶ added in v0.2.0
func DrawCandlestickBottomToTop(m *canvas.Model, p canvas.Point, l, bl, bh, h float64, s lipgloss.Style)
DrawCandlestickBottomToTop draws candlestick line runes going up from given point. `h` and `l` are the candlestick high and low values. `bh` and `bl` are the candlestick body high and low values. These values represent the height of the runes drawn going up. Fractional values are used since there are 1/2th candlestick line segment runes and top and bottom fractional values will map to the nearest 1/2th candlestick line segment runes. Assumes all high values >= all low values, `h` >= `bh`, and `l` <= `bl`. Applies style to all block runes. Coordinates (0,0) is top left of canvas.
func DrawCandlestickRune ¶ added in v0.2.0
DrawCandlestickRune draws a canndlestick rune on to the canvas at given (X,Y) coordinates with given style. The function checks for existing candlestick runes already on the canvas and attempts to draws runes such that the candlestick lines appears combined. If the runes cannot be combined, then it will the existing rune will be replaced. Does nothing if given rune is Null or is not a candlestick rune.
func DrawColumnBottomToTop ¶
DrawColumnBottomToTop draws block element runes going up from given point. The value of float64 is the number of characters to draw going up. A fractional value is used since there are 1/8th lower block elements and fractional values will map to the nearest 1/8th block for the last rune drawn. Handles overlapping columns of diferent rune heights. If there exists an existing column at given Point with same height as new column, then the existing column will be replaced. Applies style to all block runes. Coordinates (0,0) is top left of canvas.
func DrawColumnRune ¶
DrawColumnRune draws a column rune on to the canvas at given (X,Y) coordinates with given style. The function checks for existing column runes already on the canvas and attempts to draws runes such that the runes appear overlapping. Overlapping runes can only occur if either one of the runes is a full block element rune, and the other rune is not a full block element rune. If the runes cannot overlap, then it will the existing rune will be replaced. Does nothing if given rune is Null or is not a column rune.
func DrawColumns ¶
DrawColumns draws columns going upwards on to canvas starting from a given (X,Y) coordinate and a sequence of column lengths. Columns will be drawn from left to right and sequential column lengths will increment X coordinates for drawing. Handles overlapping columns of diferent rune heights. If there exists an existing column at given Point with same height as new column, then the existing column will be replaced. Applies style to all block runes. Coordinates (0,0) is top left of canvas.
func DrawHorizonalLineLeft ¶
DrawHorizonalLineLeft draws a horizontal line going to the left starting from (X,Y) coordinates. Applies given style to all runes. Coordinates (0,0) is top left of canvas.
func DrawHorizonalLineRight ¶
DrawHorizonalLineRight draws a horizontal line going to the right starting from (X,Y) coordinates. Applies given style to all runes. Coordinates (0,0) is top left of canvas.
func DrawLinePoints ¶
DrawLinePoints draws line runes on to the canvas from a []canvas.Point. Each canvas Point is expected to be either adjacent or diagonal from each other. At least two Points are required to draw any runes on to the canvas. This function can be used with the []canvas.Point output from GetLinePoints().
func DrawLineRune ¶
DrawLineRune draws a line rune on to the canvas at given (X,Y) coordinates with given style. The given rune is used to check line directions, and the final output line rune depends on the given runes.LineStyle. The function checks for existing X,Y axis or line runes already on the canvas and draws runes such that the lines appear overlapping. Does nothing if given rune is empty or is not a line rune.
func DrawLineSequence ¶
func DrawLineSequence(m *canvas.Model, startYAxis bool, startX int, seqY []int, ls runes.LineStyle, s lipgloss.Style)
DrawLineSequence draws line runes on to the canvas starting from a given X coordinate and a sequence of Y coordinates. `startYAxis` should be true if `startX` is the Y axis. Sequential Y coordinates will increment X coordinates. Applies style to all line runes. Handles overlapping lines. Handles X and Y axes drawn using DrawXYAxis functions. Coordinates (0,0) is top left of canvas.
func DrawLineSequenceLeftToRight ¶
func DrawLineSequenceLeftToRight(m *canvas.Model, a canvas.Point, b canvas.Point, ls runes.LineStyle, s lipgloss.Style)
DrawLineSequenceLeftToRight draws line runes from point A to point B where B.X = A.X+1. Assumes point A has already been drawn and does not draw point A. Applies style to all line runes. Handles overlapping lines. Handles X and Y axes drawn using DrawXYAxis functions. Coordinates (0,0) is top left of canvas.
func DrawRowLeftToRight ¶
DrawRowLeftToRight draws block element runes going right from given point. The value of float64 is the number of characters to draw going right. A fractional value is used since there are 1/8th left block elements and fractional values will map to the nearest 1/8th block for the last rune drawn. Handles overlapping rows of diferent rune widths. If there exists an existing row at given Point with same width as new row, then the existing row will be replaced. Applies style to all block runes. Coordinates (0,0) is top left of canvas.
func DrawRowRune ¶
DrawRowRune draws a row rune on to the canvas at given (X,Y) coordinates with given style. The function checks for existing row runes already on the canvas and attempts to draws runes such that the runes appear overlapping. Overlapping runes can only occur if either one of the runes is a full block element rune, and the other rune is not a full block element rune. If the runes cannot overlap, then it will the existing rune will be replaced. Does nothing if given rune is Null or is not a row rune.
func DrawRows ¶
DrawRows draws rows going right on to canvas starting from a given (X,Y) coordinate and a sequence of row widths. Rows will be drawn from top to bottom and sequential row widths will increment Y coordinates for drawing. Handles overlapping rows of diferent rune widths. If there exists an existing row at given Point with same width as new row, then the existing row will be replaced. Applies style to all block runes. Coordinates (0,0) is top left of canvas.
func DrawVerticalLineDown ¶
DrawVerticalLineDown draws a vertical line going down starting from (X,Y) coordinates. Applies given style to all runes. Coordinates (0,0) is top left of canvas.
func DrawVerticalLineUp ¶
DrawVerticalLineUp draws a vertical line going up starting from (X,Y) coordinates. Applies given style to all runes. Coordinates (0,0) is top left of canvas.
func DrawXYAxis ¶
DrawXYAxis draws X and Y axes with origin at (X,Y cordinates) with given style. Y axis extends up, and X axis extends right. Coordinates (0,0) is top left of canvas.
func DrawXYAxisAll ¶
DrawXYAxisAll draws X and Y axes with origin at (X,Y cordinates) with given style. Y axis extends up and down, and X axis extends left and right. Coordinates (0,0) is top left of canvas.
func DrawXYAxisDown ¶
DrawXYAxisDown draws X and Y axes with origin at (X,Y cordinates) with given style. Y axis extends up and down, and X axis extends right. Coordinates (0,0) is top left of canvas.
func DrawXYAxisLeft ¶
DrawXYAxisLeft draws X and Y axes with origin at (X,Y cordinates) with given style. Y axis extends up, and X axis extends left and right. Coordinates (0,0) is top left of canvas.
func GetCirclePoints ¶
GetCirclePoints returns a []canvas.Point containing points that approximates a circle of radius r for center Point c.
func GetFullCirclePoints ¶
GetFullCirclePoints returns a []canvas.Point containing points that approximates a filled circle of radius r for center Point c.
Types ¶
type BrailleGrid ¶
type BrailleGrid struct {
// contains filtered or unexported fields
}
BrailleGrid wraps a runes.PatternDotsGrid to implements a 2D grid with (X, Y) floating point coordinates used to display Braille Pattern runes. Since Braille Pattern runes are 4 high and 2 wide, the BrailleGrid will internally scale the width and height sizes to match those patterns. BrailleGrid uses canvas coordinates system with (0,0) being top left.
func NewBrailleGrid ¶
func NewBrailleGrid(w, h int, minX, maxX, minY, maxY float64) *BrailleGrid
NewBrailleGrid returns new initialized *BrailleGrid with given canvas width, canvas height and minimums and maximums X and Y values of the data points.
func (*BrailleGrid) BraillePatterns ¶
func (g *BrailleGrid) BraillePatterns() [][]rune
BraillePatterns returns [][]rune containing braille pattern runes to draw on to the canvas.
func (*BrailleGrid) GridPoint ¶
func (g *BrailleGrid) GridPoint(f canvas.Float64Point) canvas.Point
GridPoint returns a canvas Point representing a point in the braille grid in the canvas coordinates system from a Float64Point data point in the Cartesian coordinates system.
func (*BrailleGrid) Set ¶
func (g *BrailleGrid) Set(p canvas.Point)
Set will set point on grid from given canvas Point.