Documentation
¶
Index ¶
- func BoxTextBox() *boxTextBox
- func NewAlphaSourceImageMapper(i image.Image, multiplier float64) image.Image
- type AlphaSourceImageMapper
- type AnimationMode
- type AvatarFit
- type AvatarLocations
- type BoxByBoxAnimation
- type BoxShape
- type FadeAnimation
- type FadeState
- type Layout
- type LetterByLetterAnimation
- type MoreChevronLocations
- type Name
- type NamePositions
- type Option
- type Page
- type PostDrawer
- type SimpleLayout
- func (sl *SimpleLayout) AvatarRect() image.Rectangle
- func (sl *SimpleLayout) CenterRect() image.Rectangle
- func (sl *SimpleLayout) ChevronRect() image.Rectangle
- func (sl *SimpleLayout) FrameRect() image.Rectangle
- func (sl *SimpleLayout) NameRect() image.Rectangle
- func (sl *SimpleLayout) TextRect() image.Rectangle
- type SpaceMap
- type TextBox
- func (tb *TextBox) Avatar() image.Image
- func (tb *TextBox) CalculateAllPages(destSize image.Point) (int, error)
- func (tb *TextBox) DrawNextFrame(target wordwrap.Image) (lastPage bool, userInputAccepted bool, wait time.Duration, err error)
- func (tb *TextBox) DrawNextPageFrame(target wordwrap.Image, opts ...wordwrap.DrawOption) (bool, error)
- func (tb *TextBox) HasNext() bool
- func (tb *TextBox) SetSpaceMap(m SpaceMap)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoxTextBox ¶
func BoxTextBox() *boxTextBox
BoxTextBox creates a PostDrawer that draws a box around the text area.
Types ¶
type AlphaSourceImageMapper ¶
type AlphaSourceImageMapper struct {
// original image
image.Image
// Multiplier How much to "fade" it by
Multiplier float64
}
AlphaSourceImageMapper is a draw.Image compatible source image, that allows an image to fade.
type AnimationMode ¶
type AnimationMode interface {
// DrawOption draws with options.. Controls the drawing process to add extra frames and a delay to create an animation
// finished is true if you're on the last page
// userInputAccepted is if it's at the stage where you would typically accept user input (ie the animation is waiting
// user input, doesn't imply anything to do with the animation
// wait is either 0 or less, or the amount of time before the next animation phase
// err is err
// To determine if you're at the end the only way of doing it as of writing is to wait for; lastPage = true,
// userInputAccepted = false, wait = -1
DrawOption(target wordwrap.Image) (lastPage bool, userInputAccepted bool, wait time.Duration, err error)
Option
}
AnimationMode interface defining the optional animation. Used as an Option
type AvatarFit ¶
type AvatarFit int
AvatarFit defines how the avatar is scaled if it doesn't fit the allocated space.
const ( // NoAvatarFit performs no scaling (undefined behavior if too large). NoAvatarFit AvatarFit = iota // CenterAvatar centers the avatar without scaling. CenterAvatar // NearestNeighbour scales using nearest-neighbor interpolation. NearestNeighbour // ApproxBiLinear scales using approximate bi-linear interpolation. ApproxBiLinear )
type AvatarLocations ¶
type AvatarLocations int
AvatarLocations defines where the avatar is positioned relative to the text box.
const ( // NoAvatar hides the avatar. NoAvatar AvatarLocations = iota // LeftAvatar positions the avatar on the left. LeftAvatar // RightAvatar positions the avatar on the right. RightAvatar )
type BoxByBoxAnimation ¶
type BoxByBoxAnimation struct {
// The function to calculate the wait time between each box
WaitTimeFunc func(*BoxByBoxAnimation) time.Duration
// contains filtered or unexported fields
}
BoxByBoxAnimation is an animation style in which each non-whitespace box comes into visibility one by one
func NewBoxByBoxAnimation ¶
func NewBoxByBoxAnimation() *BoxByBoxAnimation
NewBoxByBoxAnimation creates an animation style where one block comes on at one time. Use WaitTimeFunc to create your own timing for each block
func (*BoxByBoxAnimation) DrawOption ¶
func (byb *BoxByBoxAnimation) DrawOption(target wordwrap.Image) (finished bool, userInputAccepted bool, waitTime time.Duration, err error)
DrawOption draws with options.. Controls the drawing process to add extra frames, a wait time and more finished is true if you're on the last page userInputAccepted is if it's at the stage where you would typically accept user input (ie the animation is waiting user input, doesn't imply anything to do with the animation wait is either 0 or less, or the amount of time before the next animation phase err is err To determine if you're at the end the only way of doing it as of writing is to wait for; lastPage = true, userInputAccepted = false, wait = -1
type FadeAnimation ¶
type FadeAnimation struct {
// contains filtered or unexported fields
}
FadeAnimation The animation for fading.
func NewFadeAnimation ¶
func NewFadeAnimation() *FadeAnimation
NewFadeAnimation constructs FadeAnimation
func (*FadeAnimation) DrawOption ¶
func (f *FadeAnimation) DrawOption(target wordwrap.Image) (finished bool, userInputAccepted bool, waitTime time.Duration, err error)
DrawOption draws with options.. Controls the drawing process to add extra frames, a wait time and more finished is true if you're on the last page userInputAccepted is if it's at the stage where you would typically accept user input (ie the animation is waiting user input, doesn't imply anything to do with the animation wait is either 0 or less, or the amount of time before the next animation phase err is err To determine if you're at the end the only way of doing it as of writing is to wait for; lastPage = true, userInputAccepted = false, wait = -1
type Layout ¶
type Layout interface {
// TextRect is the area containing the text.
TextRect() image.Rectangle
// CenterRect is the main content area inside the frame.
CenterRect() image.Rectangle
// AvatarRect is the area containing the avatar.
AvatarRect() image.Rectangle
// ChevronRect is the area containing the chevron.
ChevronRect() image.Rectangle
// NameRect is the optional area containing the name tag.
NameRect() image.Rectangle
// FrameRect is the area containing the frame.
FrameRect() image.Rectangle
}
Layout defines the positioning of elements within the text box.
type LetterByLetterAnimation ¶
type LetterByLetterAnimation struct {
// The function to calculate the wait time between each box
WaitTimeFunc func(*LetterByLetterAnimation) time.Duration
// contains filtered or unexported fields
}
LetterByLetterAnimation is an animation style in which each non-whitespace letter comes into visibility one by one
func NewLetterByLetterAnimation ¶
func NewLetterByLetterAnimation() *LetterByLetterAnimation
NewLetterByLetterAnimation creates an animation style where one block comes on at one time. Use WaitTimeFunc to create your own timing for each block
func (*LetterByLetterAnimation) DrawOption ¶
func (lyl *LetterByLetterAnimation) DrawOption(target wordwrap.Image) (finished bool, userInputAccepted bool, waitTime time.Duration, err error)
DrawOption draws with options.. Controls the drawing process to add extra frames, a wait time and more finished is true if you're on the last page userInputAccepted is if it's at the stage where you would typically accept user input (ie the animation is waiting user input, doesn't imply anything to do with the animation wait is either 0 or less, or the amount of time before the next animation phase err is err To determine if you're at the end the only way of doing it as of writing is to wait for; lastPage = true, userInputAccepted = false, wait = -1
type MoreChevronLocations ¶
type MoreChevronLocations int
MoreChevronLocations defines where the "next page" indicator is positioned.
const ( // NoMoreChevron hides the chevron. NoMoreChevron MoreChevronLocations = iota // CenterBottomInsideTextFrame positions the chevron centered at the bottom of the text area. CenterBottomInsideTextFrame // CenterBottomInsideFrame positions the chevron centered at the bottom of the entire frame. CenterBottomInsideFrame // CenterBottomOnFrameTextFrame positions the chevron centered on the bottom edge of the text area. CenterBottomOnFrameTextFrame // CenterBottomOnFrameFrame positions the chevron centered on the bottom edge of the frame. CenterBottomOnFrameFrame // RightBottomInsideTextFrame positions the chevron at the bottom right of the text area. RightBottomInsideTextFrame // RightBottomInsideFrame positions the chevron at the bottom right of the frame. RightBottomInsideFrame // RightBottomOnFrameTextFrame positions the chevron on the bottom right edge of the text area. RightBottomOnFrameTextFrame // RightBottomOnFrameFrame positions the chevron on the bottom right edge of the frame. RightBottomOnFrameFrame // TextEndChevron positions the chevron inline at the end of the text. TextEndChevron )
type NamePositions ¶
type NamePositions int
NamePositions defines where the name tag is positioned.
const ( // NoName hides the name tag. NoName NamePositions = iota // NameTopLeftAboveTextInFrame positions the name tag above the text, aligned left. NameTopLeftAboveTextInFrame // NameTopCenterInFrame positions the name tag above the text, centered. NameTopCenterInFrame // NameLeftAboveAvatarInFrame positions the name tag above the avatar, aligned left. NameLeftAboveAvatarInFrame // NameTopLeftAboveFrame positions the name tag above the frame, aligned left. NameTopLeftAboveFrame // NameTopCenterAboveFrame positions the name tag above the frame, centered. NameTopCenterAboveFrame )
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option defines a configuration option for the TextBox.
func WithWordwrapOption ¶ added in v0.0.5
func WithWordwrapOption(opt wordwrap.WrapperOption) Option
WithWordwrapOption allows passing wordwrap options as TextBox options
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page where a page of lines is stored with some statistical information. A page being what is visible in the provided rectangle
type PostDrawer ¶
type PostDrawer interface {
PostDraw(target wordwrap.Image, layout *SimpleLayout, ls []wordwrap.Line, options ...wordwrap.DrawOption) error
}
PostDrawer allows custom components to be drawn after standard elements.
type SimpleLayout ¶
type SimpleLayout struct {
// contains filtered or unexported fields
}
SimpleLayout implements a standard text box layout.
func NewSimpleLayout ¶
func NewSimpleLayout(tb *TextBox, destRect image.Rectangle) (*SimpleLayout, error)
NewSimpleLayout constructs SimpleLayout simply as possible (for the user.)
func (*SimpleLayout) AvatarRect ¶
func (sl *SimpleLayout) AvatarRect() image.Rectangle
AvatarRect returns the avatar rectangle.
func (*SimpleLayout) CenterRect ¶
func (sl *SimpleLayout) CenterRect() image.Rectangle
CenterRect returns the center content rectangle.
func (*SimpleLayout) ChevronRect ¶
func (sl *SimpleLayout) ChevronRect() image.Rectangle
ChevronRect returns the chevron rectangle.
func (*SimpleLayout) FrameRect ¶ added in v0.0.6
func (sl *SimpleLayout) FrameRect() image.Rectangle
FrameRect returns the frame rectangle.
func (*SimpleLayout) NameRect ¶
func (sl *SimpleLayout) NameRect() image.Rectangle
NameRect returns the name tag rectangle.
func (*SimpleLayout) TextRect ¶
func (sl *SimpleLayout) TextRect() image.Rectangle
TextRect returns the text rectangle.
type SpaceMap ¶ added in v0.0.5
SpaceMap is an interface for mapping screen space to interactive shapes.
type TextBox ¶
type TextBox struct {
// contains filtered or unexported fields
}
TextBox is the main component for rendering RPG-style text boxes.
func NewRichTextBox ¶ added in v0.0.5
NewRichTextBox creates a TextBox with rich text content (e.g. colors, images). theme is required. args can include string content, image.Point (for size), and Options.
func NewSimpleTextBox ¶
func NewSimpleTextBox(th theme.Theme, text string, destSize image.Point, options ...Option) (*TextBox, error)
NewSimpleTextBox creates a TextBox with simple string content. theme is required. destSize is the intended size of the image, but can be updated per frame.
func (*TextBox) CalculateAllPages ¶
CalculateAllPages calculates the box positioning of all remain pages in advance
func (*TextBox) DrawNextFrame ¶
func (tb *TextBox) DrawNextFrame(target wordwrap.Image) (lastPage bool, userInputAccepted bool, wait time.Duration, err error)
DrawNextFrame draws the next frame, if there is an animation it will draw the animation frame. lastPage is true if you're on the last page userInputAccepted is if it's at the stage where you would typically accept user input (ie the animation is waiting user input, doesn't imply anything to do with the animation wait is either 0 or less, or the amount of time before the next animation phase err is err To determine if you're at the end the only way of doing it as of writing is to wait for; lastPage = true, userInputAccepted = false, wait = -1
func (*TextBox) DrawNextPageFrame ¶
func (tb *TextBox) DrawNextPageFrame(target wordwrap.Image, opts ...wordwrap.DrawOption) (bool, error)
DrawNextPageFrame Draws the next frame ignores animation. Please use either function but be very careful if you use both, if it's supported is at an animation level
func (*TextBox) HasNext ¶
HasNext returns if there is a next page, this doesn't take into consideration if there is an animation
func (*TextBox) SetSpaceMap ¶ added in v0.0.5
SetSpaceMap sets the space map to populate