letters

package
v0.0.0-...-c6d1081 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWidth  float64 = 51.
	DefaultHeight float64 = 85.
)

Default dimensions of the original segment's cell

View Source
const (
	DGapThinnest    = 5
	DDiagonalHeight = DefaultHeight / 4
)

Sizes a D

View Source
const (
	StateFadein = iota
	StateSolid
	StateFadeout
)

Possible states of a segment

View Source
const ABarUpperHeight = DefaultHeight - 35

ABarUpperHeight is the height of the line through the centre of an A

View Source
const EEdgeDepth = 5

EEdgeDepth is how far in the centre line of the E is from the right

View Source
const EPointDepth = 13

EPointDepth is how far in the dip on the left of an E goes in

View Source
const IOverhang = 7

IOverhang is how far the top bar of an I hangs over

View Source
const SStickLength = 7

SStickLength is the length of the sticks on the tops and bottoms of an S

Variables

View Source
var (
	ColorsDeath = [2]color.RGBA{
		{0x31, 0x34, 0x16, 0xff},
		{0x95, 0x97, 0x7E, 0xff},
	}
	ColorsParadox = [2]color.RGBA{
		{0x50, 0x41, 0x39, 0xff},
		{0x00, 0x00, 0x00, 0xff},
	}
)

Original Colours

Functions

func GetLetterMap

func GetLetterMap() map[byte]func() Letter

GetLetterMap returns a map to get the functions corresponding to each letter

Types

type Cell

type Cell struct {
	TopLeft       [2]float64
	BottomRight   [2]float64
	Segments      []Segment
	DeathColors   [2]color.RGBA
	ParadoxColors [2]color.RGBA
	LetterColor   color.Color
}

Cell represents a single cell containing LetterSegments

func NewCell

func NewCell(topLeft, bottomRight [2]float64, segments []Segment, deathColors, paradoxColors [2]color.RGBA) *Cell

NewCell creates a new Cell. The color arguments take an array of two colors, the first is the background and the second is the foreground.

func (*Cell) Draw

func (cell *Cell) Draw(gc *draw2dimg.GraphicContext) bool

Draw calls the Draw method for all of its segments for them to render onto it. The image is then rendered onto the main context.

func (*Cell) Height

func (cell *Cell) Height() float64

Height returns the cell's height

func (*Cell) Scale

func (cell *Cell) Scale(factor float64)

Scale increases the size of the cell, keeping the centre the same

func (*Cell) Translate

func (cell *Cell) Translate(x, y float64)

Translate moves the cell on the screen

func (*Cell) Width

func (cell *Cell) Width() float64

Width returns the cell's width

type CellDrawer

type CellDrawer interface {
	Fill(paths ...*draw2d.Path)
	FillStroke(paths ...*draw2d.Path)
	Stroke(paths ...*draw2d.Path)
	Close()
	SetFillColor(c color.Color)
	SetStrokeColor(c color.Color)
	MoveTo(x, y float64)
	LineTo(x, y float64)
}

CellDrawer represents a type that contains all of the drawing functions needed by a segment in order to draw within the cell

func NewCellDrawer

func NewCellDrawer(gc *draw2dimg.GraphicContext, cell *Cell, segment Segment) CellDrawer

NewCellDrawer creates a CellDrawer for allowing a segment to draw within a cell. It allows the Cell and the segment's reference sizes to be different, and will translate between one and the other to simplify the construction of segment drawing procedures.

type Letter

type Letter []Segment

Letter defines a custom type for full letters. A letter is defined as a slice of segments.

func LetterA

func LetterA() Letter

LetterA returns all the segments for the letter A

func LetterD

func LetterD() Letter

LetterD returns all the segments for the letter D

func LetterE

func LetterE() Letter

LetterE returns all the segments for the letter E

func LetterI

func LetterI() Letter

LetterI returns all the segments for the letter I

func LetterK

func LetterK() Letter

LetterK returns all the segments for the letter K

func LetterN

func LetterN() Letter

LetterN returns all the segments for the letter N

func LetterS

func LetterS() Letter

LetterS returns all the segments for the letter S

func LetterSpace

func LetterSpace() Letter

LetterSpace returns a blank collection of segments

type Segment

type Segment interface {
	Width() float64
	Height() float64
	Draw(CellDrawer, *Cell) bool // defined for each type
	ID() SegmentID               // defined for each type
}

Segment is an interface representing a segment of a letter. Any coordinates used should be defined in terms of the cell

type SegmentABar

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

SegmentABar is the horizontal line through an A

func (*SegmentABar) Draw

func (seg *SegmentABar) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentABar) Height

func (seg *SegmentABar) Height() float64

Height returns the Height of the segment

func (*SegmentABar) ID

func (seg *SegmentABar) ID() SegmentID

ID returns the ID of the segment

func (*SegmentABar) Width

func (seg *SegmentABar) Width() float64

Width returns the Width of the segment

type SegmentARisingStick

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

SegmentARisingStick is one of the parts of an A

  / /
 / /
| |
| |

func (*SegmentARisingStick) Draw

func (seg *SegmentARisingStick) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentARisingStick) Height

func (seg *SegmentARisingStick) Height() float64

Height returns the Height of the segment

func (*SegmentARisingStick) ID

func (seg *SegmentARisingStick) ID() SegmentID

ID returns the ID of the segment

func (*SegmentARisingStick) Width

func (seg *SegmentARisingStick) Width() float64

Width returns the Width of the segment

type SegmentDCurve

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

SegmentDCurve is the curved line of a D

func (*SegmentDCurve) Draw

func (seg *SegmentDCurve) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentDCurve) Height

func (seg *SegmentDCurve) Height() float64

Height returns the Height of the segment

func (*SegmentDCurve) ID

func (seg *SegmentDCurve) ID() SegmentID

ID returns the ID of the segment

func (*SegmentDCurve) Width

func (seg *SegmentDCurve) Width() float64

Width returns the Width of the segment

type SegmentELower

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

SegmentELower is the lower bar on an E

func (*SegmentELower) Draw

func (seg *SegmentELower) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentELower) Height

func (seg *SegmentELower) Height() float64

Height returns the Height of the segment

func (*SegmentELower) ID

func (seg *SegmentELower) ID() SegmentID

ID returns the ID of the segment

func (*SegmentELower) Width

func (seg *SegmentELower) Width() float64

Width returns the Width of the segment

type SegmentEMiddle

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

SegmentEMiddle is the centre segment of an E

func (*SegmentEMiddle) Draw

func (seg *SegmentEMiddle) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentEMiddle) Height

func (seg *SegmentEMiddle) Height() float64

Height returns the Height of the segment

func (*SegmentEMiddle) ID

func (seg *SegmentEMiddle) ID() SegmentID

ID returns the ID of the segment

func (*SegmentEMiddle) Width

func (seg *SegmentEMiddle) Width() float64

Width returns the Width of the segment

type SegmentIBottom

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

SegmentIBottom is the line below an I

func (*SegmentIBottom) Draw

func (seg *SegmentIBottom) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentIBottom) Height

func (seg *SegmentIBottom) Height() float64

Height returns the Height of the segment

func (*SegmentIBottom) ID

func (seg *SegmentIBottom) ID() SegmentID

ID returns the ID of the segment

func (*SegmentIBottom) Width

func (seg *SegmentIBottom) Width() float64

Width returns the Width of the segment

type SegmentID

type SegmentID int

SegmentID is a unique type for unique Segment IDs

const (
	IDSUpperBar SegmentID = iota
	IDSLowerBar
	IDSMiddle
	IDNLeftVert
	IDNBar
	IDNRightVert
	IDARisingStick
	IDABar
	IDKUpper
	IDKLower
	IDELower
	IDEMiddle
	IDIMiddle
	IDITop
	IDIBottom
	IDDCurve
)

Segment IDs

type SegmentIMiddle

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

SegmentIMiddle is the line through the centre of an I

func (*SegmentIMiddle) Draw

func (seg *SegmentIMiddle) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentIMiddle) Height

func (seg *SegmentIMiddle) Height() float64

Height returns the Height of the segment

func (*SegmentIMiddle) ID

func (seg *SegmentIMiddle) ID() SegmentID

ID returns the ID of the segment

func (*SegmentIMiddle) Width

func (seg *SegmentIMiddle) Width() float64

Width returns the Width of the segment

type SegmentITop

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

SegmentITop is the line atop an I

func (*SegmentITop) Draw

func (seg *SegmentITop) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentITop) Height

func (seg *SegmentITop) Height() float64

Height returns the Height of the segment

func (*SegmentITop) ID

func (seg *SegmentITop) ID() SegmentID

ID returns the ID of the segment

func (*SegmentITop) Width

func (seg *SegmentITop) Width() float64

Width returns the Width of the segment

type SegmentKLower

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

SegmentKLower is the upper part of a K

func (*SegmentKLower) Draw

func (seg *SegmentKLower) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentKLower) Height

func (seg *SegmentKLower) Height() float64

Height returns the Height of the segment

func (*SegmentKLower) ID

func (seg *SegmentKLower) ID() SegmentID

ID returns the ID of the segment

func (*SegmentKLower) Width

func (seg *SegmentKLower) Width() float64

Width returns the Width of the segment

type SegmentKUpper

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

SegmentKUpper is the upper part of a K

func (*SegmentKUpper) Draw

func (seg *SegmentKUpper) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentKUpper) Height

func (seg *SegmentKUpper) Height() float64

Height returns the Height of the segment

func (*SegmentKUpper) ID

func (seg *SegmentKUpper) ID() SegmentID

ID returns the ID of the segment

func (*SegmentKUpper) Width

func (seg *SegmentKUpper) Width() float64

Width returns the Width of the segment

type SegmentNBar

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

SegmentNBar is the vertical bar across the top of an N

func (*SegmentNBar) Draw

func (seg *SegmentNBar) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentNBar) Height

func (seg *SegmentNBar) Height() float64

Height returns the Height of the segment

func (*SegmentNBar) ID

func (seg *SegmentNBar) ID() SegmentID

ID returns the ID of the segment

func (*SegmentNBar) Width

func (seg *SegmentNBar) Width() float64

Width returns the Width of the segment

type SegmentNLeftVert

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

SegmentNLeftVert is the vertical line on the right hand side of an N

func (*SegmentNLeftVert) Draw

func (seg *SegmentNLeftVert) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentNLeftVert) Height

func (seg *SegmentNLeftVert) Height() float64

Height returns the Height of the segment

func (*SegmentNLeftVert) ID

func (seg *SegmentNLeftVert) ID() SegmentID

ID returns the ID of the segment

func (*SegmentNLeftVert) Width

func (seg *SegmentNLeftVert) Width() float64

Width returns the Width of the segment

type SegmentNRightVert

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

SegmentNRightVert is the vertical line on the right hand side of an N

func (*SegmentNRightVert) Draw

func (seg *SegmentNRightVert) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentNRightVert) Height

func (seg *SegmentNRightVert) Height() float64

Height returns the Height of the segment

func (*SegmentNRightVert) ID

func (seg *SegmentNRightVert) ID() SegmentID

ID returns the ID of the segment

func (*SegmentNRightVert) Width

func (seg *SegmentNRightVert) Width() float64

Width returns the Width of the segment

type SegmentSLowerBar

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

SegmentSLowerBar is the bottom bar on an S

func (*SegmentSLowerBar) Draw

func (seg *SegmentSLowerBar) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentSLowerBar) Height

func (seg *SegmentSLowerBar) Height() float64

Height returns the Height of the segment

func (*SegmentSLowerBar) ID

func (seg *SegmentSLowerBar) ID() SegmentID

ID returns the ID of the segment

func (*SegmentSLowerBar) Width

func (seg *SegmentSLowerBar) Width() float64

Width returns the Width of the segment

type SegmentSMiddle

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

SegmentSMiddle is the middle section of an S

func (*SegmentSMiddle) Draw

func (seg *SegmentSMiddle) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentSMiddle) Height

func (seg *SegmentSMiddle) Height() float64

Height returns the Height of the segment

func (*SegmentSMiddle) ID

func (seg *SegmentSMiddle) ID() SegmentID

ID returns the ID of the segment

func (*SegmentSMiddle) Width

func (seg *SegmentSMiddle) Width() float64

Width returns the Width of the segment

type SegmentSUpperBar

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

SegmentSUpperBar is the top bar on an S

func (*SegmentSUpperBar) Draw

func (seg *SegmentSUpperBar) Draw(gc CellDrawer, cell *Cell) bool

Draw defines the behaviour of the segment

func (*SegmentSUpperBar) Height

func (seg *SegmentSUpperBar) Height() float64

Height returns the Height of the segment

func (*SegmentSUpperBar) ID

func (seg *SegmentSUpperBar) ID() SegmentID

ID returns the ID of the segment

func (*SegmentSUpperBar) Width

func (seg *SegmentSUpperBar) Width() float64

Width returns the Width of the segment

type SegmentState

type SegmentState int

SegmentState is a type used for storing various internal states of the segments

Jump to

Keyboard shortcuts

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