Documentation ¶
Index ¶
- Variables
- type Circle
- func (self *Circle) Area() float32
- func (self *Circle) Circumference() float32
- func (self *Circle) Contains(x, y float32) bool
- func (self *Circle) ContainsC(c *Circle) bool
- func (self *Circle) ContainsV(point *Vector2) bool
- func (self *Circle) Overlaps(c *Circle) bool
- func (self *Circle) Set(x, y, radius float32)
- func (self *Circle) SetC(circle *Circle)
- func (self *Circle) SetPosition(position *Vector2)
- func (self *Circle) SetRadius(radius float32)
- func (self *Circle) SetV(position *Vector2, radius float32)
- func (self *Circle) SetV2(center, edge *Vector2)
- func (self *Circle) String() string
- type Ellipse
- func (self *Ellipse) Area() float32
- func (self *Ellipse) Circumference() float32
- func (self *Ellipse) Contains(x, y float32) bool
- func (self *Ellipse) ContainsV(point *Vector2) bool
- func (self *Ellipse) Set(x, y, w, h float32)
- func (self *Ellipse) SetCircle(circle *Circle)
- func (self *Ellipse) SetCopy(ellipse *Ellipse)
- func (self *Ellipse) SetPosition(x, y float32) *Ellipse
- func (self *Ellipse) SetPositionV(position *Vector2) *Ellipse
- func (self *Ellipse) SetSize(w, h float32) *Ellipse
- func (self *Ellipse) SetV2(position, size *Vector2)
- type Polygon
- func (self *Polygon) Area() float32
- func (self *Polygon) Contains(x, y float32) bool
- func (self *Polygon) Dirty()
- func (self *Polygon) GetBoundingRectangle() *Rectangle
- func (self *Polygon) GetTransformedVertices() []float32
- func (self *Polygon) GetVertices() []float32
- func (self *Polygon) Rotate(degrees float32)
- func (self *Polygon) Scale(amount float32)
- func (self *Polygon) SetPosition(x, y float32)
- func (self *Polygon) SetRotation(degrees float32)
- func (self *Polygon) SetScale(scaleX, scaleY float32)
- func (self *Polygon) SetVertices(vertices []float32)
- func (self *Polygon) Translate(x, y float32)
- type Polyline
- func (self *Polyline) CalculateLength()
- func (self *Polyline) CalculateScaledLength()
- func (self *Polyline) Dirty()
- func (self *Polyline) GetLength() float32
- func (self *Polyline) GetOriginX() float32
- func (self *Polyline) GetOriginY() float32
- func (self *Polyline) GetRotation() float32
- func (self *Polyline) GetScaleX() float32
- func (self *Polyline) GetScaleY() float32
- func (self *Polyline) GetScaledLength() float32
- func (self *Polyline) GetTransformedVertices() []float32
- func (self *Polyline) GetVertices() []float32
- func (self *Polyline) GetX() float32
- func (self *Polyline) GetY() float32
- func (self *Polyline) Rotate(degrees float32)
- func (self *Polyline) Scale(amount float32)
- func (self *Polyline) SetPosition(x, y float32)
- func (self *Polyline) SetRotation(degrees float32)
- func (self *Polyline) SetScale(scaleX, scaleY float32)
- func (self *Polyline) SetVertices(vertices []float32)
- func (self *Polyline) Translate(x, y float32)
- type Rectangle
- func (self *Rectangle) Area() float32
- func (self *Rectangle) Contains(x, y float32) bool
- func (self *Rectangle) ContainsRect(r *Rectangle) bool
- func (self *Rectangle) ContainsV(point *Vector2) bool
- func (self *Rectangle) Equals(rect *Rectangle) bool
- func (self *Rectangle) FitInside(rect *Rectangle) *Rectangle
- func (self *Rectangle) FitOutside(rect *Rectangle) *Rectangle
- func (self *Rectangle) GetAspectRatio() float32
- func (self *Rectangle) GetCenter(vector *Vector2) *Vector2
- func (self *Rectangle) GetH() float32
- func (self *Rectangle) GetPosition(position *Vector2) *Vector2
- func (self *Rectangle) GetSize(size *Vector2) *Vector2
- func (self *Rectangle) GetW() float32
- func (self *Rectangle) GetX() float32
- func (self *Rectangle) GetY() float32
- func (self *Rectangle) HashCode() int
- func (self *Rectangle) Merge(x, y float32) *Rectangle
- func (self *Rectangle) MergeRect(rect *Rectangle) *Rectangle
- func (self *Rectangle) MergeVec(vec *Vector2) *Rectangle
- func (self *Rectangle) MergeVecs(vecs []*Vector2) *Rectangle
- func (self *Rectangle) Overlaps(r *Rectangle) bool
- func (self *Rectangle) Perimeter() float32
- func (self *Rectangle) Set(x, y, w, h float32) *Rectangle
- func (self *Rectangle) SetCenter(x, y float32) *Rectangle
- func (self *Rectangle) SetCenterV(position *Vector2) *Rectangle
- func (self *Rectangle) SetH(h float32) *Rectangle
- func (self *Rectangle) SetPosition(x, y float32) *Rectangle
- func (self *Rectangle) SetPositionV(position *Vector2) *Rectangle
- func (self *Rectangle) SetR(rect *Rectangle) *Rectangle
- func (self *Rectangle) SetSize(width, height float32) *Rectangle
- func (self *Rectangle) SetSizeXY(sizeXY float32) *Rectangle
- func (self *Rectangle) SetW(w float32) *Rectangle
- func (self *Rectangle) SetX(x float32) *Rectangle
- func (self *Rectangle) SetY(y float32) *Rectangle
- func (self *Rectangle) String() string
- type Shape2D
Constants ¶
This section is empty.
Variables ¶
var ( // Static temporary rectangle. Use with care! Use only when sure other code will not also use self. Tmp = NewRectangleEmpty() // Static temporary rectangle. Use with care! Use only when sure other code will not also use self. Tmp2 = NewRectangleEmpty() )
Functions ¶
This section is empty.
Types ¶
type Circle ¶
type Circle struct {
X, Y, Radius float32
}
A convenient 2D circle class. Implements Shape2D
func NewCircleC ¶
Copy constructor circle The circle to construct a copy of.
func NewCircleEmpty ¶
func NewCircleEmpty() *Circle
Constructs a new circle with all values set to zero
func NewCircleV ¶
Constructs a new circle using a given {@link Vector2} that contains the desired X and Y coordinates, and a given radius. position The position {@link Vector2}. radius The radius
func NewCircleV2 ¶
func NewCircleV2(center, edge *Vector2) *Circle
Creates a new {@link Circle} in terms of its center and a point on its edge. center The center of the new circle edge Any point on the edge of the given circle
func (*Circle) Circumference ¶
The circumference of this circle (as 2 * {@link MathUtils#PI2}) * {@code radius}
func (*Circle) Contains ¶
Checks whether or not this circle contains a given point. x X coordinate y Y coordinate true if this circle contains the given point.
func (*Circle) ContainsC ¶
c the other {@link Circle} whether this circle contains the other circle.
func (*Circle) ContainsV ¶
Checks whether or not this circle contains a given point. point The {@link Vector2} that contains the point coordinates. true if this circle contains this point; false otherwise.
func (*Circle) Overlaps ¶
// c the other {@link Circle} // whether this circle overlaps the other circle.
func (*Circle) SetC ¶
Sets a new location and radius for this circle, based upon another circle. circle The circle to copy the position and radius of.
func (*Circle) SetPosition ¶
func (self *Circle) SetPosition(position *Vector2)
Sets the x and y-coordinates of circle center from vector position The position vector
type Ellipse ¶
type Ellipse struct {
X, Y, W, H float32
}
A convenient 2D ellipse class, based on the circle class Implements Shape2D
func NewEllipse ¶
Constructs a new ellipse param x X coordinate param y Y coordinate param width Width in pixels param height Height in pixels
func NewEllipseCircle ¶
Constructs a new {@link Ellipse} from the position and radius of a {@link Circle} (since circles are special cases of ellipses). param circle The circle to take the values of
func NewEllipseCopy ¶
Copy constructor param ellipse Ellipse to construct a copy of.
func NewEllipseEmpty ¶
func NewEllipseEmpty() *Ellipse
Construct a new ellipse with all values set to zero
func NewEllipseV ¶
Costructs a new ellipse param position Position vector param width Width in pixels param height Height in pixels
func NewEllipseV2 ¶
func NewEllipseV2(position, size *Vector2) *Ellipse
func (*Ellipse) Area ¶
return The area of this {@link Ellipse} as {@link MathUtils#PI} * {@link Ellipse#width} * {@link Ellipse#height}
func (*Ellipse) Circumference ¶
Approximates the circumference of this {@link Ellipse}. Oddly enough, the circumference of an ellipse is actually difficult to compute exactly. return The Ramanujan approximation to the circumference of an ellipse if one dimension is at least three times longer than the other, else the simpler approximation
func (*Ellipse) Contains ¶
Checks whether or not this ellipse contains the given point. param x X coordinate param y Y coordinate return true if this ellipse contains the given point; false otherwise.
func (*Ellipse) ContainsV ¶
Checks whether or not this ellipse contains the given point. param point Position vector return true if this ellipse contains the given point; false otherwise.
func (*Ellipse) Set ¶
Sets a new position and size for this ellipse. param x X coordinate param y Y coordinate param width Width in pixels param height Height in pixels
func (*Ellipse) SetCopy ¶
Sets a new position and size for this ellipse based upon another ellipse. param ellipse The ellipse to copy the position and size of.
func (*Ellipse) SetPosition ¶
Sets the x and y-coordinates of ellipse center param x The x-coordinate param y The y-coordinate return this ellipse for chaining
func (*Ellipse) SetPositionV ¶
Sets the x and y-coordinates of ellipse center from a {@link Vector2}. param position The position vector return this ellipse for chaining
type Polygon ¶
type Polygon struct {
X, Y float32
OriginX, OriginY float32
Rotation float32
ScaleX, ScaleY float32
// contains filtered or unexported fields
}
Encapsulates a 2D polygon defined by it's vertices relative to an origin point (default of 0, 0).
func NewPolygon ¶
Constructs a new polygon from a float array of parts of vertex points. @param vertices an array where every even element represents the horizontal part of a point, and the following element
representing the vertical part
panics if less than 6 elements, representing 3 points, are provided
func (*Polygon) Dirty ¶
func (self *Polygon) Dirty()
Sets the polygon's world vertices to be recalculated when calling {@link #getTransformedVertices() getTransformedVertices}.
func (*Polygon) GetBoundingRectangle ¶
Returns an axis-aligned bounding box of this polygon. Note the returned Rectangle is cached in this polygon, and will be reused if this Polygon is changed. @return this polygon's bounding box {@link Rectangle}
func (*Polygon) GetTransformedVertices ¶
Calculates and returns the vertices of the polygon after scaling, rotation, and positional translations have been applied, as they are position within the world.
@return vertices scaled, rotated, and offset by the polygon position.
func (*Polygon) GetVertices ¶
Returns the polygon's local vertices without scaling or rotation and without being offset by the polygon position.
func (*Polygon) SetPosition ¶
Sets the polygon's position within the world.
func (*Polygon) SetRotation ¶
Sets the polygon to be rotated by the supplied degrees.
func (*Polygon) SetVertices ¶
Sets the polygon's local vertices relative to the origin point, without any scaling, rotating or translations being applied.
@param vertices float array where every even element represents the x-coordinate of a vertex, and the proceeding element representing the y-coordinate. panics if less than 6 elements, representing 3 points, are provided
type Polyline ¶
type Polyline struct {
// contains filtered or unexported fields
}
func NewPolygonLine ¶
func NewPolygonLineEmpty ¶
func NewPolygonLineEmpty() *Polyline
func (*Polyline) CalculateLength ¶
func (self *Polyline) CalculateLength()
func (*Polyline) CalculateScaledLength ¶
func (self *Polyline) CalculateScaledLength()
func (*Polyline) GetOriginX ¶
func (*Polyline) GetOriginY ¶
func (*Polyline) GetRotation ¶
func (*Polyline) GetScaledLength ¶
Returns the euclidean length of the polyline
func (*Polyline) GetTransformedVertices ¶
Returns vertices scaled, rotated, and offset by the polyline position.
func (*Polyline) GetVertices ¶
Returns vertices without scaling or rotation and without being offset by the polyline position.
func (*Polyline) SetPosition ¶
Sets the polyline's position within the world.
func (*Polyline) SetRotation ¶
Sets the polyline to be rotated by the supplied degrees.
func (*Polyline) SetVertices ¶
Sets the polyline's local vertices relative to the origin point, without any scaling, rotating or translations being applied.
@param vertices float array where every even element represents the x-coordinate of a vertex, and the proceeding element representing the y-coordinate. panics if less than 6 elements, representing 3 points, are provided
type Rectangle ¶
type Rectangle struct {
X, Y, W, H float32
}
Encapsulates a 2D rectangle defined by its corner point in the bottom left and its extents in x (width) and y (height). Implements Shape2D
func NewRectangle ¶
Constructs a new rectangle with the given corner point in the bottom left and dimensions.
func NewRectangleCopy ¶
Constructs a rectangle based on the given rectangle
func NewRectangleEmpty ¶
func NewRectangleEmpty() *Rectangle
Constructs a new rectangle with all values set to zero
func (*Rectangle) ContainsRect ¶
returns whether the other rectangle is contained in this rectangle.
func (*Rectangle) FitInside ¶
Fits this rectangle into another rectangle while maintaining aspect ratio. This scales and centers the rectangle to the other rectangle (e.g. Scaling a texture within a arbitrary cell without squeezing) param rect the other rectangle to fit this rectangle inside returns this rectangle for chaining
func (*Rectangle) FitOutside ¶
Fits this rectangle around another rectangle while maintaining aspect ratio. This scales and centers the rectangle to the other rectangle (e.g. Having a camera translate and scale to show a given area) param rect the other rectangle to fit this rectangle around returns this rectangle for chaining
func (*Rectangle) GetAspectRatio ¶
Calculates the aspect ratio ( width / height ) of this rectangle returns the aspect ratio of this rectangle. Returns Float.NaN if height is 0 to avoid ArithmeticException
func (*Rectangle) GetCenter ¶
func (self *Rectangle) GetCenter(vector *Vector2) *Vector2
Calculates the center of the rectangle. Results are located in the given Vector2 returns the given vector with results stored inside
func (*Rectangle) GetPosition ¶
func (self *Rectangle) GetPosition(position *Vector2) *Vector2
return the Vector2 with coordinates of this rectangle
func (*Rectangle) GetSize ¶
func (self *Rectangle) GetSize(size *Vector2) *Vector2
returns the Vector2 with size of this rectangle
func (*Rectangle) Merge ¶
Merges this rectangle with a point. The rectangle should not have negative width or negative height.
func (*Rectangle) MergeRect ¶
Merges this rectangle with the other rectangle. The rectangle should not have negative width or negative height.
func (*Rectangle) MergeVec ¶
Merges this rectangle with a point. The rectangle should not have negative width or negative height.
func (*Rectangle) MergeVecs ¶
Merges this rectangle with a list of points. The rectangle should not have negative width or negative height.
func (*Rectangle) SetCenter ¶
Moves this rectangle so that its center point is located at a given position returns this for chaining
func (*Rectangle) SetCenterV ¶
Moves this rectangle so that its center point is located at a given position returns this for chaining
func (*Rectangle) SetPosition ¶
Sets the x and y-coordinates of the bottom left corner
func (*Rectangle) SetPositionV ¶
Sets the x and y-coordinates of the bottom left corner from vector
func (*Rectangle) SetX ¶
Sets the x-coordinate of the bottom left corner param x The x-coordinate returns this rectangle for chaining