giocanvas

package module
v0.0.0-...-919e581 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT, Unlicense Imports: 19 Imported by: 0

README

giocanvas -- a canvas API built on top of gio

(Note: this code is under development and the API may change)

canvas API

Documentation

Overview

Package giocanvas is a 2D canvas API built on gio

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorLookup

func ColorLookup(s string) color.RGBA

ColorLookup returns a color.RGBA corresponding to the named color or "rgb(r)", "rgb(r,b)", "rgb(r,g,b), "rgb(r,g,b,a)" string. On error, return black.

func EndTransform

func EndTransform(stack op.StackOp)

EndTransform ends a transformation

func MapRange

func MapRange(value, low1, high1, low2, high2 float64) float64

MapRange maps a value between low1 and high1, return the corresponding value between low2 and high2

Types

type Canvas

type Canvas struct {
	Width, Height float32
	TextColor     color.RGBA
	Context       layout.Context
}

Canvas defines the Gio canvas

func NewCanvas

func NewCanvas(width, height float32, e system.FrameEvent) *Canvas

NewCanvas initializes a Canvas

func (*Canvas) AbsArc

func (c *Canvas) AbsArc(x, y, radius float32, start, end float64, fillcolor color.RGBA)

AbsArc makes circulr arc centered at (x, y), through angles start and end; the angles are measured in radians and increase clockwise N.B: derived from the clipLoader function in widget/material/loader.go

func (*Canvas) AbsCenterImage

func (c *Canvas) AbsCenterImage(name string, x, y float32, w, h int, scale float32)

AbsCenterImage places a named image centered at (x, y) using the specified dimensions (w, h), and hen scaled

func (*Canvas) AbsCenterRect

func (c *Canvas) AbsCenterRect(x, y, w, h float32, fillcolor color.RGBA)

AbsCenterRect makes a filled rectangle centered at (x, y), with dimensions (w,h)

func (*Canvas) AbsCircle

func (c *Canvas) AbsCircle(x, y, radius float32, fillcolor color.RGBA)

AbsCircle makes a circle centered at (x, y), radius r

func (*Canvas) AbsCubicBezier

func (c *Canvas) AbsCubicBezier(x, y, cx1, cy1, cx2, cy2, ex, ey, size float32, fillcolor color.RGBA)

AbsCubicBezier makes a cubic bezier curve

func (*Canvas) AbsEllipse

func (c *Canvas) AbsEllipse(x, y, w, h float32, fillcolor color.RGBA)

AbsEllipse makes a ellipse centered at (x, y) radii (w, h)

func (*Canvas) AbsGrid

func (c *Canvas) AbsGrid(width, height, size, interval float32, fillcolor color.RGBA)

AbsGrid uses horizontal and vertical lines to make a grid

func (*Canvas) AbsHLine

func (c *Canvas) AbsHLine(x, y, w, h float32, fillcolor color.RGBA)

AbsHLine makes a horizontal line starting at (x, y), with dimensions (w, h)

func (*Canvas) AbsImg

func (c *Canvas) AbsImg(im image.Image, x, y float32, w, h int, scale float32)

AbsImg places a image.Image centered at (x, y) using the specified dimensions (w, h), and then scaled

func (*Canvas) AbsLine

func (c *Canvas) AbsLine(x0, y0, x1, y1, size float32, fillcolor color.RGBA)

AbsLine makes a line from (x0,y0) to (x1, y1) using absolute coordinates

func (*Canvas) AbsPolygon

func (c *Canvas) AbsPolygon(x, y []float32, fillcolor color.RGBA)

AbsPolygon makes a closed, filled polygon with vertices in x and y

func (*Canvas) AbsQuadBezier

func (c *Canvas) AbsQuadBezier(x, y, cx, cy, ex, ey, size float32, fillcolor color.RGBA)

AbsQuadBezier makes a quadratic curve starting at (x, y), control point at (cx, cy), end point (ex, ey)

func (*Canvas) AbsRect

func (c *Canvas) AbsRect(x, y, w, h float32, fillcolor color.RGBA)

AbsRect makes a filled Rectangle; left corner at (x, y), with dimensions (w,h)

func (*Canvas) AbsRotate

func (c *Canvas) AbsRotate(x, y, angle float32) op.StackOp

AbsRotate rotates around (x,y) using angle (radians)

func (*Canvas) AbsScale

func (c *Canvas) AbsScale(x, y, factor float32) op.StackOp

AbsScale scales by factor at (x,y)

func (*Canvas) AbsShear

func (c *Canvas) AbsShear(x, y, ax, ay float32) op.StackOp

AbsShear shears at (x,y) using angle ax and ay

func (*Canvas) AbsText

func (c *Canvas) AbsText(x, y, size float32, s string, fillcolor color.RGBA)

AbsText places text at (x,y)

func (*Canvas) AbsTextEnd

func (c *Canvas) AbsTextEnd(x, y, size float32, s string, fillcolor color.RGBA)

AbsTextEnd places text aligned to the end

func (*Canvas) AbsTextMid

func (c *Canvas) AbsTextMid(x, y, size float32, s string, fillcolor color.RGBA)

AbsTextMid places text centered at (x,y)

func (*Canvas) AbsTextWrap

func (c *Canvas) AbsTextWrap(x, y, size, width float32, s string, fillcolor color.RGBA)

AbsTextWrap places and wraps text at (x, y), wrapped at width

func (*Canvas) AbsTranslate

func (c *Canvas) AbsTranslate(x, y float32) op.StackOp

AbsTranslate moves current location by (x,y)

func (*Canvas) AbsVLine

func (c *Canvas) AbsVLine(x, y, w, h float32, fillcolor color.RGBA)

AbsVLine makes a vertical line beginning at (x,y) with dimension (w, h)

func (*Canvas) Arc

func (c *Canvas) Arc(x, y, r float32, a1, a2 float64, fillcolor color.RGBA)

Arc makes a filled arc, using percentage-based measures center is (x, y) the arc begins at angle a1, and ends at a2, with radius r. The arc is filled with the specified color.

func (*Canvas) ArcLine

func (c *Canvas) ArcLine(x, y, r float32, a1, a2 float64, size float32, fillcolor color.RGBA)

ArcLine makes a stroked arc, using percentage-based measures center is (x, y), the arc begins at angle a1, and ends at a2, with radius r. The arc is stroked with the specified stroke size and color

func (*Canvas) Background

func (c *Canvas) Background(fillcolor color.RGBA)

Background makes a filled rectangle covering the whole canvas

func (*Canvas) CText

func (c *Canvas) CText(x, y, size float32, s string, fillcolor color.RGBA)

CText - alternative name for TextMid

func (*Canvas) CenterImage

func (c *Canvas) CenterImage(name string, x, y float32, w, h int, scale float32)

CenterImage places a scaled image centered at (x,y), using percentage coordinates and scales

func (*Canvas) CenterRect

func (c *Canvas) CenterRect(x, y, w, h float32, fillcolor color.RGBA)

CenterRect makes a rectangle using percentage-based measures with center at (x,y), sized at (w,h)

func (*Canvas) Circle

func (c *Canvas) Circle(x, y, r float32, fillcolor color.RGBA)

Circle makes a filled circle, using percentage-based measures center is (x,y), radius r

func (*Canvas) Coord

func (c *Canvas) Coord(x, y, size float32, s string, fillcolor color.RGBA)

Coord shows the specified coordinate, using percentage-based coordinates the (x, y) label is above the point, with a label below

func (*Canvas) CornerRect

func (c *Canvas) CornerRect(x, y, w, h float32, fillcolor color.RGBA)

CornerRect makes a rectangle using percentage-based measures upper left corner at (x,y), with sized at (w,h)

func (*Canvas) CubeCurve

func (c *Canvas) CubeCurve(x, y, cx1, cy1, cx2, cy2, ex, ey float32, fillcolor color.RGBA)

CubeCurve makes a cubic Bezier curve, using percentage-based measures starting at (x, y), control points at (cx1, cy1), (cx2, cy2), end point (ex, ey)

func (*Canvas) Curve

func (c *Canvas) Curve(x, y, cx, cy, ex, ey float32, fillcolor color.RGBA)

Curve makes a quadric Bezier curve, using percentage-based measures starting at (x, y), control point at (cx, cy), end point (ex, ey)

func (*Canvas) EText

func (c *Canvas) EText(x, y, size float32, s string, fillcolor color.RGBA)

EText - alternative name for TextEnd

func (*Canvas) Ellipse

func (c *Canvas) Ellipse(x, y, w, h float32, fillcolor color.RGBA)

Ellipse makes a filled circle, using percentage-based measures center is (x,y), radii (w, h)

func (*Canvas) Grid

func (c *Canvas) Grid(x, y, w, h, size, interval float32, linecolor color.RGBA)

Grid makes vertical and horizontal grid lines, percentage-based coordinates

func (*Canvas) HLine

func (c *Canvas) HLine(x, y, linewidth, size float32, linecolor color.RGBA)

HLine makes a horizontal line starting at (x, y), with dimensions (w, h) the line begin at (x,y) and extends to the left by linewidth

func (*Canvas) Image

func (c *Canvas) Image(name string, x, y float32, w, h int, scale float32)

Image places a scaled image centered at (x,y), reading from a named file, using percetage coordinates and scales

func (*Canvas) Img

func (c *Canvas) Img(im image.Image, x, y float32, w, h int, scale float32)

Img places a scaled image centered at (x, y), data from image.Image using percentage coordinates and scales

func (*Canvas) Line

func (c *Canvas) Line(x0, y0, x1, y1, size float32, strokecolor color.RGBA)

Line makes a stroked line using percentage-based measures from (x0, y0) to (x1, y1), stroke width size

func (*Canvas) Polar

func (c *Canvas) Polar(cx, cy, r, theta float32) (float32, float32)

Polar returns the Cartesian coordinates (x, y) from polar coordinates with compensation for canvas aspect ratio center at (cx, cy), radius r, and angle theta (radians)

func (*Canvas) PolarDegrees

func (c *Canvas) PolarDegrees(cx, cy, r, theta float32) (float32, float32)

PolarDegrees returns the Cartesian coordinates (x, y) from polar coordinates with compensation for canvas aspect ratio center at (cx, cy), radius r, and angle theta (degrees)

func (*Canvas) Polygon

func (c *Canvas) Polygon(x, y []float32, fillcolor color.RGBA)

Polygon makes a filled polygon using percentage-based measures vertices in x and y,

func (*Canvas) QuadCurve

func (c *Canvas) QuadCurve(x, y, cx, cy, ex, ey float32, fillcolor color.RGBA)

QuadCurve makes a quadric Bezier curve, using percentage-based measures starting at (x, y), control point at (cx, cy), end point (ex, ey)

func (*Canvas) Rect

func (c *Canvas) Rect(x, y, w, h float32, fillcolor color.RGBA)

Rect makes a rectangle using percentage-based measures upper left corner at (x,y), with size at (w,h)

func (*Canvas) Rotate

func (c *Canvas) Rotate(x, y, angle float32) op.StackOp

Rotate around (x,y) by angle (radians) using percentage-based measures

func (*Canvas) Scale

func (c *Canvas) Scale(x, y, factor float32) op.StackOp

Scale centered at (x,y) by factor using percentage-based measures

func (*Canvas) Shear

func (c *Canvas) Shear(x, y, ax, ay float32) op.StackOp

Shear the object centered at (x,y) using x-angle and y-angle (radians) using percentage-based measures

func (*Canvas) Square

func (c *Canvas) Square(x, y, w float32, fillcolor color.RGBA)

Square makes a square shape, using percentage based measures centered at (x, y), sides are w. Accounts for screen aspect

func (*Canvas) Text

func (c *Canvas) Text(x, y, size float32, s string, fillcolor color.RGBA)

Text places text using percentage-based measures left at x, baseline at y, at the specified size and color

func (*Canvas) TextEnd

func (c *Canvas) TextEnd(x, y, size float32, s string, fillcolor color.RGBA)

TextEnd places text using percentage-based measures x is the end of the string, baseline at y, using specified size and color

func (*Canvas) TextMid

func (c *Canvas) TextMid(x, y, size float32, s string, fillcolor color.RGBA)

TextMid places text using percentage-based measures text is centered at x, baseline y, using specied size and color

func (*Canvas) TextWrap

func (c *Canvas) TextWrap(x, y, size, width float32, s string, fillcolor color.RGBA)

TextWrap places and wraps text using percentage-based measures text begins at (x,y), baseline y, and wraps at width, using specied size and color

func (*Canvas) Translate

func (c *Canvas) Translate(x, y float32) op.StackOp

Translate moves current location by (x,y) using percentage-based measures

func (*Canvas) VLine

func (c *Canvas) VLine(x, y, lineheight, size float32, linecolor color.RGBA)

VLine makes a vertical line beginning at (x,y) with dimension (w, h) the line begins at (x,y) and moves upward by linewidth

Directories

Path Synopsis
confetti -- random shapes
confetti -- random shapes
Package chart makes charts using the gio canvas
Package chart makes charts using the gio canvas
gchart
gchart -- command line chart using giocanvas chart package
gchart -- command line chart using giocanvas chart package
concentric circles
concentric circles
confetti -- random shapes
confetti -- random shapes
eclipse illustrates the eclipse
eclipse illustrates the eclipse
flowers demonstrated transforms with "flowers"
flowers demonstrated transforms with "flowers"
hello is the giocanvas hello, world
hello is the giocanvas hello, world
lines tests line drawing
lines tests line drawing
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
play demos the giocanvas API
play demos the giocanvas API
rl makes random lines
rl makes random lines
tile makes a tiling visual
tile makes a tiling visual
transform tests affine transforms
transform tests affine transforms

Jump to

Keyboard shortcuts

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