Documentation
¶
Index ¶
- func NewProgram(vertexShaderSource, fragmentShaderSource string) (uint32, error)
- type BoundingBox
- type CharacterSide
- type Font
- type Text
- func (t *Text) AddScale(s float32) bool
- func (t *Text) BeginFadeOut()
- func (t *Text) CharPosition(index int) float64
- func (t *Text) ClickedCharacter(xPos, offset float64) (index int, side CharacterSide)
- func (t *Text) Draw()
- func (t *Text) GetBoundingBox() (X1, X2 gltext.Point)
- func (t *Text) GetLength() int
- func (t *Text) HasRune(r rune) bool
- func (t *Text) Height() float32
- func (t *Text) Hide()
- func (t *Text) PrintCharSpacing()
- func (t *Text) Release()
- func (t *Text) SetColor(color mgl32.Vec3)
- func (t *Text) SetPosition(v mgl32.Vec2)
- func (t *Text) SetScale(s float32) bool
- func (t *Text) SetString(fs string, argv ...interface{})
- func (t *Text) Show()
- func (t *Text) Width() float32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProgram ¶
Types ¶
type BoundingBox ¶
type BoundingBox struct {
// X1, X2: the lower left and upper right points of a box that bounds the text
X1 gltext.Point
X2 gltext.Point
// contains filtered or unexported fields
}
func (*BoundingBox) Draw ¶
func (b *BoundingBox) Draw()
func (*BoundingBox) Release ¶
func (b *BoundingBox) Release()
type CharacterSide ¶
type CharacterSide int
CharacterSide shows which side of a character is clicked
const ( CSLeft CharacterSide = iota CSRight CSUnknown )
type Font ¶
type Font struct {
Config *gltext.FontConfig // Character set for this font.
OrthographicMatrix mgl32.Mat4
WindowWidth float32
WindowHeight float32
// contains filtered or unexported fields
}
func (*Font) GetTextureHeight ¶
func (*Font) GetTextureWidth ¶
func (*Font) ResizeWindow ¶
type Text ¶
type Text struct {
Font *Font
// scaling the text
Scale float32
ScaleMin float32
ScaleMax float32
// Fadeout reduces alpha
FadeOutBegun bool
FadeOutFrameCount float32 // number of frames since drawing began
FadeOutPerFrame float32 // smaller value takes more time
// bounding box of text
BoundingBox *BoundingBox
// determines how many prefix characters are drawn on screen
RuneCount int
// no longer than this string
MaxRuneCount int
// lower left
X1 gltext.Point
// upper right
X2 gltext.Point
// Screen position away from center
Position mgl32.Vec2
String string
CharSpacing []float32
// contains filtered or unexported fields
}
Text is not designed to be accessed concurrently
func NewText ¶
NewText creates a new text object with scaling boundaries the rest state of the text when not being interacted with is scaleMin. most likely one wants to use 1.0.
func (*Text) BeginFadeOut ¶
func (t *Text) BeginFadeOut()
func (*Text) CharPosition ¶
func (*Text) ClickedCharacter ¶
func (t *Text) ClickedCharacter(xPos, offset float64) (index int, side CharacterSide)
ClickedCharacter should only be called after a bounding box hit is confirmed because it does not check y-axis values at all. Returns the index and side of the char clicked.
func (*Text) GetBoundingBox ¶
func (*Text) PrintCharSpacing ¶
func (t *Text) PrintCharSpacing()
PrintCharSpacing is used for debugging
func (*Text) SetPosition ¶
SetPosition prepares variables passed to the shader as well as values used for bounding box calculations when clicking or hovering above text
Click to show internal directories.
Click to hide internal directories.