draw2d/gc.go

81 lines
3 KiB
Go
Raw Normal View History

2011-04-27 08:06:14 +00:00
// Copyright 2010 The draw2d Authors. All rights reserved.
// created: 21/11/2010 by Laurent Le Goff
2012-04-17 09:03:56 +00:00
2011-04-27 08:06:14 +00:00
package draw2d
import (
"image"
2012-01-13 09:14:12 +00:00
"image/color"
2011-04-27 08:06:14 +00:00
)
2015-07-07 22:42:00 +00:00
// GraphicContext describes the interface for the various backends (images, pdf, opengl, ...)
2011-04-27 08:06:14 +00:00
type GraphicContext interface {
// PathBuilder describes the interface for path drawing
PathBuilder
2015-04-29 16:09:07 +00:00
// BeginPath creates a new path
2012-04-17 09:03:56 +00:00
BeginPath()
2015-04-29 16:09:07 +00:00
// GetMatrixTransform returns the current transformation matrix
2015-04-30 12:11:23 +00:00
GetMatrixTransform() Matrix
2015-04-29 16:09:07 +00:00
// SetMatrixTransform sets the current transformation matrix
2015-04-30 12:11:23 +00:00
SetMatrixTransform(tr Matrix)
2015-04-29 16:09:07 +00:00
// ComposeMatrixTransform composes the current transformation matrix with tr
2015-04-30 12:11:23 +00:00
ComposeMatrixTransform(tr Matrix)
2015-04-29 16:09:07 +00:00
// Rotate applies a rotation to the current transformation matrix. angle is in radian.
2011-04-27 08:06:14 +00:00
Rotate(angle float64)
2015-04-29 16:09:07 +00:00
// Translate applies a translation to the current transformation matrix.
2011-04-27 08:06:14 +00:00
Translate(tx, ty float64)
2015-04-29 16:09:07 +00:00
// Scale applies a scale to the current transformation matrix.
2011-04-27 08:06:14 +00:00
Scale(sx, sy float64)
2015-04-29 16:09:07 +00:00
// SetStrokeColor sets the current stroke color
2012-01-13 09:14:12 +00:00
SetStrokeColor(c color.Color)
// SetFillColor sets the current fill color
2012-01-13 09:14:12 +00:00
SetFillColor(c color.Color)
2015-04-29 16:09:07 +00:00
// SetFillRule sets the current fill rule
2011-04-27 08:06:14 +00:00
SetFillRule(f FillRule)
2015-04-29 16:09:07 +00:00
// SetLineWidth sets the current line width
2011-04-27 08:06:14 +00:00
SetLineWidth(lineWidth float64)
2015-04-29 16:09:07 +00:00
// SetLineCap sets the current line cap
SetLineCap(cap LineCap)
2015-04-29 16:09:07 +00:00
// SetLineJoin sets the current line join
SetLineJoin(join LineJoin)
// SetLineDash sets the current dash
2011-04-27 08:06:14 +00:00
SetLineDash(dash []float64, dashOffset float64)
// SetFontSize sets the current font size
2011-04-27 08:06:14 +00:00
SetFontSize(fontSize float64)
// GetFontSize gets the current font size
2011-04-27 08:06:14 +00:00
GetFontSize() float64
// SetFontData sets the current FontData
2011-04-27 08:06:14 +00:00
SetFontData(fontData FontData)
// GetFontData gets the current FontData
2011-04-27 08:06:14 +00:00
GetFontData() FontData
// DrawImage draws the raster image in the current canvas
2011-04-27 08:06:14 +00:00
DrawImage(image image.Image)
Save()
Restore()
// Clear fills the current canvas with a default transparent color
2011-04-27 08:06:14 +00:00
Clear()
ClearRect(x1, y1, x2, y2 int)
// SetDPI sets the current DPI
2011-04-27 08:06:14 +00:00
SetDPI(dpi int)
// GetDPI gets the current DPI
2011-04-27 08:06:14 +00:00
GetDPI() int
// GetStringBounds gets pixel bounds(dimensions) of given string
2013-05-29 02:48:35 +00:00
GetStringBounds(s string) (left, top, right, bottom float64)
// CreateStringPath creates a path from the string s at x, y
2013-05-27 19:09:57 +00:00
CreateStringPath(text string, x, y float64) (cursor float64)
// FillString draws the text at point (0, 0)
2011-04-27 08:06:14 +00:00
FillString(text string) (cursor float64)
// FillStringAt draws the text at the specified point (x, y)
2013-05-27 19:09:57 +00:00
FillStringAt(text string, x, y float64) (cursor float64)
// StrokeString draws the contour of the text at point (0, 0)
StrokeString(text string) (cursor float64)
// StrokeStringAt draws the contour of the text at point (x, y)
2013-05-27 19:09:57 +00:00
StrokeStringAt(text string, x, y float64) (cursor float64)
// Stroke strokes the paths with the color specified by SetStrokeColor
Stroke(paths ...*Path)
// Fill fills the paths with the color specified by SetFillColor
Fill(paths ...*Path)
// FillStroke first fills the paths and than strokes them
FillStroke(paths ...*Path)
2011-04-27 08:06:14 +00:00
}