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 {
|
2016-04-27 13:25:21 +00:00
|
|
|
// PathBuilder describes the interface for path drawing
|
2015-04-29 12:33:32 +00:00
|
|
|
PathBuilder
|
2015-04-29 16:09:07 +00:00
|
|
|
// BeginPath creates a new path
|
2012-04-17 09:03:56 +00:00
|
|
|
BeginPath()
|
2016-10-19 19:01:45 +00:00
|
|
|
// GetPath copies the current path, then returns it
|
2016-10-19 18:53:36 +00:00
|
|
|
GetPath() Path
|
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)
|
2016-04-27 13:25:21 +00:00
|
|
|
// 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
|
2015-04-29 12:33:32 +00:00
|
|
|
SetLineCap(cap LineCap)
|
2015-04-29 16:09:07 +00:00
|
|
|
// SetLineJoin sets the current line join
|
2015-04-29 12:33:32 +00:00
|
|
|
SetLineJoin(join LineJoin)
|
2016-04-27 13:25:21 +00:00
|
|
|
// SetLineDash sets the current dash
|
2011-04-27 08:06:14 +00:00
|
|
|
SetLineDash(dash []float64, dashOffset float64)
|
2016-04-27 13:25:21 +00:00
|
|
|
// SetFontSize sets the current font size
|
2011-04-27 08:06:14 +00:00
|
|
|
SetFontSize(fontSize float64)
|
2016-04-27 13:25:21 +00:00
|
|
|
// GetFontSize gets the current font size
|
2011-04-27 08:06:14 +00:00
|
|
|
GetFontSize() float64
|
2016-04-27 13:25:21 +00:00
|
|
|
// SetFontData sets the current FontData
|
2011-04-27 08:06:14 +00:00
|
|
|
SetFontData(fontData FontData)
|
2016-04-27 13:25:21 +00:00
|
|
|
// GetFontData gets the current FontData
|
2011-04-27 08:06:14 +00:00
|
|
|
GetFontData() FontData
|
2016-04-27 13:25:21 +00:00
|
|
|
// DrawImage draws the raster image in the current canvas
|
2011-04-27 08:06:14 +00:00
|
|
|
DrawImage(image image.Image)
|
2016-04-27 13:25:21 +00:00
|
|
|
// Save the context and push it to the context stack
|
2011-04-27 08:06:14 +00:00
|
|
|
Save()
|
2016-04-27 13:25:21 +00:00
|
|
|
// Restore remove the current context and restore the last one
|
2011-04-27 08:06:14 +00:00
|
|
|
Restore()
|
2016-04-27 13:25:21 +00:00
|
|
|
// Clear fills the current canvas with a default transparent color
|
2011-04-27 08:06:14 +00:00
|
|
|
Clear()
|
2016-04-27 13:25:21 +00:00
|
|
|
// ClearRect fills the specified rectangle with a default transparent color
|
2011-04-27 08:06:14 +00:00
|
|
|
ClearRect(x1, y1, x2, y2 int)
|
2016-04-27 13:25:21 +00:00
|
|
|
// SetDPI sets the current DPI
|
2011-04-27 08:06:14 +00:00
|
|
|
SetDPI(dpi int)
|
2016-04-27 13:25:21 +00:00
|
|
|
// GetDPI gets the current DPI
|
2011-04-27 08:06:14 +00:00
|
|
|
GetDPI() int
|
2016-04-27 13:25:21 +00:00
|
|
|
// GetStringBounds gets pixel bounds(dimensions) of given string
|
2013-05-29 02:48:35 +00:00
|
|
|
GetStringBounds(s string) (left, top, right, bottom float64)
|
2016-04-27 13:25:21 +00:00
|
|
|
// 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)
|
2016-04-27 13:25:21 +00:00
|
|
|
// FillString draws the text at point (0, 0)
|
2011-04-27 08:06:14 +00:00
|
|
|
FillString(text string) (cursor float64)
|
2016-04-27 13:25:21 +00:00
|
|
|
// 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)
|
2016-04-27 13:25:21 +00:00
|
|
|
// StrokeString draws the contour of the text at point (0, 0)
|
2013-05-27 18:53:53 +00:00
|
|
|
StrokeString(text string) (cursor float64)
|
2016-04-27 13:25:21 +00:00
|
|
|
// 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)
|
2016-04-27 13:25:21 +00:00
|
|
|
// Stroke strokes the paths with the color specified by SetStrokeColor
|
2015-04-29 12:33:32 +00:00
|
|
|
Stroke(paths ...*Path)
|
2016-04-27 13:25:21 +00:00
|
|
|
// Fill fills the paths with the color specified by SetFillColor
|
2015-04-29 12:33:32 +00:00
|
|
|
Fill(paths ...*Path)
|
2016-04-27 13:25:21 +00:00
|
|
|
// FillStroke first fills the paths and than strokes them
|
2015-04-29 12:33:32 +00:00
|
|
|
FillStroke(paths ...*Path)
|
2011-04-27 08:06:14 +00:00
|
|
|
}
|