primatives

package
v0.0.0-...-963f1c7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Nothing shape = iota
	Point
	Line
	Circle
	Rectangle
	Polygon
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Circ

type Circ struct {
	Primative
	// contains filtered or unexported fields
}

func (Circ) Collides

func (c Circ) Collides(other Collider) (bool, Collision)

func (Circ) Move

func (c Circ) Move(v m.Vector) Primative

func (Circ) Raster

func (c Circ) Raster() *imdraw.IMDraw

func (Circ) String

func (c Circ) String() string

type Collider

type Collider interface {
	Shape
	Collides(other Collider) (bool, Collision)
}

func NewCollider

func NewCollider(shape Shape) Collider

type Collision

type Collision struct {
	*collision2d.Response
}

func Collides

func Collides(s Collider, other Collider) (bool, Collision)

func TestCircleCircle

func TestCircleCircle(circleA Circ, circleB Circ) (bool, Collision)

func TestCircleLine

func TestCircleLine(circle Circ, line Lin) (bool, Collision)

func TestCirclePolygon

func TestCirclePolygon(circle Circ, polygon Poly) (bool, Collision)

func TestCircleRect

func TestCircleRect(circle Circ, rect Rect) (bool, Collision)

func TestDotCircle

func TestDotCircle(dot Dot, circle Circ) (bool, Collision)

func TestDotDot

func TestDotDot(dotA Dot, dotB Dot) (bool, Collision)

func TestDotLine

func TestDotLine(dot Dot, line Lin) (bool, Collision)

func TestDotPolygon

func TestDotPolygon(dot Dot, poly Poly) (bool, Collision)

func TestDotRect

func TestDotRect(dot Dot, rect Rect) (bool, Collision)

func TestLineLine

func TestLineLine(lin1, lin2 Lin) (bool, Collision)

func TestPolygonLine

func TestPolygonLine(poly Poly, lin Lin) (bool, Collision)

func TestPolygonPolygon

func TestPolygonPolygon(polyA Poly, polyB Poly) (bool, Collision)

func TestRectLine

func TestRectLine(rect Rect, lin Lin) (bool, Collision)

func TestRectPolygon

func TestRectPolygon(rect Rect, polygon Poly) (bool, Collision)

func TestRectRect

func TestRectRect(rectA Rect, rectB Rect) (bool, Collision)

func (Collision) Reverse

func (c Collision) Reverse() Collision

type ConcreteShape

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

func NewShape

func NewShape(kind shape) *ConcreteShape

func (*ConcreteShape) Type

func (cs *ConcreteShape) Type() shape

type Dot

type Dot struct {
	*m.Vector
	Primative
}

func NewDot

func NewDot(x, y float64) Dot

func (Dot) Collides

func (d Dot) Collides(other Collider) (bool, Collision)

func (Dot) Move

func (d Dot) Move(v m.Vector) Primative

func (Dot) Raster

func (d Dot) Raster() *imdraw.IMDraw

func (*Dot) String

func (d *Dot) String() string

type Lin

type Lin struct {
	Primative
	// contains filtered or unexported fields
}

func NewLine

func NewLine(start m.Vector, end m.Vector) Lin

func (Lin) Collides

func (l Lin) Collides(other Collider) (bool, Collision)

func (Lin) Move

func (l Lin) Move(v m.Vector) Primative

func (Lin) Raster

func (l Lin) Raster() *imdraw.IMDraw

func (Lin) String

func (l Lin) String() string

type Poly

type Poly struct {
	Primative
	// contains filtered or unexported fields
}

func NewPolygon

func NewPolygon(points ...m.Vector) Poly

func NewPolygonFromLines

func NewPolygonFromLines(lines []line) Poly

func (Poly) Center

func (p Poly) Center() m.Vector

func (Poly) Collides

func (p Poly) Collides(other Collider) (bool, Collision)

func (Poly) Move

func (p Poly) Move(v m.Vector) Primative

func (Poly) Raster

func (p Poly) Raster() *imdraw.IMDraw

type Primative

type Primative interface {
	Collider
	graphics.Rasterable
	Move(v m.Vector) Primative
}

func NewCircle

func NewCircle(radius float64, location m.Vector) Primative

func NewPrimative

func NewPrimative(collider Collider) Primative

type Rect

type Rect struct {
	Primative
	// contains filtered or unexported fields
}

func NewRectangle

func NewRectangle(min m.Vector, max m.Vector) Rect

func (Rect) Collides

func (r Rect) Collides(other Collider) (bool, Collision)

func (Rect) Move

func (r Rect) Move(v m.Vector) Primative

func (Rect) Raster

func (r Rect) Raster() *imdraw.IMDraw

func (Rect) ToPolygon

func (r Rect) ToPolygon() Poly

type Shape

type Shape interface {
	Type() shape
}

Jump to

Keyboard shortcuts

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