Documentation
¶
Index ¶
- Constants
- func NewPixel(opts ...PixelOption) (term.Pixel, error)
- type Cell
- type Item
- type LeveledList
- type Line
- type LineOption
- type LinearGradient
- func (l *LinearGradient) Generate(iw, ih int) image.Image
- func (l *LinearGradient) Hide()
- func (l *LinearGradient) MinSize() *term.Size
- func (l *LinearGradient) Move(pos *term.Position)
- func (l *LinearGradient) Position() *term.Position
- func (l *LinearGradient) Resize(size *term.Size)
- func (l *LinearGradient) SetMinSize(size *term.Size)
- func (l *LinearGradient) Show()
- func (l *LinearGradient) Size() *term.Size
- func (l *LinearGradient) Visible() bool
- type Node
- type Owners
- type Page
- func (p *Page) Activate()
- func (r *Page) Column(index int) Pixels
- func (r *Page) Columns() PixelsMatrix
- func (p *Page) Deactivate()
- func (p *Page) DyingChan() chan struct{}
- func (r *Page) HasColumns() bool
- func (r *Page) HasRows() bool
- func (p *Page) KeyListen() chan term.KeyEvent
- func (p *Page) MouseListen() chan term.MouseEvent
- func (r *Page) NumColumns() int
- func (r *Page) NumRows() int
- func (r *Page) Orientation() style.Orientation
- func (p *Page) ResizeListen() chan term.ResizeEvent
- func (r *Page) Row(index int) Pixels
- func (r *Page) Rows() PixelsMatrix
- func (p *Page) Shutdown()
- type PageOption
- type PixelOption
- type Pixels
- type PixelsMatrix
- type RadialGradient
- func (r *RadialGradient) Generate(iw, ih int) image.Image
- func (r *RadialGradient) Hide()
- func (r *RadialGradient) MinSize() *term.Size
- func (r *RadialGradient) Move(pos *term.Position)
- func (r *RadialGradient) Position() *term.Position
- func (r *RadialGradient) Resize(size *term.Size)
- func (r *RadialGradient) SetMinSize(size *term.Size)
- func (r *RadialGradient) Show()
- func (r *RadialGradient) Size() *term.Size
- func (r *RadialGradient) Visible() bool
- type Rectangle
- func (r *Rectangle) AtBegin() bool
- func (r *Rectangle) AtBottom() bool
- func (r *Rectangle) AtEnd() bool
- func (r *Rectangle) AtHorizontalCenter() bool
- func (r *Rectangle) AtLeft() bool
- func (r *Rectangle) AtMiddle() bool
- func (r *Rectangle) AtRight() bool
- func (r *Rectangle) AtTop() bool
- func (r *Rectangle) AtVerticalCenter() bool
- func (r *Rectangle) Bg() color.Color
- func (r *Rectangle) Bottom() *term.Position
- func (r *Rectangle) Center() *term.Position
- func (r *Rectangle) Column(index int) Pixels
- func (r *Rectangle) Columns() PixelsMatrix
- func (r *Rectangle) DyingChan() chan struct{}
- func (r *Rectangle) Empty() bool
- func (r *Rectangle) Fg() color.Color
- func (r *Rectangle) HasColumns() bool
- func (r *Rectangle) HasPerfectCenter() bool
- func (r *Rectangle) HasRows() bool
- func (r *Rectangle) Height() int
- func (r *Rectangle) Hide()
- func (r *Rectangle) Id() int
- func (r *Rectangle) In(s *Rectangle) bool
- func (r *Rectangle) Intersect(s *Rectangle) *Rectangle
- func (r *Rectangle) Invalid() bool
- func (r *Rectangle) MinSize() *term.Size
- func (r *Rectangle) Move(pos *term.Position)
- func (r *Rectangle) NumColumns() int
- func (r *Rectangle) NumRows() int
- func (r *Rectangle) Orientation() style.Orientation
- func (r *Rectangle) Overlaps(s *Rectangle) bool
- func (r *Rectangle) PixelAskChan() chan term.Position
- func (r *Rectangle) PixelReceiverChan() chan px
- func (r *Rectangle) PixelReleaseChan() chan term.Position
- func (r *Rectangle) ResizeListen() chan term.ResizeEvent
- func (r *Rectangle) Row(index int) Pixels
- func (r *Rectangle) Rows() PixelsMatrix
- func (r *Rectangle) SetChildren(children ...*Rectangle)
- func (r *Rectangle) SetMinSize(size *term.Size)
- func (r *Rectangle) Show()
- func (r *Rectangle) Size() *term.Size
- func (r *Rectangle) Top() *term.Position
- func (r *Rectangle) Union(s *Rectangle) *Rectangle
- func (r *Rectangle) Visible() bool
- func (r *Rectangle) Width() int
- type RectangleOption
- func AsColumn(column, startRow, endRow int) RectangleOption
- func AsLine(line, startColumn, endColumn int) RectangleOption
- func WithAcquisitionChan(pixelCh chan term.Position) RectangleOption
- func WithAlignment(a style.Alignment) RectangleOption
- func WithBackgroundColor(c color.Color) RectangleOption
- func WithBottomCorner(col, row int) RectangleOption
- func WithChildren(children ...*Rectangle) RectangleOption
- func WithCore(engine term.Engine) RectangleOption
- func WithForegroundColor(c color.Color) RectangleOption
- func WithHeight(percent int) RectangleOption
- func WithMinSize(size *term.Size) RectangleOption
- func WithOrientation(o style.Orientation) RectangleOption
- func WithReleasingChan(relePixelCh chan term.Position) RectangleOption
- func WithRowColAndSize(row, column, numRows, numCols int) RectangleOption
- func WithTopCorner(col, row int) RectangleOption
- func WithWidth(percent int) RectangleOption
- func WithWidthAndHeight(widthPercent, heightPercent int) RectangleOption
- type RootRectangle
- type Screen
- type Tree
- type Window
Constants ¶
const (
Debug = true // if set to false, the compiler will cleanup/remove the lines inside functions
)
Variables ¶
This section is empty.
Functions ¶
func NewPixel ¶
func NewPixel(opts ...PixelOption) (term.Pixel, error)
NewPixel constructs a term.Pixel implementation, to be used as both term.Pixel and term.PixelSetter interfaces Note : the reason for which we're using image.Point relies on the functionality it provides regarding image package, e.g : image.Point.In(r image.Rectangle) Another note, important : the background and foreground needs to be defaulted to color.Default because engine performs extra steps otherwise. Search core.drawPixel method for `positions "needed" from geom.Pixel`
Types ¶
type Item ¶
Item combines a text with a specific level. The level is the indent, which would normally be seen in a BulletList.
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line describes a colored line primitive. Lines are special as they can have a negative width or height to indicate an inverse slope (i.e. slope up vs down).
func NewLine ¶
func NewLine(ctx context.Context, opts ...LineOption) *Line
NewLine returns a new Line instance
func (*Line) Position ¶
Position gets the current top-left position of this line object, relative to its children / canvas
func (*Line) Resize ¶
Resize sets a new bottom-right position for the line object and it will then be refreshed.
type LineOption ¶
type LineOption func(l *Line)
func WithPositions ¶
func WithPositions(from, to *term.Position) LineOption
type LinearGradient ¶
type LinearGradient struct { sync.RWMutex // StartColor color.Color // The beginning color of the gradient EndColor color.Color // The end color of the gradient Angle float64 // The angle of the gradient (0/180 for vertical; 90/270 for horizontal) Hidden bool // Is this object currently hidden // contains filtered or unexported fields }
LinearGradient defines a Gradient travelling straight at a given angle. The only supported values for the angle are `0.0` (vertical) and `90.0` (horizontal), currently.
func NewHorizontalGradient ¶
func NewHorizontalGradient(start, end color.Color) *LinearGradient
NewHorizontalGradient creates a new horizontally travelling linear gradient. The start color will be at the left of the gradient and the end color will be at the right.
func NewLinearGradient ¶
func NewLinearGradient(start, end color.Color, angle float64) *LinearGradient
NewLinearGradient creates a linear gradient at a the specified angle. The angle parameter is the degree angle along which the gradient is calculated. A NewHorizontalGradient uses 270 degrees and NewVerticalGradient is 0 degrees.
func NewVerticalGradient ¶
func NewVerticalGradient(start color.Color, end color.Color) *LinearGradient
NewVerticalGradient creates a new vertically travelling linear gradient. The start color will be at the top of the gradient and the end color will be at the bottom.
func (*LinearGradient) Generate ¶
func (l *LinearGradient) Generate(iw, ih int) image.Image
Generate calculates an image of the gradient with the specified width and height.
func (*LinearGradient) Hide ¶
func (l *LinearGradient) Hide()
Hide will set this object to not be visible
func (*LinearGradient) MinSize ¶
func (l *LinearGradient) MinSize() *term.Size
MinSize returns the specified minimum size, if set, or {1, 1} otherwise
func (*LinearGradient) Move ¶
func (l *LinearGradient) Move(pos *term.Position)
Move the rectangle object to a new position, relative to its children / canvas
func (*LinearGradient) Position ¶
func (l *LinearGradient) Position() *term.Position
CurrentPosition gets the current position of this rectangle object, relative to its children / canvas
func (*LinearGradient) Resize ¶
func (l *LinearGradient) Resize(size *term.Size)
Resize sets a new size for the rectangle object
func (*LinearGradient) SetMinSize ¶
func (l *LinearGradient) SetMinSize(size *term.Size)
SetMinSize specifies the smallest size this object should be
func (*LinearGradient) Show ¶
func (l *LinearGradient) Show()
Show will set this object to be visible
func (*LinearGradient) Size ¶
func (l *LinearGradient) Size() *term.Size
CurrentSize returns the current size of this rectangle object
func (*LinearGradient) Visible ¶
func (l *LinearGradient) Visible() bool
IsVisible returns true if this object is visible, false otherwise
type Node ¶
type Node struct { Children []Node // Rectangle *Rectangle // // contains filtered or unexported fields }
Node is used as items in a Tree.
func NewTreeFromLeveledList ¶
func NewTreeFromLeveledList(items LeveledList) Node
NewTreeFromLeveledList converts a TreeItems list to a Node and returns it.
type Page ¶
type Page struct { sync.RWMutex // sync.Once // required for registering lifecycle goroutines exactly once // contains filtered or unexported fields }
Page
type PageOption ¶
type PageOption func(p *Page)
PageOption
func WithPageOrientation ¶
func WithPageOrientation(o style.Orientation) PageOption
WithPageOrientation
type PixelOption ¶
type PixelOption func(p *px)
PixelOption for functional options
func WithPosition ¶
func WithPosition(pos *term.Position) PixelOption
WithPosition is required - row is X, column is Y
type PixelsMatrix ¶
type PixelsMatrix []Pixels
type RadialGradient ¶
type RadialGradient struct { sync.RWMutex // StartColor color.Color // The beginning color of the gradient EndColor color.Color // The end color of the gradient CenterOffsetX float64 // The offset of the center for generation of the gradient. This is not a DP measure but relates to the width/height. A value of 0.5 would move the center by the half width/height. CenterOffsetY float64 // Hidden bool // Is this object currently hidden // contains filtered or unexported fields }
RadialGradient defines a Gradient travelling radially from a center point outward.
func NewRadialGradient ¶
func NewRadialGradient(start, end color.Color) *RadialGradient
NewRadialGradient creates a new radial gradient.
func (*RadialGradient) Generate ¶
func (r *RadialGradient) Generate(iw, ih int) image.Image
Generate calculates an image of the gradient with the specified width and height.
func (*RadialGradient) Hide ¶
func (r *RadialGradient) Hide()
Hide will set this object to not be visible
func (*RadialGradient) MinSize ¶
func (r *RadialGradient) MinSize() *term.Size
MinSize returns the specified minimum size, if set, or {1, 1} otherwise
func (*RadialGradient) Move ¶
func (r *RadialGradient) Move(pos *term.Position)
Move the rectangle object to a new position, relative to its children / canvas
func (*RadialGradient) Position ¶
func (r *RadialGradient) Position() *term.Position
CurrentPosition gets the current position of this rectangle object, relative to its children / canvas
func (*RadialGradient) Resize ¶
func (r *RadialGradient) Resize(size *term.Size)
Resize sets a new size for the rectangle object
func (*RadialGradient) SetMinSize ¶
func (r *RadialGradient) SetMinSize(size *term.Size)
SetMinSize specifies the smallest size this object should be
func (*RadialGradient) Show ¶
func (r *RadialGradient) Show()
Show will set this object to be visible
func (*RadialGradient) Size ¶
func (r *RadialGradient) Size() *term.Size
CurrentSize returns the current size of this rectangle object
func (*RadialGradient) Visible ¶
func (r *RadialGradient) Visible() bool
IsVisible returns true if this object is visible, false otherwise
type Rectangle ¶
type Rectangle struct {
// contains filtered or unexported fields
}
Rectangle describes a colored rectangle primitive
func NewRectangle ¶
func NewRectangle(ctx context.Context, opts ...RectangleOption) (*Rectangle, error)
TODO : thinking maybe this should be a private constructor. Ask Page to give you a Rectangle and it will give it already populated and ready to use. For now (testing purposes), I'll leave it as it is. NewRectangle returns a new Rectangle instance
func (*Rectangle) AtHorizontalCenter ¶
AtHorizontalCenter indicates horizontally centered.
func (*Rectangle) AtVerticalCenter ¶
AtVerticalCenter indicates vertically centered.
func (*Rectangle) Column ¶
Column returns the column of pixels at index (absolute, starting with zero)
func (*Rectangle) DyingChan ¶
func (r *Rectangle) DyingChan() chan struct{}
DyingChan implementation of term.Death interface, listened in core for waiting graceful shutdown
func (*Rectangle) HasPerfectCenter ¶
HasPerfectCenter - allows the caller of Center not to fool themselves (e.g. center is shifted towards top right)
func (*Rectangle) Intersect ¶
Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.
func (*Rectangle) Move ¶
Move the rectangle object to a new position, relative to its children / canvas
func (*Rectangle) NumColumns ¶
func (r *Rectangle) NumColumns() int
NumColumns - depends on orientation
func (*Rectangle) PixelAskChan ¶
PixelAskChan - used by Page to deliver pixels
func (*Rectangle) PixelReceiverChan ¶
func (r *Rectangle) PixelReceiverChan() chan px
PixelReceiverChan - used by Rectangle to get pixels from Page
func (*Rectangle) PixelReleaseChan ¶
PixelReleaseChan - use by Page to change owner of the pixel
func (*Rectangle) ResizeListen ¶
func (r *Rectangle) ResizeListen() chan term.ResizeEvent
ResizeListen
func (*Rectangle) SetChildren ¶
SetChildren - general convention that all siblings are registered together so we can perform calculations of positions and invalidate recursively the children rectangles
func (*Rectangle) SetMinSize ¶
SetMinSize specifies the smallest size this object should be
type RectangleOption ¶
type RectangleOption func(r *Rectangle)
RectangleOption
func WithAcquisitionChan ¶
func WithAcquisitionChan(pixelCh chan term.Position) RectangleOption
WithAcquisitionChan is provided by the caller, so we can "ask" for pixels
func WithBackgroundColor ¶
func WithBackgroundColor(c color.Color) RectangleOption
WithBackgroundColor
func WithForegroundColor ¶
func WithForegroundColor(c color.Color) RectangleOption
WithForegroundColor
func WithReleasingChan ¶
func WithReleasingChan(relePixelCh chan term.Position) RectangleOption
WithReleasingChan is provided by the caller, so we can "free" pixels
func WithRowColAndSize ¶
func WithRowColAndSize(row, column, numRows, numCols int) RectangleOption
WithRowColAndSize
func WithWidthAndHeight ¶
func WithWidthAndHeight(widthPercent, heightPercent int) RectangleOption
WithWidthAndHeight
type RootRectangle ¶
type RootRectangle interface { Orientation() style.Orientation HasRows() bool NumRows() int Rows() PixelsMatrix Row(index int) Pixels HasColumns() bool NumColumns() int Columns() PixelsMatrix Column(index int) Pixels }
RootRectangle interface