1package drawing
2
3import (
4	"image"
5	"image/color"
6
7	"github.com/golang/freetype/truetype"
8)
9
10// GraphicContext describes the interface for the various backends (images, pdf, opengl, ...)
11type GraphicContext interface {
12	// PathBuilder describes the interface for path drawing
13	PathBuilder
14	// BeginPath creates a new path
15	BeginPath()
16	// GetMatrixTransform returns the current transformation matrix
17	GetMatrixTransform() Matrix
18	// SetMatrixTransform sets the current transformation matrix
19	SetMatrixTransform(tr Matrix)
20	// ComposeMatrixTransform composes the current transformation matrix with tr
21	ComposeMatrixTransform(tr Matrix)
22	// Rotate applies a rotation to the current transformation matrix. angle is in radian.
23	Rotate(angle float64)
24	// Translate applies a translation to the current transformation matrix.
25	Translate(tx, ty float64)
26	// Scale applies a scale to the current transformation matrix.
27	Scale(sx, sy float64)
28	// SetStrokeColor sets the current stroke color
29	SetStrokeColor(c color.Color)
30	// SetFillColor sets the current fill color
31	SetFillColor(c color.Color)
32	// SetFillRule sets the current fill rule
33	SetFillRule(f FillRule)
34	// SetLineWidth sets the current line width
35	SetLineWidth(lineWidth float64)
36	// SetLineCap sets the current line cap
37	SetLineCap(cap LineCap)
38	// SetLineJoin sets the current line join
39	SetLineJoin(join LineJoin)
40	// SetLineDash sets the current dash
41	SetLineDash(dash []float64, dashOffset float64)
42	// SetFontSize sets the current font size
43	SetFontSize(fontSize float64)
44	// GetFontSize gets the current font size
45	GetFontSize() float64
46	// SetFont sets the font for the context
47	SetFont(f *truetype.Font)
48	// GetFont returns the current font
49	GetFont() *truetype.Font
50	// DrawImage draws the raster image in the current canvas
51	DrawImage(image image.Image)
52	// Save the context and push it to the context stack
53	Save()
54	// Restore remove the current context and restore the last one
55	Restore()
56	// Clear fills the current canvas with a default transparent color
57	Clear()
58	// ClearRect fills the specified rectangle with a default transparent color
59	ClearRect(x1, y1, x2, y2 int)
60	// SetDPI sets the current DPI
61	SetDPI(dpi int)
62	// GetDPI gets the current DPI
63	GetDPI() int
64	// GetStringBounds gets pixel bounds(dimensions) of given string
65	GetStringBounds(s string) (left, top, right, bottom float64)
66	// CreateStringPath creates a path from the string s at x, y
67	CreateStringPath(text string, x, y float64) (cursor float64)
68	// FillString draws the text at point (0, 0)
69	FillString(text string) (cursor float64)
70	// FillStringAt draws the text at the specified point (x, y)
71	FillStringAt(text string, x, y float64) (cursor float64)
72	// StrokeString draws the contour of the text at point (0, 0)
73	StrokeString(text string) (cursor float64)
74	// StrokeStringAt draws the contour of the text at point (x, y)
75	StrokeStringAt(text string, x, y float64) (cursor float64)
76	// Stroke strokes the paths with the color specified by SetStrokeColor
77	Stroke(paths ...*Path)
78	// Fill fills the paths with the color specified by SetFillColor
79	Fill(paths ...*Path)
80	// FillStroke first fills the paths and than strokes them
81	FillStroke(paths ...*Path)
82}
83