graphics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package graphics provides image processing and graphics capabilities for Nxlang

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanvasGetHeight

func CanvasGetHeight(args ...types.Object) types.Object

CanvasGetHeight returns canvas height

func CanvasGetWidth

func CanvasGetWidth(args ...types.Object) types.Object

CanvasGetWidth returns canvas width

func ClearFunc

func ClearFunc(args ...types.Object) types.Object

ClearFunc clears a canvas

func CreateCanvasFunc

func CreateCanvasFunc(args ...types.Object) types.Object

CreateCanvasFunc creates a new canvas

func DrawCircleFunc

func DrawCircleFunc(args ...types.Object) types.Object

DrawCircleFunc draws a circle on canvas

func DrawLineFunc

func DrawLineFunc(args ...types.Object) types.Object

DrawLineFunc draws a line on canvas

func DrawPointFunc

func DrawPointFunc(args ...types.Object) types.Object

DrawPointFunc draws a point on canvas

func DrawRectangleFunc

func DrawRectangleFunc(args ...types.Object) types.Object

DrawRectangleFunc draws a rectangle on canvas

func FillCircleFunc

func FillCircleFunc(args ...types.Object) types.Object

FillCircleFunc fills a circle on canvas

func FillRectangleFunc

func FillRectangleFunc(args ...types.Object) types.Object

FillRectangleFunc fills a rectangle on canvas

func GetPixelFunc

func GetPixelFunc(args ...types.Object) types.Object

GetPixelFunc gets pixel color from canvas

func LoadPNGFunc

func LoadPNGFunc(args ...types.Object) types.Object

LoadPNGFunc loads a PNG image into a canvas

func SavePNGFunc

func SavePNGFunc(args ...types.Object) types.Object

SavePNGFunc saves canvas to PNG file

Types

type Canvas

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

Canvas represents a drawing canvas for graphics operations

func NewCanvas

func NewCanvas(width, height int) *Canvas

NewCanvas creates a new canvas with specified dimensions

func (*Canvas) Clear

func (c *Canvas) Clear(r, g, b, a uint8)

Clear clears the canvas with the specified color

func (*Canvas) DrawCircle

func (c *Canvas) DrawCircle(cx, cy, radius int, r, g, b, a uint8)

DrawCircle draws a circle outline using midpoint circle algorithm

func (*Canvas) DrawLine

func (c *Canvas) DrawLine(x0, y0, x1, y1 int, r, g, b, a uint8)

DrawLine draws a line using Bresenham's algorithm

func (*Canvas) DrawPoint

func (c *Canvas) DrawPoint(x, y int, r, g, b, a uint8)

DrawPoint draws a single point on the canvas

func (*Canvas) DrawRectangle

func (c *Canvas) DrawRectangle(x, y, w, h int, r, g, b, a uint8)

DrawRectangle draws a rectangle outline

func (*Canvas) Equals

func (c *Canvas) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Canvas) FillCircle

func (c *Canvas) FillCircle(cx, cy, radius int, r, g, b, a uint8)

FillCircle draws a filled circle

func (*Canvas) FillRectangle

func (c *Canvas) FillRectangle(x, y, w, h int, r, g, b, a uint8)

FillRectangle draws a filled rectangle

func (*Canvas) FromBytes

func (c *Canvas) FromBytes(data []byte, width, height int) types.Object

FromBytes loads image data from raw RGBA bytes

func (*Canvas) GetPixel

func (c *Canvas) GetPixel(x, y int) (uint8, uint8, uint8, uint8)

GetPixel returns the color of a pixel

func (*Canvas) Height

func (c *Canvas) Height() int

Height returns the canvas height

func (*Canvas) LoadFromPNG

func (c *Canvas) LoadFromPNG(filename string) types.Object

LoadFromPNG loads an image from a PNG file

func (*Canvas) SaveToPNG

func (c *Canvas) SaveToPNG(filename string) types.Object

SaveToPNG saves the canvas to a PNG file

func (*Canvas) ToBytes

func (c *Canvas) ToBytes() []byte

ToBytes returns the raw RGBA bytes of the canvas

func (*Canvas) ToStr

func (c *Canvas) ToStr() string

ToStr implements types.Object interface

func (*Canvas) TypeCode

func (c *Canvas) TypeCode() uint8

TypeCode implements types.Object interface

func (*Canvas) TypeName

func (c *Canvas) TypeName() string

TypeName implements types.Object interface

func (*Canvas) Width

func (c *Canvas) Width() int

Width returns the canvas width

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image represents a loaded image

func LoadImage

func LoadImage(filename string) (*Image, error)

LoadImage loads an image from a file (supports PNG, JPEG, GIF)

func (*Image) Equals

func (i *Image) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Image) Height

func (i *Image) Height() int

Height returns the image height

func (*Image) ToCanvas

func (i *Image) ToCanvas() *Canvas

ToCanvas converts the image to a canvas

func (*Image) ToStr

func (i *Image) ToStr() string

ToStr implements types.Object interface

func (*Image) TypeCode

func (i *Image) TypeCode() uint8

TypeCode implements types.Object interface

func (*Image) TypeName

func (i *Image) TypeName() string

TypeName implements types.Object interface

func (*Image) Width

func (i *Image) Width() int

Width returns the image width

Jump to

Keyboard shortcuts

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