geometry

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: Apache-2.0 Imports: 3 Imported by: 12

Documentation

Overview

Package geometry handle components with geometry concepts

Index

Constants

This section is empty.

Variables

View Source
var Get = gets{

	Point: func(e *goecs.Entity) Point {
		return e.Get(TYPE.Point).(Point)
	},
}

Get a geometry component

View Source
var TYPE = types{
	Point: reflect.TypeOf(Point{}),
}

TYPE hold the reflect.Type for our geometry components

Functions

This section is empty.

Types

type Point

type Point struct {
	X float32 // The x coordinate
	Y float32 // The y coordinate
}

Point represent a x/y coordinate

func (*Point) Clamp

func (pos *Point) Clamp(min Point, max Point)

Clamp a geometry.Point to min max value

type Rect

type Rect struct {
	From Point // From is the origin of the area
	Size Size  // Size is the size of the area
}

Rect is a rectangular area

func (Rect) Collides added in v0.1.7

func (r Rect) Collides(other Rect) bool

Collides return if a given geometry.Rect collides with this geometry.Rect

func (Rect) IsPointInRect

func (r Rect) IsPointInRect(point Point) bool

IsPointInRect return if a given geometry.Point is inside the geometry.Rect

type Scale

type Scale struct {
	Point Point   // Point is the scale per point
	Min   float32 // Min is the minimum scale between X and Y
	Max   float32 // Max is the maximum scale between X and Y
}

Scale is the current scale between two Size

type Size

type Size struct {
	Width  float32 // Width is vertical length of the size
	Height float32 // Height is the horizontal length of the size
}

Size represent the size of an object

func (Size) CalculateScale

func (s Size) CalculateScale(other Size) Scale

CalculateScale calculates the Scale between to Size

func (Size) Scale

func (s Size) Scale(factor float32) Size

Scale return a geometry.Size scaled by a factor

Jump to

Keyboard shortcuts

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