graphic

package
v0.0.0-...-ce589c3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ANCHOR_LEFT = iota
	ANCHOR_RIGHT
	ANCHOR_HORIZONTAL_MiDDLE

	ANCHOR_TOP
	ANCHOR_BOTTOM
	ANCHOR_VERTICAL_MiDDLE
)

Type of anchor

Variables

View Source
var (
	ErrOutOfRange = errors.New("colorconv: inputs out of range")
)

Functions

func DetectPointRectCollision

func DetectPointRectCollision(point Vector2, rect Rect) bool

Detect if a point is inside the area of the rectangle.

func DetectRectCollision

func DetectRectCollision(rect1, rect2 Rect) bool

Detect if two rectangles overlap.

func DrawAdjustedTexture

func DrawAdjustedTexture(image rl.Texture2D)

func DrawTextureFromCenter

func DrawTextureFromCenter(texture rl.Texture2D, position Vector2, scale float32, tint color.RGBA)

func HSLToRGB

func HSLToRGB(h, s, l float64) (r, g, b uint8, err error)

Convertion from rgb color format to hsl color format.

func NewColorFromGradient

func NewColorFromGradient(offset float64, brightness float64) color.RGBA

Get the color from a color gradient, using its offset, ranging from 0 to 360.

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

type Circle struct {
	CenterPosition Vector2
	Radius         float32
}

object representing a circle

func NewCircle

func NewCircle(radius float32, x float32, y float32) Circle

Return a new circle.

func (*Circle) DetectCircleCollision

func (c *Circle) DetectCircleCollision(otherCircle Circle) bool

Detect if the two circles are overlapping.

func (*Circle) DetectMouseCollision

func (c *Circle) DetectMouseCollision() bool

Returns if the position of the mouse is inside the area of the circle.

func (*Circle) DetectPointCollision

func (c *Circle) DetectPointCollision(position Vector2) bool

Returns if a point is inside the area of the circle.

func (*Circle) DetectRectCollision

func (c *Circle) DetectRectCollision(rect Rect) bool

Returns if the circle and a given rectangle are overlapping.

func (*Circle) DrawCross

func (c *Circle) DrawCross(color color.RGBA)

draw the border line of the circle, and a cross inside

func (*Circle) DrawLines

func (c *Circle) DrawLines(color color.RGBA, LineAngle float32)

Draw the border line of the cirle. For some reason it also draw an additionnal line, whose angle can be changed by lineAngle (in degrees).

func (*Circle) Fill

func (c *Circle) Fill(color color.RGBA)

Draw a circle filled with a certain color, using the coordinates of the circle.

type Rect

type Rect struct {
	X      float32
	Y      float32
	Width  float32
	Height float32
}

A rect is a set of 4 numbers, which represent its position and its size.

func GetInnerHorizontalrect

func GetInnerHorizontalrect(sourceRect Rect, padding float32) Rect

GetInnerRect() but only horizontally.

func GetInnerRect

func GetInnerRect(sourceRect Rect, padding float32) Rect

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

func GetRectAdjustedToWindow(rectRatio float32) Rect

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 NewRect

func NewRect(x, y, width, height float32) Rect

Returns a new rect.

func NewRectFromCenter

func NewRectFromCenter(center, size Vector2) Rect

Returns a new rect, using vectors.

func NewRectFromVector

func NewRectFromVector(position, size Vector2) Rect

Returns a new rect, using vectors.

func (*Rect) DrawLines

func (r *Rect) DrawLines(color color.RGBA, roundness float32, thickness float32)

Draw the lines of the rectangle.

func (Rect) Fill

func (r Rect) Fill(color color.RGBA, roundness float32)

Draw a filled rectangle with a color using the coordinates of the rectangle.

func (Rect) GetCenter

func (r Rect) GetCenter() Vector2

Get the position of the center of the rect.

func (Rect) GetPosition

func (r Rect) GetPosition() Vector2

Get the position of the rect.

func (Rect) GetSize

func (r Rect) GetSize() Vector2

Get the size of the rect.

func (Rect) ScaleFromCenter

func (r Rect) ScaleFromCenter(scale float32) Rect

Scale the rectangle while its center remains the same.

func (Rect) WithPosition

func (r Rect) WithPosition(pos Vector2) Rect

Return the rect with position modified.

func (Rect) WithSize

func (r Rect) WithSize(size Vector2) Rect

Return the rect with size modified.

type Shader

type Shader struct {
	Shader rl.Shader
	// contains filtered or unexported fields
}

Object representing a shader program, make shader usage easier

func InitShader

func InitShader(vertexShaderPath, fragmentShaderPath string) *Shader

func (*Shader) Begin

func (s *Shader) Begin()

Begin custom shader drawing.

func (*Shader) End

func (s *Shader) End()

End custom shader drawing.

func (*Shader) SetValueFromUniformName

func (s *Shader) SetValueFromUniformName(uniformName string, value any, uniformType rl.ShaderUniformDataType)

type Vector2

type Vector2 struct {
	X float32
	Y float32
}

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 NewVector2

func NewVector2(x float32, y float32) Vector2

Returns a new Vector.

func NewVectorFromAngle

func NewVectorFromAngle(angle float64) Vector2

func (Vector2) Add

func (v Vector2) Add(otherVector Vector2) Vector2

return the addition of the two vectors.

func (Vector2) FlattenToLine

func (v Vector2) FlattenToLine(lineAngle float64) Vector2

Weird function I invented and can't explain. Probably something stupid.

func (Vector2) GetAngle

func (v Vector2) GetAngle() float64

Return the angle in radians between the vector and (1, 0)

func (Vector2) GetNorm

func (v Vector2) GetNorm() float32

Get the length of the Vector.

func (Vector2) Inverse

func (v Vector2) Inverse() Vector2

vector inverse -> no null vector

func (Vector2) Multiply

func (v Vector2) Multiply(otherVector Vector2) Vector2

Returns (v1.x*v2.x, v.1.y*v.2.y)

func (Vector2) NormalizeToRect

func (v Vector2) NormalizeToRect(originRect Rect, destRect Rect) Vector2

Normalize vector to originRect and multiply it by the size of the destRect

func (Vector2) NormalizeToVector

func (v Vector2) NormalizeToVector(otherVector Vector2) Vector2

Normalize vector to another. So (v1.x/v2.x, v.1.y/v.2.y)

func (Vector2) Rotate

func (v Vector2) Rotate(angle float64) Vector2

Rotate the Vector to a certain angle. Better way to do this smh (https://matthew-brett.github.io/teaching/rotation_2d.html).

func (Vector2) Scale

func (v Vector2) Scale(scale float32) Vector2

Scale the Vector by multiplying numbers by a certain value.

func (Vector2) ScaleToNorm

func (v Vector2) ScaleToNorm(norm float32) Vector2

Scale the vector to get the desired norm. Doesn't work with Vector (0, 0) (division by 0)

func (Vector2) Substract

func (v Vector2) Substract(otherVector Vector2) Vector2

Return the substraction of the two vectors.

func (Vector2) ToRaylibVector2

func (v Vector2) ToRaylibVector2() rl.Vector2

Conversion to raylib Vector2. Useless since it possible to do rl.Vector2() of the object Vector2

type Vector2i

type Vector2i struct {
	X, Y int
}

func NewVector2i

func NewVector2i(x, y int) Vector2i

func (Vector2i) ToVector2

func (v Vector2i) ToVector2() Vector2

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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