graphics

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: MPL-2.0 Imports: 7 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. If preserve is true the path is preserved after this operation.

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 PenColor

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

PenColor returns or sets the cursor pen color. pencolor(hexcolor) - sets the pen color to `hexcolor`. pencolor(r, g, b) - sets the pen color to `r,g,b` values - should be between 0 and 1, inclusive. Alpha will be set to 1 (fully opaque). pencolor(r, g, b, a) - sets the pen color to `r,g,b,a` values - should be between 0 and 1, inclusive.

func PenSize

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

PenSize returns or sets the pen line thickness. pensize() - returns the current pen line thickness. pensize(width) - sets the pen line thickness to `width`.

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 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. If preserve is true the path will be preserved.

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 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 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

func WorldCoords

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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