v41

package
v0.0.0-...-84bc6aa Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2018 License: BSD-3-Clause Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProgram

func NewProgram(vertexShaderSource, fragmentShaderSource string) (uint32, error)

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 NewFont

func NewFont(config *gltext.FontConfig) (f *Font, err error)

func (*Font) GetTextureHeight

func (f *Font) GetTextureHeight() float32

func (*Font) GetTextureWidth

func (f *Font) GetTextureWidth() float32

func (*Font) Release

func (f *Font) Release()

func (*Font) ResizeWindow

func (f *Font) ResizeWindow(width float32, height float32)

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

func NewText(f *Font, scaleMin, scaleMax float32) (t *Text)

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) AddScale

func (t *Text) AddScale(s float32) bool

AddScale returns true when a change occured

func (*Text) BeginFadeOut

func (t *Text) BeginFadeOut()

func (*Text) CharPosition

func (t *Text) CharPosition(index int) float64

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) Draw

func (t *Text) Draw()

func (*Text) GetBoundingBox

func (t *Text) GetBoundingBox() (X1, X2 gltext.Point)

func (*Text) GetLength

func (t *Text) GetLength() int

func (*Text) HasRune

func (t *Text) HasRune(r rune) bool

func (*Text) Height

func (t *Text) Height() float32

func (*Text) Hide

func (t *Text) Hide()

func (*Text) PrintCharSpacing

func (t *Text) PrintCharSpacing()

PrintCharSpacing is used for debugging

func (*Text) Release

func (t *Text) Release()

Release releases text resources.

func (*Text) SetColor

func (t *Text) SetColor(color mgl32.Vec3)

func (*Text) SetPosition

func (t *Text) SetPosition(v mgl32.Vec2)

SetPosition prepares variables passed to the shader as well as values used for bounding box calculations when clicking or hovering above text

func (*Text) SetScale

func (t *Text) SetScale(s float32) bool

SetScale returns true when a change occured

func (*Text) SetString

func (t *Text) SetString(fs string, argv ...interface{})

SetString performs creates new vbo and ebo objects as well as to perform all binding required for displaying text to screen

func (*Text) Show

func (t *Text) Show()

func (*Text) Width

func (t *Text) Width() float32

Jump to

Keyboard shortcuts

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