common

package
v0.0.0-...-4142f2f Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 3 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 Surface

type Surface interface {
	GetSurfaceSize() (int, int)
}

type Transform

type Transform struct {
	*wgpu.Device
	*wgpu.SwapChainDescriptor
	*wgpu.Buffer

	matrix.Matrix
	// contains filtered or unexported fields
}

func NewTransform

func NewTransform(surface Surface, device *wgpu.Device, scd *wgpu.SwapChainDescriptor, bufferLabel string) *Transform

func (*Transform) CreateBuffer

func (t *Transform) CreateBuffer()

func (*Transform) Destroy

func (t *Transform) Destroy()

func (*Transform) Move

func (t *Transform) Move(screenX, screenY float32)

func (*Transform) Resize

func (t *Transform) Resize(screenWidth, screenHeight float32)

func (*Transform) Rotate

func (t *Transform) Rotate(a float32) matrix.Matrix

func (*Transform) Scale

func (t *Transform) Scale(sx, sy float32) matrix.Matrix

func (*Transform) Update

func (t *Transform) Update()

type Vertex

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

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 (*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