go-chart/renderer.go

67 lines
1.4 KiB
Go
Raw Normal View History

2016-07-06 21:54:00 -04:00
package chart
import (
"io"
"github.com/golang/freetype/truetype"
2016-07-09 14:23:35 -04:00
"github.com/wcharczuk/go-chart/drawing"
2016-07-06 21:54:00 -04:00
)
// Renderer represents the basic methods required to draw a chart.
type Renderer interface {
2016-07-10 13:43:04 -04:00
// GetDPI gets the DPI for the renderer.
2016-07-10 04:11:47 -04:00
GetDPI() float64
2016-07-08 20:57:14 -04:00
// SetDPI sets the DPI for the renderer.
SetDPI(dpi float64)
2016-07-06 21:54:00 -04:00
// SetStrokeColor sets the current stroke color.
2016-07-09 14:23:35 -04:00
SetStrokeColor(drawing.Color)
2016-07-06 21:54:00 -04:00
// SetFillColor sets the current fill color.
2016-07-09 14:23:35 -04:00
SetFillColor(drawing.Color)
2016-07-06 21:54:00 -04:00
2016-07-08 01:18:53 -04:00
// SetStrokeWidth sets the stroke width.
SetStrokeWidth(width float64)
2016-07-06 21:54:00 -04: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)
// Close finalizes a shape as drawn by LineTo.
Close()
2016-07-07 17:44:03 -04:00
// Stroke strokes the path.
2016-07-06 21:54:00 -04:00
Stroke()
2016-07-07 17:44:03 -04:00
// Fill fills the path, but does not stroke.
Fill()
// FillStroke fills and strokes a path.
2016-07-06 21:54:00 -04: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 14:23:35 -04:00
SetFontColor(drawing.Color)
2016-07-06 21:54:00 -04: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-08 20:57:14 -04:00
MeasureText(body string) (width int, height int)
2016-07-06 21:54:00 -04:00
// Save writes the image to the given writer.
Save(w io.Writer) error
}