g

package
v0.1.2-0...-b65944d Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT, Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pi  = math.Pi
	Tau = Pi * 2
	Phi = math.Phi
)

Variables

View Source
var (
	Red   = Color{0xFF, 0x00, 0x00, 0xFF}
	Green = Color{0x00, 0xFF, 0x00, 0xFF}
	Blue  = Color{0x00, 0x00, 0xFF, 0xFF}
)
View Source
var Zero2 = V2{}

Functions

func Abs

func Abs(a float32) float32

func ApplyDeadZone

func ApplyDeadZone(v float32, deadZone float32) float32

func Atan

func Atan(v float32) float32

func Atan2

func Atan2(y, x float32) float32

func Clamp

func Clamp(a, low, high float32) float32

Clamp clamps value to low..high

func Clamp01

func Clamp01(a float32) float32

Clamp01 clamps value to 0..1

func ClampUnit

func ClampUnit(a float32) float32

ClampUnit clamps value to -1..1 TODO: what's the conventional name for this?

func Cos

func Cos(v float32) float32

func DegToRad

func DegToRad(deg float32) float32

func EnforceInside

func EnforceInside(pos, vel *V2, bounds Rect, dampening float32)

func Lerp

func Lerp(a, b, p float32) float32

func LerpClamp

func LerpClamp(a, b, p float32) float32

func Max

func Max(a, b float32) float32

func Min

func Min(a, b float32) float32

func MinMax

func MinMax(a, b float32) (float32, float32)

func Mod

func Mod(x, y float32) float32

func Pow

func Pow(v, e float32) float32

func RadToDeg

func RadToDeg(rad float32) float32

func RandomBetween

func RandomBetween(a, b float32) float32

func Sat8

func Sat8(v float32) uint8

func Sin

func Sin(v float32) float32

func Sqr

func Sqr(v float32) float32

Sqr returns the square of v

func Sqrt

func Sqrt(v float32) float32

Sqrt returns the square root of v

Types

type Color

type Color struct{ R, G, B, A uint8 }

func ColorFloat

func ColorFloat(r, g, b, a float32) Color

func ColorHSL

func ColorHSL(h, s, l float32) Color

func ColorHSLA

func ColorHSLA(h, s, l, a float32) Color

func ColorHex

func ColorHex(hex uint32) Color

func LerpColor

func LerpColor(a, b Color, p float32) Color

func (Color) Float

func (c Color) Float() (r, g, b, a float32)

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint8)

func (Color) WithAlpha

func (c Color) WithAlpha(a uint8) Color

type Font

type Font struct {
	Texture      *Texture
	Glyphs       string
	GlyphsPerRow int
	GlyphSize    V2
}

func (*Font) Draw

func (font *Font) Draw(text string, position V2, glyphHeight float32)

func (*Font) DrawColored

func (font *Font) DrawColored(text string, position V2, glyphHeight float32, color Color)

func (*Font) DrawLines

func (font *Font) DrawLines(lines []string, position V2, glyphHeight, lineHeight float32)

func (*Font) Width

func (font *Font) Width(text string, glyphHeight float32) float32

type Radian

type Radian float32

type Rect

type Rect struct{ Min, Max V2 }

func NewCircleRect

func NewCircleRect(r float32) Rect

func NewRect

func NewRect(w, h float32) Rect

func (Rect) Contains

func (r Rect) Contains(p V2) bool

func (Rect) Offset

func (r Rect) Offset(delta V2) Rect

func (Rect) ScaleInv

func (r Rect) ScaleInv(v V2) Rect

func (Rect) Size

func (r Rect) Size() V2

type Texture

type Texture struct {
	Path string

	Repeat bool
	RGBA   *image.RGBA
	Size   V2
	ID     uint32
	// contains filtered or unexported fields
}

func (*Texture) Delete

func (tex *Texture) Delete()

func (*Texture) Draw

func (tex *Texture) Draw(dst Rect)

func (*Texture) DrawColored

func (tex *Texture) DrawColored(dst Rect, color Color)

func (*Texture) DrawSub

func (tex *Texture) DrawSub(dst Rect, src Rect)

func (*Texture) DrawSubColored

func (tex *Texture) DrawSubColored(dst Rect, src Rect, color Color)

func (*Texture) Line

func (tex *Texture) Line(from, to V2, width float32)

func (*Texture) LineColored

func (tex *Texture) LineColored(from, to V2, width float32, color Color)

func (*Texture) Reload

func (tex *Texture) Reload()

func (*Texture) Upload

func (tex *Texture) Upload()

type V2

type V2 struct{ X, Y float32 }

func ClampLength

func ClampLength(a V2, maxsize float32) V2

func RandomV2

func RandomV2(r Rect) V2

func RandomV2Circle

func RandomV2Circle(radius float32) V2

func (V2) Add

func (a V2) Add(b V2) V2

Add adds two vectors and returns the result

func (V2) AddScale

func (a V2) AddScale(b V2, s float32) V2

func (V2) Angle

func (a V2) Angle() float32

func (V2) Cross

func (a V2) Cross(b V2) float32

Cross product of a and b

func (V2) Distance

func (a V2) Distance(b V2) float32

Distance returns the distance to vector b

func (V2) Distance2

func (a V2) Distance2(b V2) float32

Distance2 returns the squared distance to vector b

func (V2) Dot

func (a V2) Dot(b V2) float32

Dot calculates the dot product

func (V2) Length

func (a V2) Length() float32

Length returns the length of the vector

func (V2) Length2

func (a V2) Length2() float32

Length2 returns the squared length of the vector

func (V2) NearZero

func (a V2) NearZero() bool

func (V2) Negate

func (a V2) Negate() V2

func (V2) Normalize

func (a V2) Normalize() V2

func (V2) Rotate

func (a V2) Rotate(angle float32) V2

func (V2) Rotate180

func (a V2) Rotate180() V2

func (V2) Rotate90

func (a V2) Rotate90() V2

func (V2) Rotate90c

func (a V2) Rotate90c() V2

func (V2) Scale

func (a V2) Scale(s float32) V2

Scale scales each component and returns the result

func (V2) Sub

func (a V2) Sub(b V2) V2

Sub subtracts two vectors and returns the result

func (V2) XY

func (a V2) XY() (x, y float32)

XY returns both components

func (V2) XYZ

func (a V2) XYZ() (x, y, z float32)

Jump to

Keyboard shortcuts

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