| 1 | package chart |
| 2 | |
| 3 | import ( |
| 4 | "io" |
| 5 | |
| 6 | "github.com/golang/freetype/truetype" |
| 7 | "github.com/wcharczuk/go-chart/v2/drawing" |
| 8 | ) |
| 9 | |
| 10 | // Renderer represents the basic methods required to draw a chart. |
| 11 | type Renderer interface { |
| 12 | // ResetStyle should reset any style related settings on the renderer. |
| 13 | ResetStyle() |
| 14 | |
| 15 | // GetDPI gets the DPI for the renderer. |
| 16 | GetDPI() float64 |
| 17 | |
| 18 | // SetDPI sets the DPI for the renderer. |
| 19 | SetDPI(dpi float64) |
| 20 | |
| 21 | // SetClassName sets the current class name. |
| 22 | SetClassName(string) |
| 23 | |
| 24 | // SetStrokeColor sets the current stroke color. |
| 25 | SetStrokeColor(drawing.Color) |
| 26 | |
| 27 | // SetFillColor sets the current fill color. |
| 28 | SetFillColor(drawing.Color) |
| 29 | |
| 30 | // SetStrokeWidth sets the stroke width. |
| 31 | SetStrokeWidth(width float64) |
| 32 | |
| 33 | // SetStrokeDashArray sets the stroke dash array. |
| 34 | SetStrokeDashArray(dashArray []float64) |
| 35 | |
| 36 | // MoveTo moves the cursor to a given point. |
| 37 | MoveTo(x, y int) |
| 38 | |
| 39 | // LineTo both starts a shape and draws a line to a given point |
| 40 | // from the previous point. |
| 41 | LineTo(x, y int) |
| 42 | |
| 43 | // QuadCurveTo draws a quad curve. |
| 44 | // cx and cy represent the bezier "control points". |
| 45 | QuadCurveTo(cx, cy, x, y int) |
| 46 | |
| 47 | // ArcTo draws an arc with a given center (cx,cy) |
| 48 | // a given set of radii (rx,ry), a startAngle and delta (in radians). |
| 49 | ArcTo(cx, cy int, rx, ry, startAngle, delta float64) |
| 50 | |
| 51 | // Close finalizes a shape as drawn by LineTo. |
| 52 | Close() |
| 53 | |
| 54 | // Stroke strokes the path. |
| 55 | Stroke() |
| 56 | |
| 57 | // Fill fills the path, but does not stroke. |
| 58 | Fill() |
| 59 | |
| 60 | // FillStroke fills and strokes a path. |
| 61 | FillStroke() |
| 62 | |
| 63 | // Circle draws a circle at the given coords with a given radius. |
| 64 | Circle(radius float64, x, y int) |
| 65 | |
| 66 | // SetFont sets a font for a text field. |
| 67 | SetFont(*truetype.Font) |
| 68 | |
| 69 | // SetFontColor sets a font's color |
| 70 | SetFontColor(drawing.Color) |
| 71 | |
| 72 | // SetFontSize sets the font size for a text field. |
| 73 | SetFontSize(size float64) |
| 74 | |
| 75 | // Text draws a text blob. |
| 76 | Text(body string, x, y int) |
| 77 | |
| 78 | // MeasureText measures text. |
| 79 | MeasureText(body string) Box |
| 80 | |
| 81 | // SetTextRotatation sets a rotation for drawing elements. |
| 82 | SetTextRotation(radians float64) |
| 83 | |
| 84 | // ClearTextRotation clears rotation. |
| 85 | ClearTextRotation() |
| 86 | |
| 87 | // Save writes the image to the given writer. |
| 88 | Save(w io.Writer) error |
| 89 | } |