terminalCanvas

package module
v0.0.0-...-1468bbb Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

type Canvas struct {
	Ccolor Color
	// contains filtered or unexported fields
}

Canvas object, stores pixels and stuff

func NewCanvas

func NewCanvas(sx int16, sy int16) *Canvas

Creates new canvas with given size

func (*Canvas) Clear

func (c *Canvas) Clear()

Fills canvas with color stored in Ccolor

func (*Canvas) DrawLine

func (c *Canvas) DrawLine(a U16Vec2, b U16Vec2, col Color)

Draws line using Bresenham's line algorithm

func (*Canvas) DrawLineC

func (c *Canvas) DrawLineC(a I16Vec2, b I16Vec2, col Color)

DrawLine but {0, 0} is center of canvas

func (*Canvas) DrawLineF

func (c *Canvas) DrawLineF(a U16Frag, b U16Frag, f Material)

func (*Canvas) DrawLineFC

func (c *Canvas) DrawLineFC(a I16Frag, b I16Frag, f Material)

func (*Canvas) DrawLineI

func (c *Canvas) DrawLineI(a U16Vec2C, b U16Vec2C)

Draws line interpolating colors between

func (*Canvas) DrawLineIC

func (c *Canvas) DrawLineIC(a I16Vec2C, b I16Vec2C)

Same as DrawLineI but {0, 0} is canvas center

func (*Canvas) DrawTriangle

func (c *Canvas) DrawTriangle(p0 U16Vec2, p1 U16Vec2, p2 U16Vec2, col Color)

Draws filled triangle using scan line algorithm

func (*Canvas) DrawTriangleC

func (c *Canvas) DrawTriangleC(p0 I16Vec2, p1 I16Vec2, p2 I16Vec2, col Color)

Same as DrawTriangle but {0, 0} is center of canvas

func (*Canvas) DrawTriangleF

func (c *Canvas) DrawTriangleF(p0 U16Frag, p1 U16Frag, p2 U16Frag, f Material)

func (*Canvas) DrawTriangleFC

func (c *Canvas) DrawTriangleFC(p0 I16Frag, p1 I16Frag, p2 I16Frag, f Material)

func (*Canvas) DrawTriangleI

func (c *Canvas) DrawTriangleI(p0 U16Vec2C, p1 U16Vec2C, p2 U16Vec2C)

Draws filled triangle with colors interpolated between points

func (*Canvas) DrawTriangleIC

func (c *Canvas) DrawTriangleIC(p0 I16Vec2C, p1 I16Vec2C, p2 I16Vec2C)

Same as DrawTriangleI but {0, 0} is canvas center

func (*Canvas) Fill

func (c *Canvas) Fill(col Color)

Sets every pixel in canvas to given color

func (*Canvas) Print

func (c *Canvas) Print()

Prints canvas to terminal, using escape sequences for colors and `▄` for smaller pixels

func (*Canvas) PrintD

func (c *Canvas) PrintD(d *Canvas)

Prints only pixels that differ between canvas

func (*Canvas) PrintT

func (c *Canvas) PrintT()

Prints canvas to terminal, but if ignores pixels which have z equal math.MaxFloat32

func (*Canvas) PrintZ

func (c *Canvas) PrintZ()

Prints Z buffer, larger Z is brighter

func (*Canvas) SetPixel

func (c *Canvas) SetPixel(pos U16Vec2, col Color)

Sets pixel at given position to given color

func (*Canvas) SetPixelC

func (c *Canvas) SetPixelC(pos I16Vec2, col Color)

Sets pixel but {0, 0} is center of canvas

type Color

type Color struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

RGB one byte per channel

type F32Vec2

type F32Vec2 struct {
	X float32
	Y float32
}

type I16Frag

type I16Frag struct {
	Pos I16Vec2
	UV  F32Vec2
	Z   float32
}

type I16Vec2

type I16Vec2 struct {
	X int16
	Y int16
}

type I16Vec2C

type I16Vec2C struct {
	X int16
	Y int16
	C Color
}

type Material

type Material interface {
	GetColor(F32Vec2) Color
}

TODO: RENAME THAT PROBABLY

type MaterialFlat

type MaterialFlat struct{ C Color }

Material that will always return one color

func (MaterialFlat) GetColor

func (m MaterialFlat) GetColor(coord F32Vec2) Color

type MaterialImage

type MaterialImage struct{ Img image.Image }

func (MaterialImage) GetColor

func (M MaterialImage) GetColor(coord F32Vec2) Color

type MaterialUV

type MaterialUV struct{}

Material that will return UV as RGB

func (MaterialUV) GetColor

func (M MaterialUV) GetColor(coord F32Vec2) Color

type MaterialUVtest

type MaterialUVtest struct{}

Material to check if UV range is correct Green - correct (UV X and Y between 0.0 and 1.0) Red - wrong

func (MaterialUVtest) GetColor

func (M MaterialUVtest) GetColor(coord F32Vec2) Color

type Pixel

type Pixel struct {
	C Color
	Z float32
}

type U16Frag

type U16Frag struct {
	Pos U16Vec2
	UV  F32Vec2
	Z   float32
}

Fragment data

type U16Vec2

type U16Vec2 struct {
	X uint16
	Y uint16
}

type U16Vec2C

type U16Vec2C struct {
	X uint16
	Y uint16
	C Color
}

Jump to

Keyboard shortcuts

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