gx

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Graphics related stuff

Implements badly some image drawing methods. Mainly used for debugging for now.

Example code:

canvas := gx.NewCanvas(300, 300)
canvas.Clear(gx.BLACK)
canvas.DrawCircle(100,100,50,10,gx.WHITE)
canvas.DrawDisk(150,150,30,gx.RED)
canvas.ToPNG("test.png")

Index

Constants

This section is empty.

Variables

View Source
var (
	BLACK  = color.NRGBA{R: 0, G: 0, B: 0, A: 255}
	WHITE  = color.NRGBA{R: 255, G: 255, B: 255, A: 255}
	RED    = color.NRGBA{R: 255, G: 0, B: 0, A: 255}
	GREEN  = color.NRGBA{R: 0, G: 255, B: 0, A: 255}
	BLUE   = color.NRGBA{R: 0, G: 0, B: 255, A: 255}
	ORANGE = color.NRGBA{R: 255, G: 165, B: 0, A: 255}

	SKYBLUE_PALE   = color.NRGBA{204, 255, 255, 255}
	SKYBLUE_OPAQUE = color.NRGBA{128, 204, 204, 255}
	SKYBLUE        = color.NRGBA{178, 255, 255, 255}
)

Functions

func Abs

func Abs(x int) int

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

Types

type Canvas

type Canvas struct {
	Img *image.NRGBA
	W   int
	H   int
}

func NewCanvas

func NewCanvas(width, height int) Canvas

func (Canvas) Clear

func (c Canvas) Clear(color Color)

func (Canvas) DrawCircle

func (c Canvas) DrawCircle(cx, cy, radius, border float32, color Color)

func (Canvas) DrawDisk

func (c Canvas) DrawDisk(cx, cy, radius float32, color Color)

func (Canvas) DrawLine

func (c Canvas) DrawLine(start, end Vec2i, color Color)

func (Canvas) DrawPoint

func (c Canvas) DrawPoint(x, y int, color Color)

func (Canvas) DrawRect

func (c Canvas) DrawRect(lowerLeft, upperRight Vec2i, color Color)

func (Canvas) ToPNG

func (c Canvas) ToPNG(file_path string)

type Color

type Color = color.NRGBA

func HeatRamp

func HeatRamp(index uint8) Color

func ParaRamp

func ParaRamp(index uint8) Color

index 0 to 255 gives a whatever map cheap remake of https://www.kennethmoreland.com/color-advice/ ordered on wish

func RainbowRamp

func RainbowRamp(index uint8) Color

index 0 to 255 gives a rainbow

func ToxicRamp

func ToxicRamp(index uint8) Color

type Vec2i

type Vec2i struct {
	X, Y int
}

Jump to

Keyboard shortcuts

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