graphic

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpaceRune = '\u0020'

	BarRuneV = '\u2580'
	BarRune  = '\u2588'
	BarRuneH = '\u2590'

	StyleReverse = termbox.AttrReverse

	// NumRunes number of runes for sub step bars
	NumRunes = 8

	// ScalingWindow in seconds
	ScalingWindow = 1.5
	// PeakThreshold is the threshold to not draw if the peak is less.
	PeakThreshold = 0.001
)

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

type Display struct {
	Smoother dsp.Smoother
	// contains filtered or unexported fields
}

Display handles drawing our visualizer.

func NewDisplay

func NewDisplay() *Display

func (*Display) AdjustBase

func (d *Display) AdjustBase(delta int)

AdjustBase will change the base by delta units

func (*Display) AdjustSizes added in v1.5.0

func (d *Display) AdjustSizes(barDelta, spaceDelta int)

AdjustSizes modifies the bar and space size by barDelta and spaceDelta.

func (*Display) Bins added in v1.7.0

func (d *Display) Bins(chCount int) int

Bins returns the number of bars we will draw.

func (*Display) Close

func (d *Display) Close() error

Close will stop display and clean up the terminal.

func (*Display) Init

func (d *Display) Init(sampleRate float64, sampleSize int) error

Init initializes the display. Should be called before any other display method.

func (*Display) SetBase

func (d *Display) SetBase(size int)

SetBase will set the base size.

func (*Display) SetDrawType

func (d *Display) SetDrawType(dt DrawType)

SetDrawType sets the draw type for future draws

func (*Display) SetInvertDraw added in v1.7.0

func (d *Display) SetInvertDraw(invert bool)

func (*Display) SetSizes added in v1.5.0

func (d *Display) SetSizes(bar, space int)

SetSizes takes a bar size and spacing size. Returns number of bars able to show.

func (*Display) SetStyles added in v1.5.0

func (d *Display) SetStyles(styles Styles)

func (*Display) Start

func (d *Display) Start(ctx context.Context) context.Context

Start display is bad.

func (*Display) Stop

func (d *Display) Stop() error

Stop display not work.

func (*Display) Write added in v1.7.0

func (d *Display) Write(buffers [][]float64, channels int) error

Draw takes data and draws.

type DrawType

type DrawType int

DrawType is the type.

const (
	DrawMin DrawType = iota
	DrawUp
	DrawUpDown
	DrawDown
	DrawLeft
	DrawLeftRight
	DrawRight
	DrawUpDownSplit
	DrawLeftRightSplit
	DrawUpDownSplitVert
	DrawMax

	// DrawDefault is the default draw type.
	DrawDefault = DrawUpDown
)

draw types

type Styles added in v1.5.0

type Styles struct {
	Foreground termbox.Attribute
	Background termbox.Attribute
	CenterLine termbox.Attribute
}

Styles is the structure for the styles that Display will draw using.

func DefaultStyles added in v1.5.0

func DefaultStyles() Styles

DefaultStyles returns the default styles.

func StylesFromUInt16 added in v1.5.0

func StylesFromUInt16(fg, bg, center uint16) Styles

StylesFromUInt16 converts 3 uint16 values to styles.

func (Styles) AsUInt16s added in v1.5.0

func (s Styles) AsUInt16s() (fg, bg, center uint16)

AsUInt16s converts the styles to 3 uint16 values.

Jump to

Keyboard shortcuts

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