dots

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 4 Imported by: 0

README

Dots

Simple library for drawing in terminal using braille patterns.

Examples

The examples repository contains a few examples demonstrating Dots' functionality.

Documentation

Index

Constants

View Source
const (
	DefaultThreshold = 128
)

Variables

View Source
var Atkinson = DiffusionKernel{
	Base: 8,
	Rows: [][]int32{
		{1, 1},
		{1, 1, 1},
		{1},
	},
}
View Source
var Burkes = DiffusionKernel{
	Base: 32,
	Rows: [][]int32{
		{8, 4},
		{2, 4, 8, 4, 2},
	},
}
View Source
var ColorModel = color.ModelFunc(colorModel)
View Source
var FloydSteinberg = DiffusionKernel{
	Base: 16,
	Rows: [][]int32{
		{7},
		{3, 5, 1},
	},
}
View Source
var JarvisJudiceNinke = DiffusionKernel{
	Base: 48,
	Rows: [][]int32{
		{7, 5},
		{3, 5, 7, 5, 3},
		{1, 3, 5, 3, 1},
	},
}
View Source
var Sierra = DiffusionKernel{
	Base: 32,
	Rows: [][]int32{
		{5, 3},
		{2, 4, 5, 4, 2},
		{2, 3, 2},
	},
}
View Source
var SierraLite = DiffusionKernel{
	Base: 4,
	Rows: [][]int32{
		{2},
		{1, 1},
	},
}

Functions

func CpToRune added in v0.2.0

func CpToRune(cp CodePoint) rune

func ErrorDiffusionDithering added in v0.3.0

func ErrorDiffusionDithering(src image.Image, dst *Image, k DiffusionKernel)

func OrderedDithering added in v0.2.0

func OrderedDithering(src image.Image, dst *Image, thMap ThresholdMap)

func PixRectToCpRect added in v0.3.0

func PixRectToCpRect(r image.Rectangle) image.Rectangle

func Thresholding

func Thresholding(src image.Image, dst *Image, threshold8 uint8)

Types

type CodePoint

type CodePoint uint8

func CpFlipH added in v0.2.0

func CpFlipH(cp CodePoint) CodePoint

func CpFlipV added in v0.2.0

func CpFlipV(cp CodePoint) CodePoint

func RuneToCp added in v0.2.0

func RuneToCp(r rune) CodePoint

UB on random rune

type Color added in v0.3.0

type Color struct {
	White bool
}

func (Color) RGBA added in v0.3.0

func (c Color) RGBA() (r, g, b, a uint32)

type DiffusionKernel

type DiffusionKernel struct {
	Base int32
	Rows [][]int32
}

type Ditherer

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

func (*Ditherer) ErrorDiffusion added in v0.3.0

func (d *Ditherer) ErrorDiffusion(src image.Image, dst *Image, k DiffusionKernel)

type Image added in v0.3.0

type Image struct {
	CpRect image.Rectangle
	Stride int
	Cps    []CodePoint
}

func NewImage

func NewImage(r image.Rectangle) *Image

NewImage creates empty image with given size in CodePoints.

func NewImagePix added in v0.3.0

func NewImagePix(r image.Rectangle) *Image

NewImagePix creates empty image with given size in pixels.

func (*Image) At added in v0.3.0

func (p *Image) At(px, py int) color.Color

func (*Image) Bounds added in v0.3.0

func (p *Image) Bounds() image.Rectangle

Bounds returns image size in pixels.

func (*Image) ByteLen added in v0.3.0

func (p *Image) ByteLen() int

ByteLen returns number of bytes required to render image.

func (*Image) Clear added in v0.3.0

func (p *Image) Clear() *Image

func (*Image) ColorModel added in v0.3.0

func (p *Image) ColorModel() color.Model

func (*Image) CpAt added in v0.3.0

func (p *Image) CpAt(x, y int) CodePoint

func (*Image) CpOffset added in v0.3.0

func (p *Image) CpOffset(x, y int) int

func (*Image) DotAt added in v0.3.0

func (p *Image) DotAt(px, py int) Color

func (*Image) Fill added in v0.3.0

func (p *Image) Fill(cp CodePoint) *Image

func (*Image) FlipBits added in v0.3.0

func (p *Image) FlipBits() *Image

func (*Image) FlipH added in v0.3.0

func (p *Image) FlipH() *Image

func (*Image) FlipV added in v0.3.0

func (p *Image) FlipV() *Image

func (*Image) RGBA64At added in v0.3.0

func (p *Image) RGBA64At(x, y int) color.RGBA64

func (*Image) String added in v0.3.0

func (p *Image) String() string

func (*Image) SubImage added in v0.3.0

func (p *Image) SubImage(r image.Rectangle) *Image

SubImage returns a picture inside of r in CodePoints. The returned value is shared with original picture.

func (*Image) SubImagePix added in v0.3.0

func (p *Image) SubImagePix(r image.Rectangle) *Image

SubImagePix returns a picture inside of r in pixels. The returned value is shared with original picture.

type Renderer

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

func NewRenderer

func NewRenderer(buf []byte) *Renderer

func (*Renderer) Render

func (r *Renderer) Render(w io.Writer, p *Image) error

Render writes all image data into buffer, then writes buffered data into wr.

type ThresholdMap added in v0.2.0

type ThresholdMap struct {
	Base uint16
	Rows [][]uint16
}

ThresholdMap valid example: [0 2] [3 1]

func GenerateThresholdMap added in v0.2.0

func GenerateThresholdMap(n int) ThresholdMap

Directories

Path Synopsis
examples
png

Jump to

Keyboard shortcuts

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