gfx

package
v0.0.0-...-fb24458 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gfx contains drawing utilities for a draw.Image destination.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context provides primitive drawing operations on a draw.Image. All operations use the drawing color set by SetColor().

func NewContext

func NewContext(dst draw.Image) *Context

NewContext returns a new Context initialized with black drawing color.

func (*Context) Clear

func (ctx *Context) Clear()

Clear clears the destination image.

func (*Context) DrawLine

func (ctx *Context) DrawLine(x0, y0, x1, y1 int)

DrawLine draws a line. The Bresenham's line algorithm is used which is detailed here: https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm

func (*Context) DrawString

func (ctx *Context) DrawString(s string, x, y int)

DrawString draws a string. The y coordinate is the bottom line of the text.

func (*Context) FillCircle

func (ctx *Context) FillCircle(x0, y0, rad int)

FillCircle draws a filled circle. The Midpoint circle algorithm is used which is detailed here: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm

func (*Context) HLine

func (ctx *Context) HLine(x1, x2, y int)

HLine draws a horizontal line.

func (*Context) Point

func (ctx *Context) Point(x, y int)

Point draws a point.

func (*Context) Rectangle

func (ctx *Context) Rectangle(x1, y1, width, height int)

Rectangle draws a rectangle.

func (*Context) SetColor

func (ctx *Context) SetColor(col color.Color)

SetColor sets the drawing color.

func (*Context) SetColorRGBA

func (ctx *Context) SetColorRGBA(r, g, b, a byte)

SetColorRGBA sets the drawing color.

func (*Context) VLine

func (ctx *Context) VLine(y1, y2, x int)

VLine draws a vertical line.

Jump to

Keyboard shortcuts

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