Documentation
¶
Overview ¶
Package providing clipping on line
This is more "modern" font solution supporting embed directive (avail since go 1.16)
Fonts are generated beforehand and loaded with embed directive.
Font data is like this - font width uint16 - font height uint16
Then repeating part - flags, now 0, 1=RLE encoded - first 8bit char code - number of chars first,first+1,first+2 - byte w*h*n bits of data. Alligned to byte on each char
Rendering supports rotation ¶
Run length coding on large fonts Option to scale down font when rendering (embed largest font, scale down for smaller fonts)
Some fonts for gomonochromebitmap ¶
Package provides functions for operating monochrome images
Index ¶
- Constants
- func ClipLine(a, b image.Point, area image.Rectangle) (*image.Point, *image.Point)
- func CreatePlanarColorImage(planes []MonoBitmap, palette []color.Color) (*image.RGBA, error)
- type AnsiColorString
- type BlockGraphics
- type Font
- type FontFileBlockHeader
- type FontFileHeader
- type MonoBitmap
- func (p *MonoBitmap) Bounds() image.Rectangle
- func (p *MonoBitmap) Circle(p0 image.Point, r int, value bool)
- func (p *MonoBitmap) CircleFill(p0 image.Point, r int, value bool)
- func (p *MonoBitmap) DrawBitmap(source MonoBitmap, sourceArea image.Rectangle, targetCorner image.Point, ...)
- func (p *MonoBitmap) Fill(area image.Rectangle, fillValue bool)
- func (p *MonoBitmap) FlipH()
- func (p *MonoBitmap) FlipV()
- func (p *MonoBitmap) GetDisplayImage(trueColorUpper color.Color, trueColorDowner color.Color, upperRows int, ...) *image.RGBA
- func (p *MonoBitmap) GetFgBgImage(fgPic image.Image, bgPic image.Image) (image.Image, error)
- func (p *MonoBitmap) GetImage(trueColor color.Color, falseColor color.Color) *image.RGBA
- func (p *MonoBitmap) GetPix(x int, y int) bool
- func (p *MonoBitmap) GetPixNoCheck(x int, y int) bool
- func (p *MonoBitmap) GetView(w int, h int, p0 image.Point, pxStep int, edges bool) MonoBitmap
- func (p *MonoBitmap) Hline(x0 int, x1 int, y int, value bool)
- func (p *MonoBitmap) Hline_(x0 int, x1 int, y int, value bool)
- func (p *MonoBitmap) Invert(area image.Rectangle)
- func (p *MonoBitmap) Line(p0In image.Point, p1In image.Point, value bool)
- func (p *MonoBitmap) Print(text string, font MonoFont, lineSpacing int, gap int, area image.Rectangle, ...) image.Rectangle
- func (p *MonoBitmap) RLEdecode(activeFirst bool, data []byte) error
- func (p *MonoBitmap) RLEencode(activeFirst bool) []byte
- func (p *MonoBitmap) Rectangle(area image.Rectangle)
- func (p *MonoBitmap) Rotate90(turn90 int)
- func (p *MonoBitmap) SetPix(x int, y int, value bool)
- func (p *MonoBitmap) SetPixNoCheck(x int, y int, value bool)
- func (p *MonoBitmap) Vline(x int, y0 int, y1 int, value bool)
- type MonoFont
- type Typesetter
Constants ¶
const ( ANSI_NO = "" ANSI_RESET = "\033[0m" )
const ( FGANSI_BLACK = "\033[30m" FGANSI_RED = "\033[31m" FGANSI_GREEN = "\033[32m" FGANSI_YELLOW = "\033[33m" FGANSI_BLUE = "\033[34m" FGANSI_PURPLE = "\033[35m" FGANSI_CYAN = "\033[36m" FGANSI_WHITE = "\033[37m" FGANSI_BRIGHT_BLACK = "\033[30;1m" FGANSI_BRIGHT_RED = "\033[31;1m" FGANSI_BRIGHT_GREEN = "\033[32;1m" FGANSI_BRIGHT_YELLOW = "\033[33;1m" FGANSI_BRIGHT_BLUE = "\033[34;1m" FGANSI_BRIGHT_PURPLE = "\033[35;1m" FGANSI_BRIGHT_CYAN = "\033[36;1m" FGANSI_BRIGHT_WHITE = "\033[37;1m" )
const ( BGANSI_BLACK = "\033[40m" BGANSI_RED = "\033[41m" BGANSI_GREEN = "\033[42m" BGANSI_YELLOW = "\033[43m" BGANSI_BLUE = "\033[44m" BGANSI_PURPLE = "\033[45m" BGANSI_CYAN = "\033[46m" BGANSI_WHITE = "\033[47m" BGANSI_BRIGHT_BLACK = "\033[40;1m" BGANSI_BRIGHT_RED = "\033[41;1m" BGANSI_BRIGHT_GREEN = "\033[42;1m" BGANSI_BRIGHT_YELLOW = "\033[43;1m" BGANSI_BRIGHT_BLUE = "\033[44;1m" BGANSI_BRIGHT_PURPLE = "\033[45;1m" BGANSI_BRIGHT_CYAN = "\033[46;1m" BGANSI_BRIGHT_WHITE = "\033[47;1m" )
const ( INSIDE = 0 // 0000 LEFT = 1 // 0001 RIGHT = 2 // 0010 BOTTOM = 4 // 0100 TOP = 8 // 1000 )
Define region codes for Cohen-Sutherland algorithm
const (
CLEARDISPLAY = "\033c"
)
Variables ¶
This section is empty.
Functions ¶
func CreatePlanarColorImage ¶
Use each monochrome bitmap as bit in color palette index. https://en.wikipedia.org/wiki/Planar_(computer_graphics)
Types ¶
type AnsiColorString ¶
type AnsiColorString string
type BlockGraphics ¶
type BlockGraphics struct { Clear bool HaveBorder bool BorderColor AnsiColorString TextColor AnsiColorString }
func (*BlockGraphics) ToFullBlockChars ¶
func (p *BlockGraphics) ToFullBlockChars(bitmap *MonoBitmap) string
ToFullBlockChars creates console printable version of image ' ','█'
func (*BlockGraphics) ToHalfBlockChars ¶
func (p *BlockGraphics) ToHalfBlockChars(bitmap *MonoBitmap) string
ToHalfBlockChars ' ', '▀', '▄', '█'
func (*BlockGraphics) ToQuadBlockChars ¶
func (p *BlockGraphics) ToQuadBlockChars(bitmap *MonoBitmap) string
ToQuadBlockChars ' ', '▘', '▝', '▀','▖', '▌', '▞', '▛','▗', '▚', '▐', '▜','▄', '▙', '▟', '█'
type Font ¶
type Font []byte
Must be just []byte in type definition so this works
func (*Font) GetHeader ¶
func (p *Font) GetHeader() (FontFileHeader, error)
type FontFileBlockHeader ¶
type FontFileHeader ¶
type MonoBitmap ¶
type MonoBitmap struct { Pix []uint32 //using byte vs uint16 vs uint32 vs uint64... 32bit shoud suit well for raspi1/2 W int H int }
func NewMonoBitmap ¶
func NewMonoBitmap(w int, h int, fill bool) MonoBitmap
NewMonoBitmap initializes empty bitmap fill is default value
func NewMonoBitmapFromImage ¶
func NewMonoBitmapFromImage(img image.Image, area image.Rectangle, threshold byte, invert bool) MonoBitmap
NewMonoBitmapFromImage initializes bitmap from image. Color conversion: if any Red,Green or Blue value is over threshold then pixel is true
func (*MonoBitmap) Bounds ¶
func (p *MonoBitmap) Bounds() image.Rectangle
Bounds returns W,H in Rect struct
func (*MonoBitmap) Circle ¶
func (p *MonoBitmap) Circle(p0 image.Point, r int, value bool)
Modified from C++ source https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
func (*MonoBitmap) CircleFill ¶
func (p *MonoBitmap) CircleFill(p0 image.Point, r int, value bool)
Modified from C++ source https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
func (*MonoBitmap) DrawBitmap ¶
func (p *MonoBitmap) DrawBitmap(source MonoBitmap, sourceArea image.Rectangle, targetCorner image.Point, drawTrue bool, drawFalse bool, invert bool)
Draws source bitmap on bitmap drawTrue, draw when point value is true drawFalse, draw when point value is true
func (*MonoBitmap) Fill ¶
func (p *MonoBitmap) Fill(area image.Rectangle, fillValue bool)
Fills rectangle area from map. Used for clearing image
func (*MonoBitmap) FlipH ¶
func (p *MonoBitmap) FlipH()
func (*MonoBitmap) GetDisplayImage ¶
func (p *MonoBitmap) GetDisplayImage(trueColorUpper color.Color, trueColorDowner color.Color, upperRows int, falseColor color.Color, pixelW int, pixelH int, gapW int, gapH int) *image.RGBA
Generates image that is rendered like it was LCD. Space in between segments is transparent upper vs lower color allows to render two color LCD's (like cyan and yellow strip)
func (*MonoBitmap) GetFgBgImage ¶
func (*MonoBitmap) GetImage ¶
BenchmarkGetBlankImage-16 750 1588057 ns/op 1925196 B/op 4 allocs/op GetImage Creates RGBA image from bitmap
func (*MonoBitmap) GetPix ¶
func (p *MonoBitmap) GetPix(x int, y int) bool
Gets pixel. Returns false if out of range
func (*MonoBitmap) GetPixNoCheck ¶
func (p *MonoBitmap) GetPixNoCheck(x int, y int) bool
func (*MonoBitmap) GetView ¶
func (p *MonoBitmap) GetView(w int, h int, p0 image.Point, pxStep int, edges bool) MonoBitmap
Get view (size w,h) for display. Starting from corner p0. Result is centered. If p0 goes outside, function clamps view This is meant only for producing scrollable output picture for display. Better scaling functions elsewhere pxStep=0, autoscale, so bitmap will fit pxStep=1 is 1:1 pxStep=2 is 2:1 (50% scale) pxStep=3 is 3:1 (25% scale) pxStep is limited to point where whole bitmap is visible Returns: image, actual cornerpoint and zoom used. Useful if UI includes
func (*MonoBitmap) Line ¶
Bresenham's line, copied from http://41j.com/blog/2012/09/bresenhams-line-drawing-algorithm-implemetations-in-go-and-c/
func (*MonoBitmap) Print ¶
func (p *MonoBitmap) Print(text string, font MonoFont, lineSpacing int, gap int, area image.Rectangle, drawTrue bool, drawFalse bool, invert bool, wrap bool) image.Rectangle
Prints message on screen.Creates new lines on \n Returns rectangle where text was printed
func (*MonoBitmap) RLEdecode ¶
func (p *MonoBitmap) RLEdecode(activeFirst bool, data []byte) error
RLEdecode decodes run length compressed bitmap data
func (*MonoBitmap) RLEencode ¶
func (p *MonoBitmap) RLEencode(activeFirst bool) []byte
RLEencodes bitmap in runlength compressed format
func (*MonoBitmap) Rectangle ¶
func (p *MonoBitmap) Rectangle(area image.Rectangle)
func (*MonoBitmap) Rotate90 ¶
func (p *MonoBitmap) Rotate90(turn90 int)
Rotates in 90 decree steps +1=90 clockwise -1=90 anticlockwise +2=180 clockwise etc...
func (*MonoBitmap) SetPix ¶
func (p *MonoBitmap) SetPix(x int, y int, value bool)
TODO BUG: does not work if not div by 8
func (*MonoBitmap) SetPixNoCheck ¶
func (p *MonoBitmap) SetPixNoCheck(x int, y int, value bool)
type MonoFont ¶
type MonoFont map[rune]MonoBitmap //All bitmaps have same size
func GetFont_11x16 ¶
func GetFont_11x16() MonoFont
func GetFont_3x6 ¶
func GetFont_3x6() MonoFont
func GetFont_4x5 ¶
func GetFont_4x5() MonoFont
func GetFont_5x7 ¶
func GetFont_5x7() MonoFont
func GetFont_6x10 ¶
func GetFont_6x10() MonoFont
func GetFont_8x12 ¶
func GetFont_8x12() MonoFont
func GetFont_8x8 ¶
func GetFont_8x8() MonoFont
func (*MonoFont) AreaEstimated ¶
Directories
¶
Path | Synopsis |
---|---|
This sub library is for simulating gadgets on desktop Supports keys and monochrome display.
|
This sub library is for simulating gadgets on desktop Supports keys and monochrome display. |