graphics

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arc

func Arc(env *object.Environment, args ...object.Object) object.Object

Arc draws a circular arc centered at `x, y` with a radius of `r`. The path starts at `angle1`, ends at `angle2`, and travels in the direction given by anticlockwise.

func ArcTo

func ArcTo(env *object.Environment, args ...object.Object) object.Object

ArcTo adds a circular arc to the current sub-path, using the given control points and radius. The arc is automatically connected to the path's latest point with a straight line, if necessary for the specified parameters.

func BeginPath

func BeginPath(env *object.Environment, args ...object.Object) object.Object

BeginPath starts a new path.

func Circle

func Circle(env *object.Environment, args ...object.Object) object.Object

Circle draws a circle centered at [x, y] coordinates and with the radius `r`.

func Clear

func Clear(env *object.Environment, args ...object.Object) object.Object

Clear fills the entire image with the current color. Clear all drawings.

func ClosePath

func ClosePath(env *object.Environment, args ...object.Object) object.Object

ClosePath adds a line segment from the current point to the beginning of the current subpath. If there is no current point, this is a no-op.

func Dashes

func Dashes(env *object.Environment, args ...object.Object) object.Object

Dashes sets the current dash pattern to use. Call with zero arguments to disable dashes. The values specify the lengths of each dash, with alternating on and off lengths.

func Ellipse

func Ellipse(env *object.Environment, args ...object.Object) object.Object

Ellipse draws an ellipse centered at [x, y] coordinates and with the radii `rx` and `ry`.

func Fill

func Fill(env *object.Environment, args ...object.Object) object.Object

Fill fills the current path with the current color. Open subpaths are implicity closed. The path is cleared after this operation.

func FillAndStroke added in v0.5.0

func FillAndStroke(env *object.Environment, args ...object.Object) object.Object

FillAndStroke first fills the current path and than strokes it

func FillColor added in v0.5.0

func FillColor(env *object.Environment, args ...object.Object) object.Object

FillColor returns or sets the fill color. fillColor(hexcolor) - sets the fill color to `hexcolor`. fillColor(r, g, b) - sets the fill color to `r,g,b` values. fillColor(r, g, b, a) - sets the fill color to `r,g,b,a` values.

func FontSize added in v0.5.0

func FontSize(env *object.Environment, args ...object.Object) object.Object

FontSize sets the size of the current font face. `fontSize()` returns the current font height `fontSize(size)` sets the current font height

func GetCurrentX

func GetCurrentX(env *object.Environment, args ...object.Object) object.Object

GetCurrentX returns the current X position if there is a current point.

func GetCurrentY

func GetCurrentY(env *object.Environment, args ...object.Object) object.Object

GetCurrentY returns the current Y position if there is a current point.

func Height

func Height(env *object.Environment, args ...object.Object) object.Object

Height returns the image height

func Identity

func Identity(env *object.Environment, args ...object.Object) object.Object

Identity resets the current transformation matrix to the identity matrix. This results in no translating, scaling, rotating, or shearing.

func ImageAnchored

func ImageAnchored(env *object.Environment, args ...object.Object) object.Object

ImageAnchored draws the specified image at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the image. Use ax=0.5, ay=0.5 to center the image at the specified point.

func Line

func Line(env *object.Environment, args ...object.Object) object.Object

Line draws a line from point (x1, y1) to point (x2, y2)

func LineTo

func LineTo(env *object.Environment, args ...object.Object) object.Object

LineTo adds a line segment to the current path starting at the current point. If there is no current point, it is equivalent to MoveTo(x, y)

func LoadPNG

func LoadPNG(env *object.Environment, args ...object.Object) object.Object

LoadPNG loads a PNG image file

func MoveTo

func MoveTo(env *object.Environment, args ...object.Object) object.Object

MoveTo starts a new subpath within the current path starting at the specified point.

func Point

func Point(env *object.Environment, args ...object.Object) object.Object

Point draws a point at specified coordinates.

func Pop

func Pop(env *object.Environment, args ...object.Object) object.Object

Pop restores the last saved context state from the stack.

func Push

func Push(env *object.Environment, args ...object.Object) object.Object

Push saves the current state of the context by pushin it onto a stack. These can be nested.

func Quad

func Quad(env *object.Environment, args ...object.Object) object.Object

Quad draws a quadrilateral, a four sided polygon.

func QuadraticCurveTo

func QuadraticCurveTo(env *object.Environment, args ...object.Object) object.Object

QuadraticCurveTo adds a quadratic Bézier curve to the current sub-path. It requires two points: the first one is a control point and the second one is the end point. The starting point is the latest point in the current path, which can be changed using `moveTo()` before creating the quadratic Bézier curve.

func Rect

func Rect(env *object.Environment, args ...object.Object) object.Object

Rect draws a (w x h) rectangle with upper left corner located at (x, y). rect(x, y, w, h, [r]) if radius `r` is specified, the rectangle will have rounded corners.

func RotateAbout

func RotateAbout(env *object.Environment, args ...object.Object) object.Object

RotateAbout updates the current matrix with a anticlockwise rotation. rotate(angle) - rotation occurs about the origin. rotate(angle, x, y) - rotation occurs about the specified point. Angle is specified in radians.

func RouteTo

func RouteTo(env *object.Environment, args ...object.Object) object.Object

RouteTo adds a line segment to the current path starting at the current point. If there is no current point, it is equivalent to MoveTo(x, y)

func ScaleAbout

func ScaleAbout(env *object.Environment, args ...object.Object) object.Object

ScaleAbout updates the current matrix with a scaling factor. scale(sx, sy) - scaling occurs about the origin. scale(sx, sy, x, y) - scaling occurs about the specified point.

func Size

func Size(env *object.Environment, args ...object.Object) object.Object

Size sets the image size. `size(d)` creates a squared image where width and height are equals to `d`. `size(w, h) creates an image where width is equals to `w` and height to `h`.

func Snapshot

func Snapshot(env *object.Environment, args ...object.Object) object.Object

Snapshot encodes as PNG the image with the current drawings and saves the image on the filesystem. If file name is omitted it will be autogenerated adn the PNG saved in the .g2d file folder.

func Star added in v0.5.0

func Star(env *object.Environment, args ...object.Object) object.Object

Star draws a star shape. star(cx, cy, n, or, ir) cx, cy center of the star, n is the number of spikes, or and ir the outer and inner radius.

func Stroke

func Stroke(env *object.Environment, args ...object.Object) object.Object

Stroke strokes the current path with the current color and line width the path is cleared after this operation.

func StrokeColor added in v0.5.0

func StrokeColor(env *object.Environment, args ...object.Object) object.Object

StrokeColor returns or sets the stroke color. strokeColor(hexcolor) - sets the stroke color to `hexcolor`. strokeColor(r, g, b) - sets the stroke color to `r,g,b` values. strokeColor(r, g, b, a) - sets the stroke color to `r,g,b,a` values.

func StrokeWeight added in v0.5.0

func StrokeWeight(env *object.Environment, args ...object.Object) object.Object

StrokeWeight returns or sets the stroke line thickness. strokeWeight() - returns the current stroke line thickness. strokeWeight(width) - sets the stroke thickness to `width`.

func Text

func Text(env *object.Environment, args ...object.Object) object.Object

Text draws the specified text at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the text. Use ax=0.5, ay=0.5 to center the text at the specified point.

func TextWidth

func TextWidth(env *object.Environment, args ...object.Object) object.Object

TextWidth returns the rendered width of the specified text given the current font face.

func Transform added in v0.5.0

func Transform(env *object.Environment, args ...object.Object) object.Object

Transform multiplies the specified point by the current matrix, returning a transformed position.

func Translate

func Translate(env *object.Environment, args ...object.Object) object.Object

Translate updates the current matrix with a translation.

func Triangle

func Triangle(env *object.Environment, args ...object.Object) object.Object

Triangle draws a triangle. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point.

func Viewport added in v0.5.0

func Viewport(env *object.Environment, args ...object.Object) object.Object

Viewport sets up user-defined coordinate system. This performs a screen reset, all drawings are cleared.

func Width

func Width(env *object.Environment, args ...object.Object) object.Object

Width returns the image width `width(img)` - if the img is not specified the

Types

This section is empty.

Jump to

Keyboard shortcuts

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