primitives

package
v0.0.0-...-8789af9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateCenter

func CalculateCenter(v []Vertex) [2]float32

func CreateVertexBuffer

func CreateVertexBuffer(device *wgpu.Device, vertices []Vertex, width float32, height float32) *wgpu.Buffer

func ScreenToNDC

func ScreenToNDC(x, y, screenWidth, screenHeight float32) [3]float32

ScreenToNDC transforms screen space coordinates to NDC. screenWidth and screenHeight are the dimensions of the screen.

Types

type Vertex

type Vertex struct {
	Position  [3]float32 // x, y, z coordinates
	Color     [4]float32 // RGBA color
	TexCoords [2]float32
}

Vertex represents a single vertex in the shape.

func ConvertVerticesToNDC

func ConvertVerticesToNDC(vertices []Vertex, screenWidth, screenHeight float32) []Vertex

convertVerticesToNDC converts an array of vertices from screen space to NDC.

func MakeCircle

func MakeCircle(cx, cy int, radius float32, c color.Color, segments int) []Vertex

MakeCircle creates a new Circle renderable and adds it to the RenderQueue. It returns a reference to the created Circle.

func MakeLine

func MakeLine(x1, y1, x2, y2 int, width float32, c color.Color) []Vertex

MakeLine creates a new Line renderable and adds it to the RenderQueue. It returns a reference to the created Line.

func MakePolygon

func MakePolygon(cx, cy int, width float32, c color.Color, sides int) []Vertex

MakePolygon creates a new Polygon renderable and adds it to the RenderQueue. It returns a reference to the created Polygon.

func MakePolygonFromVertices

func MakePolygonFromVertices(cx, cy int, width float32, vertices []graphics.Vertex) []Vertex

func MakeRectangle

func MakeRectangle(x, y, width, height int, c color.Color) []Vertex

MakeRectangle creates a new Rectangle renderable and adds it to the RenderQueue. It returns a reference to the created Rectangle.

func MakeTriangle

func MakeTriangle(x1, y1, x2, y2, x3, y3 int, c color.Color) []Vertex

MakeTriangle creates a new Triangle renderable and adds it to the RenderQueue. It returns a reference to the created Triangle.

func (*Vertex) SetColor

func (v *Vertex) SetColor(c color.Color)

Jump to

Keyboard shortcuts

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