go-chart/renderer.go

90 lines
2.1 KiB
Go
Raw Normal View History

2016-07-07 03:54:00 +02:00
package chart
import (
"io"
"git.fireandbrimst.one/aw/go-chart/drawing"
"git.fireandbrimst.one/aw/golang-freetype/truetype"
2016-07-07 03:54:00 +02:00
)
// Renderer represents the basic methods required to draw a chart.
type Renderer interface {
2016-10-21 21:44:37 +02:00
// ResetStyle should reset any style related settings on the renderer.
ResetStyle()
2016-07-10 19:43:04 +02:00
// GetDPI gets the DPI for the renderer.
2016-07-10 10:11:47 +02:00
GetDPI() float64
2016-07-09 02:57:14 +02:00
// SetDPI sets the DPI for the renderer.
SetDPI(dpi float64)
// SetClassName sets the current class name.
SetClassName(string)
2016-07-07 03:54:00 +02:00
// SetStrokeColor sets the current stroke color.
2016-07-09 20:23:35 +02:00
SetStrokeColor(drawing.Color)
2016-07-07 03:54:00 +02:00
// SetFillColor sets the current fill color.
2016-07-09 20:23:35 +02:00
SetFillColor(drawing.Color)
2016-07-07 03:54:00 +02:00
2016-07-08 07:18:53 +02:00
// SetStrokeWidth sets the stroke width.
SetStrokeWidth(width float64)
2016-07-07 03:54:00 +02:00
2016-07-12 03:48:51 +02:00
// SetStrokeDashArray sets the stroke dash array.
SetStrokeDashArray(dashArray []float64)
2016-07-07 03:54:00 +02:00
// MoveTo moves the cursor to a given point.
MoveTo(x, y int)
// LineTo both starts a shape and draws a line to a given point
// from the previous point.
LineTo(x, y int)
2016-07-28 11:34:44 +02:00
// QuadCurveTo draws a quad curve.
// cx and cy represent the bezier "control points".
QuadCurveTo(cx, cy, x, y int)
// ArcTo draws an arc with a given center (cx,cy)
// a given set of radii (rx,ry), a startAngle and delta (in radians).
ArcTo(cx, cy int, rx, ry, startAngle, delta float64)
2016-07-07 03:54:00 +02:00
// Close finalizes a shape as drawn by LineTo.
Close()
2016-07-07 23:44:03 +02:00
// Stroke strokes the path.
2016-07-07 03:54:00 +02:00
Stroke()
2016-07-07 23:44:03 +02:00
// Fill fills the path, but does not stroke.
Fill()
// FillStroke fills and strokes a path.
2016-07-07 03:54:00 +02:00
FillStroke()
// Circle draws a circle at the given coords with a given radius.
Circle(radius float64, x, y int)
// SetFont sets a font for a text field.
SetFont(*truetype.Font)
// SetFontColor sets a font's color
2016-07-09 20:23:35 +02:00
SetFontColor(drawing.Color)
2016-07-07 03:54:00 +02:00
// SetFontSize sets the font size for a text field.
SetFontSize(size float64)
// Text draws a text blob.
Text(body string, x, y int)
// MeasureText measures text.
2016-07-12 03:48:51 +02:00
MeasureText(body string) Box
2016-07-07 03:54:00 +02:00
2016-08-07 06:59:46 +02:00
// SetTextRotatation sets a rotation for drawing elements.
SetTextRotation(radians float64)
// ClearTextRotation clears rotation.
ClearTextRotation()
2016-07-07 03:54:00 +02:00
// Save writes the image to the given writer.
Save(w io.Writer) error
}