Documentation
¶
Index ¶
- Constants
- Variables
- func DetectPointRectCollision(point Vector2, rect Rect) bool
- func DetectRectCollision(rect1, rect2 Rect) bool
- func DrawAdjustedTexture(image rl.Texture2D)
- func DrawTextureFromCenter(texture rl.Texture2D, position Vector2, scale float32, tint color.RGBA)
- func HSLToRGB(h, s, l float64) (r, g, b uint8, err error)
- func NewColorFromGradient(offset float64, brightness float64) color.RGBA
- type Anchor
- type Circle
- func (c *Circle) DetectCircleCollision(otherCircle Circle) bool
- func (c *Circle) DetectMouseCollision() bool
- func (c *Circle) DetectPointCollision(position Vector2) bool
- func (c *Circle) DetectRectCollision(rect Rect) bool
- func (c *Circle) DrawCross(color color.RGBA)
- func (c *Circle) DrawLines(color color.RGBA, LineAngle float32)
- func (c *Circle) Fill(color color.RGBA)
- type Rect
- func GetInnerHorizontalrect(sourceRect Rect, padding float32) Rect
- func GetInnerRect(sourceRect Rect, padding float32) Rect
- func GetMouseRect() Rect
- func GetRectAdjustedToWindow(rectRatio float32) Rect
- func GetWindowRect() Rect
- func NewRect(x, y, width, height float32) Rect
- func NewRectFromCenter(center, size Vector2) Rect
- func NewRectFromVector(position, size Vector2) Rect
- func (r *Rect) DrawLines(color color.RGBA, roundness float32, thickness float32)
- func (r Rect) Fill(color color.RGBA, roundness float32)
- func (r Rect) GetCenter() Vector2
- func (r Rect) GetPosition() Vector2
- func (r Rect) GetSize() Vector2
- func (r Rect) ScaleFromCenter(scale float32) Rect
- func (r Rect) WithPosition(pos Vector2) Rect
- func (r Rect) WithSize(size Vector2) Rect
- type Shader
- type Vector2
- func (v Vector2) Add(otherVector Vector2) Vector2
- func (v Vector2) FlattenToLine(lineAngle float64) Vector2
- func (v Vector2) GetAngle() float64
- func (v Vector2) GetNorm() float32
- func (v Vector2) Inverse() Vector2
- func (v Vector2) Multiply(otherVector Vector2) Vector2
- func (v Vector2) NormalizeToRect(originRect Rect, destRect Rect) Vector2
- func (v Vector2) NormalizeToVector(otherVector Vector2) Vector2
- func (v Vector2) Rotate(angle float64) Vector2
- func (v Vector2) Scale(scale float32) Vector2
- func (v Vector2) ScaleToNorm(norm float32) Vector2
- func (v Vector2) Substract(otherVector Vector2) Vector2
- func (v Vector2) ToRaylibVector2() rl.Vector2
- type Vector2i
Constants ¶
const ( ANCHOR_LEFT = iota ANCHOR_RIGHT ANCHOR_HORIZONTAL_MiDDLE ANCHOR_TOP ANCHOR_BOTTOM ANCHOR_VERTICAL_MiDDLE )
Type of anchor
Variables ¶
var (
ErrOutOfRange = errors.New("colorconv: inputs out of range")
)
Functions ¶
func DetectPointRectCollision ¶
Detect if a point is inside the area of the rectangle.
func DetectRectCollision ¶
Detect if two rectangles overlap.
func DrawAdjustedTexture ¶
func DrawTextureFromCenter ¶
Types ¶
type Anchor ¶
type Anchor struct {
X, Y int
}
Object representing a set of two anchor: one horizontal and vertical. Those anchor types are defined as enum. if X or Y are mixed, the resulting transormation will ignore the anchor.
type Circle ¶
object representing a circle
func (*Circle) DetectCircleCollision ¶
Detect if the two circles are overlapping.
func (*Circle) DetectMouseCollision ¶
Returns if the position of the mouse is inside the area of the circle.
func (*Circle) DetectPointCollision ¶
Returns if a point is inside the area of the circle.
func (*Circle) DetectRectCollision ¶
Returns if the circle and a given rectangle are overlapping.
type Rect ¶
A rect is a set of 4 numbers, which represent its position and its size.
func GetInnerHorizontalrect ¶
GetInnerRect() but only horizontally.
func GetInnerRect ¶
Get the rect inside another, with a certain padding.
func GetMouseRect ¶
func GetMouseRect() Rect
Get the rect representing the mouse, with position (mX, mY) and size (1, 1).
func GetRectAdjustedToWindow ¶
Get new rect that keeps the same ratio and has the same size that the windows
func GetWindowRect ¶
func GetWindowRect() Rect
Get the rect representing the window, with position (0, 0) and size (wWidth, wHeight).
func NewRectFromCenter ¶
Returns a new rect, using vectors.
func NewRectFromVector ¶
Returns a new rect, using vectors.
func (Rect) ScaleFromCenter ¶
Scale the rectangle while its center remains the same.
func (Rect) WithPosition ¶
Return the rect with position modified.
type Shader ¶
Object representing a shader program, make shader usage easier
func InitShader ¶
func (*Shader) SetValueFromUniformName ¶
func (s *Shader) SetValueFromUniformName(uniformName string, value any, uniformType rl.ShaderUniformDataType)
type Vector2 ¶
A Vector2 is a set of 2 numbers, often representing a 2d coordinate/movement.
func GetRectCoordinatesWithAnchor ¶
func GetRectCoordinatesWithAnchor(position Vector2, size Vector2, anchor Anchor, bounds Rect) Vector2
Get the position of a rect given its set of anchors. Position and size : define the position and size of the rectangle. bounds : the rectangle which define the bounds where the rect is contained. Often the rect of the window
func NewVectorFromAngle ¶
func (Vector2) FlattenToLine ¶
Weird function I invented and can't explain. Probably something stupid.
func (Vector2) NormalizeToRect ¶
Normalize vector to originRect and multiply it by the size of the destRect
func (Vector2) NormalizeToVector ¶
Normalize vector to another. So (v1.x/v2.x, v.1.y/v.2.y)
func (Vector2) Rotate ¶
Rotate the Vector to a certain angle. Better way to do this smh (https://matthew-brett.github.io/teaching/rotation_2d.html).
func (Vector2) ScaleToNorm ¶
Scale the vector to get the desired norm. Doesn't work with Vector (0, 0) (division by 0)
func (Vector2) ToRaylibVector2 ¶
Conversion to raylib Vector2. Useless since it possible to do rl.Vector2() of the object Vector2