imagerender

package
v0.0.0-...-1effa6f Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: AGPL-3.0, AGPL-3.0-only Imports: 15 Imported by: 0

Documentation

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 represents an image rendering context.

func NewContext

func NewContext(width, height int) *Context

NewContext creates a new image.RGBA with the specified width and height and prepares a context for rendering onto that image.

func NewContextForImage

func NewContextForImage(im image.Image) *Context

NewContextForImage copies the specified image into a new image.RGBA and prepares a context for rendering onto that image.

func NewContextForRGBA

func NewContextForRGBA(im *image.RGBA) *Context

NewContextForRGBA prepares a context for rendering onto the specified image. No copy is made.

func (*Context) AsMask

func (dc *Context) AsMask() *image.Alpha

AsMask returns an *image.Alpha representing the alpha channel of this context. This can be useful for advanced clipping operations where you first render the mask geometry and then use it as a mask.

func (*Context) Clear

func (dc *Context) Clear()

Clear fills the entire image with the current color.

func (*Context) ClearPath

func (dc *Context) ClearPath()

ClearPath clears the current path. There is no current point after this operation.

func (*Context) Clip

func (dc *Context) Clip()

Clip updates the clipping region by intersecting the current clipping region with the current path as it would be filled by dc.Fill(). The path is cleared after this operation.

func (*Context) ClipPreserve

func (dc *Context) ClipPreserve()

ClipPreserve updates the clipping region by intersecting the current clipping region with the current path as it would be filled by dc.Fill(). The path is preserved after this operation.

func (*Context) ClosePath

func (dc *Context) ClosePath()

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 (*Context) CubicTo

func (dc *Context) CubicTo(x1, y1, x2, y2, x3, y3 float64)

CubicTo adds a cubic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1). Because freetype/raster does not support cubic beziers, this is emulated with many small line segments.

func (*Context) DrawArc

func (dc *Context) DrawArc(x, y, r, angle1, angle2 float64)

DrawArc draws an arc described by r, angle1, angle2 at position x,y.

func (*Context) DrawCircle

func (dc *Context) DrawCircle(x, y, r float64)

DrawCircle draws a circle of radius r at position x,y.

func (*Context) DrawEllipse

func (dc *Context) DrawEllipse(x, y, rx, ry float64)

DrawEllipse draws an ellipse of size rx,ry at position x,y.

func (*Context) DrawEllipticalArc

func (dc *Context) DrawEllipticalArc(x, y, rx, ry, angle1, angle2 float64)

DrawEllipticalArc draws an elliptical arc described by r, angle1, angle2 at position x,y.

func (*Context) DrawImage

func (dc *Context) DrawImage(im image.Image, x, y int)

DrawImage draws the specified image at the specified point.

func (*Context) DrawImageAnchored

func (dc *Context) DrawImageAnchored(im image.Image, x, y int, ax, ay float64)

DrawImageAnchored 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 (*Context) DrawLine

func (dc *Context) DrawLine(x1, y1, x2, y2 float64)

DrawLine draws the line described by points x1,y1 and x2,y2.

func (*Context) DrawPoint

func (dc *Context) DrawPoint(x, y, r float64)

DrawPoint is like DrawCircle but ensures that a circle of the specified size is drawn regardless of the current transformation matrix. The position is still transformed, but not the shape of the point.

func (*Context) DrawRectangle

func (dc *Context) DrawRectangle(x, y, w, h float64)

DrawRectangle draws a rectangle of size w,h at position x,y.

func (*Context) DrawRoundedRectangle

func (dc *Context) DrawRoundedRectangle(x, y, w, h, r float64)

DrawRoundedRectangle draws a rounded rectangle of size w,h at position x,y.

func (*Context) DrawString

func (dc *Context) DrawString(s string, x, y float64)

DrawString draws the specified text at the specified point.

func (*Context) DrawStringAnchored

func (dc *Context) DrawStringAnchored(s string, x, y, ax, ay float64)

DrawStringAnchored 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 (*Context) Fill

func (dc *Context) Fill()

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

func (*Context) FillPreserve

func (dc *Context) FillPreserve()

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

func (*Context) Height

func (dc *Context) Height() int

Height returns the height of the image in pixels.

func (*Context) Identity

func (dc *Context) Identity()

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

func (*Context) Image

func (dc *Context) Image() image.Image

Image returns the image that has been drawn by this context.

func (*Context) InvertMask

func (dc *Context) InvertMask()

InvertMask inverts the alpha values in the current clipping mask such that a fully transparent region becomes fully opaque and vice versa.

func (*Context) LineTo

func (dc *Context) LineTo(x, y float64)

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 (*Context) LineWidth

func (dc *Context) LineWidth() float64

LineWidth returns the line width of the context.

func (*Context) Matrix

func (dc *Context) Matrix() transform.Matrix

Matrix returns the current transformation matrix.

func (*Context) MeasureString

func (dc *Context) MeasureString(s string) (w, h float64)

MeasureString returns the rendered width and height of the specified text given the current font face.

func (*Context) MoveTo

func (dc *Context) MoveTo(x, y float64)

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

func (*Context) NewSubPath

func (dc *Context) NewSubPath()

NewSubPath starts a new subpath within the current path. There is no current point after this operation.

func (*Context) Pop

func (dc *Context) Pop()

Pop restores the last saved context state from the stack.

func (*Context) Push

func (dc *Context) Push()

Push saves the current state of the context for later retrieval. These can be nested.

func (*Context) QuadraticTo

func (dc *Context) QuadraticTo(x1, y1, x2, y2 float64)

QuadraticTo adds a quadratic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1)

func (*Context) ResetClip

func (dc *Context) ResetClip()

ResetClip clears the clipping region.

func (*Context) Rotate

func (dc *Context) Rotate(angle float64)

Rotate updates the current matrix with a anticlockwise rotation. Rotation occurs about the origin. Angle is specified in radians.

func (*Context) RotateAbout

func (dc *Context) RotateAbout(angle, x, y float64)

RotateAbout updates the current matrix with a anticlockwise rotation. Rotation occurs about the specified point. Angle is specified in radians.

func (*Context) Scale

func (dc *Context) Scale(x, y float64)

Scale updates the current matrix with a scaling factor. Scaling occurs about the origin.

func (*Context) ScaleAbout

func (dc *Context) ScaleAbout(sx, sy, x, y float64)

ScaleAbout updates the current matrix with a scaling factor. Scaling occurs about the specified point.

func (*Context) SetColor

func (dc *Context) SetColor(c color.Color)

SetColor sets the current color(for both fill and stroke).

func (*Context) SetDash

func (dc *Context) SetDash(dashes ...float64)

SetDash 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 (*Context) SetDashOffset

func (dc *Context) SetDashOffset(offset float64)

SetDashOffset sets the initial offset into the dash pattern to use when stroking dashed paths.

func (*Context) SetFillRGBA

func (dc *Context) SetFillRGBA(r, g, b, a float64)

SetFillRGBA sets the current color for fill operations. r, g, b, a values must be in range 0-1.

func (*Context) SetFillRule

func (dc *Context) SetFillRule(fillRule context.FillRule)

SetFillRule sets the fill rule.

func (*Context) SetFillStyle

func (dc *Context) SetFillStyle(pattern context.Pattern)

SetFillStyle sets current fill style

func (*Context) SetHexColor

func (dc *Context) SetHexColor(x string)

SetHexColor sets the current color using a hex string. The leading pound sign (#) is optional. Both 3- and 6-digit variations are supported. 8 digits may be provided to set the alpha value as well.

func (*Context) SetLineCap

func (dc *Context) SetLineCap(lineCap context.LineCap)

SetLineCap sets the line cap style.

func (*Context) SetLineJoin

func (dc *Context) SetLineJoin(lineJoin context.LineJoin)

SetLineJoin sets the line join style.

func (*Context) SetLineWidth

func (dc *Context) SetLineWidth(lineWidth float64)

SetLineWidth sets the line width of the context.

func (*Context) SetMask

func (dc *Context) SetMask(mask *image.Alpha) error

SetMask allows you to directly set the *image.Alpha to be used as a clipping mask. It must be the same size as the context, else an error is returned and the mask is unchanged.

func (*Context) SetMatrix

func (dc *Context) SetMatrix(m transform.Matrix)

SetMatrix modifies the transformation matrix.

func (*Context) SetPixel

func (dc *Context) SetPixel(x, y int)

SetPixel sets the color of the specified pixel using the current color.

func (*Context) SetRGB

func (dc *Context) SetRGB(r, g, b float64)

SetRGB sets the current color. r, g, b values should be between 0 and 1, inclusive. Alpha will be set to 1 (fully opaque).

func (*Context) SetRGB255

func (dc *Context) SetRGB255(r, g, b int)

SetRGB255 sets the current color. r, g, b values should be between 0 and 255, inclusive. Alpha will be set to 255 (fully opaque).

func (*Context) SetRGBA

func (dc *Context) SetRGBA(r, g, b, a float64)

SetRGBA sets the current color. r, g, b, a values should be between 0 and 1, inclusive.

func (*Context) SetRGBA255

func (dc *Context) SetRGBA255(r, g, b, a int)

SetRGBA255 sets the current color. r, g, b, a values should be between 0 and 255, inclusive.

func (*Context) SetStrokeRGBA

func (dc *Context) SetStrokeRGBA(r, g, b, a float64)

SetStrokeRGBA sets the current color for stroking operations. r, g, b, a values must be in range 0-1.

func (*Context) SetStrokeStyle

func (dc *Context) SetStrokeStyle(pattern context.Pattern)

SetStrokeStyle sets current stroke style

func (*Context) Shear

func (dc *Context) Shear(x, y float64)

Shear updates the current matrix with a shearing angle. Shearing occurs about the origin.

func (*Context) ShearAbout

func (dc *Context) ShearAbout(sx, sy, x, y float64)

ShearAbout updates the current matrix with a shearing angle. Shearing occurs about the specified point.

func (*Context) Stroke

func (dc *Context) Stroke()

Stroke strokes the current path with the current color, line width, line cap, line join and dash settings. The path is cleared after this operation.

func (*Context) StrokePreserve

func (dc *Context) StrokePreserve()

StrokePreserve strokes the current path with the current color, line width, line cap, line join and dash settings. The path is preserved after this operation.

func (*Context) TextState

func (dc *Context) TextState() *context.TextState

TextState returns the current text state.

func (*Context) Transform

func (dc *Context) Transform(x, y float64) (tx, ty float64)

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

func (*Context) Translate

func (dc *Context) Translate(x, y float64)

Translate updates the current matrix with a translation.

func (*Context) Width

func (dc *Context) Width() int

Width returns the width of the image in pixels.

Jump to

Keyboard shortcuts

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