runes

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 0 Imported by: 1

Documentation

Overview

Package runes contains commonly used runes and functions to obtain runes.

Index

Constants

View Source
const (
	Null = '\u0000'

	LineHorizontal         = '\u2500' // ─
	LineVertical           = '\u2502' // │
	LineDownRight          = '\u250C' // ┌
	LineDownLeft           = '\u2510' // ┐
	LineUpRight            = '\u2514' // └
	LineUpLeft             = '\u2518' // ┘
	LineVerticalRight      = '\u251C' // ├
	LineVerticalLeft       = '\u2524' // ┤
	LineHorizontalUp       = '\u2534' // ┴
	LineHorizontalDown     = '\u252C' // ┬
	LineHorizontalVertical = '\u253C' // ┼
	LineLeft               = '\u2574' // ╴
	LineUp                 = '\u2575' // ╵
	LineRight              = '\u2576' // ╶
	LineDown               = '\u2577' // ╷

	ArcDownRight = '\u256D' // ╭
	ArcDownLeft  = '\u256E' // ╮
	ArcUpLeft    = '\u256F' // ╯
	ArcUpRight   = '\u2570' // ╰

	LowerBlockOne   = '\u2581' // ▁
	LowerBlockTwo   = '\u2582' // ▂
	LowerBlockThree = '\u2583' // ▃
	LowerBlockFour  = '\u2584' // ▄
	LowerBlockFive  = '\u2585' // ▅
	LowerBlockSix   = '\u2586' // ▆
	LowerBlockSeven = '\u2587' // ▇
	FullBlock       = '\u2588' // █
	LeftBlockSeven  = '\u2589' // ▉
	LeftBlockSix    = '\u258A' // ▊
	LeftBlockFive   = '\u258B' // ▋
	LeftBlockFour   = '\u258C' // ▌
	LeftBlockThree  = '\u258D' // ▍
	LeftBlockTwo    = '\u258E' // ▎
	LeftBlockOne    = '\u258F' // ▏
)
View Source
const BrailleBlockOffset = 0x2800 // beginning of Unicode Braille Patterns (empty Braille Pattern)

Variables

This section is empty.

Functions

func ArcLineFromLineSegments

func ArcLineFromLineSegments(l LineSegments) rune

ArcLineFromLineSegments returns either an empty rune or a line rune using given LineSegments. LineSegments contain whether or not the returned rune should display arc lines going up, down, left or right.

func BraillePatternFromPatternDots

func BraillePatternFromPatternDots(p PatternDots) (r rune)

BraillePatternFromPatternDots returns a Braille Pattern rune using given PatternDots. Each index in PatternDots corresponds to Braille dot number and whether the dot should be displayed.

func CombineBraillePatterns

func CombineBraillePatterns(r1 rune, r2 rune) rune

CombineBraillePatterns returns a rune that is a combination of two braille pattern runes. Any invalid braille pattern rune combinations will return r2.

func CombineLines

func CombineLines(r1 rune, r2 rune, ls LineStyle) (r rune)

CombineLines returns a rune that is a combination of two line runes. Any invalid line rune combinations or invalid LineStyle will return r2. The Linestyle determines the output line rune, even if the two input line runes are not of that style.

func IsBraillePattern

func IsBraillePattern(r rune) bool

IsBraillePattern returns whether a given rune is considered a Braile Pattern rune.

func IsLeftBlockElement

func IsLeftBlockElement(r rune) bool

IsLeftBlockElement returns whether a given rune is considered a left block or full block element.

func IsLine

func IsLine(r rune) bool

IsLine returns whether a given rune is considered a line rune.

func IsLowerBlockElement

func IsLowerBlockElement(r rune) bool

IsLowerBlockElement returns whether a given rune is considered a lower block or full block element.

func LeftBlockElementFromFloat64

func LeftBlockElementFromFloat64(f float64) rune

LeftBlockElementFromFloat64 returns either an empty rune or a left Block Element rune using given float64. A float64 < 1.0 will return the nearest one eights left block element corresponding to the float value. An empty rune will be returned if float64 does not round to lowest 1/8 left block.

func LowerBlockElementFromFloat64

func LowerBlockElementFromFloat64(f float64) rune

LowerBlockElementFromFloat64 returns either an empty rune or a lower Block Element rune using given float64. A float64 < 1.0 will return the nearest one eights lower block element corresponding to the float value. An empty rune will be returned if float64 does not round to lowest 1/8 lower block.

func SetLineSegments

func SetLineSegments(r rune, l *LineSegments)

SetLineSegments sets given LineSegments directions based on given rune.

func SetPatternDots

func SetPatternDots(r rune, p *PatternDots)

SetPatternDots sets given PatternDots dots based on given rune.

func ThinLineFromLineSegments

func ThinLineFromLineSegments(l LineSegments) rune

ThinLineFromLineSegments returns either an empty rune or a line rune using given LineSegments. LineSegments contain whether or not the returned rune should display thin lines going up, down, left or right.

Types

type LineSegments

type LineSegments struct {
	Up    bool
	Down  bool
	Left  bool
	Right bool
}

LineSegments indicates whether a line segment going up, down, left, or right is displayed.

type LineStyle

type LineStyle int

LineStyle enumerates the different style of line runes to display.

const (
	ThinLineStyle LineStyle = iota
	ArcLineStyle
)

type PatternDots

type PatternDots [8]bool

PatternDots indicates whether a dot in a Braille Pattern is displayed.

type PatternDotsGrid

type PatternDotsGrid struct {
	// contains filtered or unexported fields
}

PatternDotsGrid is a 2D array where each row and column indicates whether a dot in a sequence of Braille Patterns runes should be displayed. Example:

 width = 4, height = 4 will give 2 Braille Pattern runes
 [0][3][0][3]
 [1][4][1][4]
 [2][5][2][5]
 [6][7][6][7]

setting (0,0) will set Dot 0 of first braille rune
setting (0,3) will set Dot 6 of first braille rune
setting (3,0) will set Dot 3 of second braille rune
setting (3,3) will set Dot 7 of second braille rune

func NewPatternDotsGrid

func NewPatternDotsGrid(w, h int) *PatternDotsGrid

NewPatternDotsGrid returns new initialized *PatternDotsGrid

func (*PatternDotsGrid) BraillePatterns

func (g *PatternDotsGrid) BraillePatterns() (p [][]rune)

BraillePatterns returns a [][]rune containing Braille Pattern runes based on internal grid values.

func (*PatternDotsGrid) Reset

func (g *PatternDotsGrid) Reset()

Reset will reset the internal grid

func (*PatternDotsGrid) Set

func (g *PatternDotsGrid) Set(x int, y int)

Set will set value in grid at given column and row

func (*PatternDotsGrid) Unset

func (g *PatternDotsGrid) Unset(x int, y int)

Unset will unset value in grid at given column and row

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL