A Canvas is the main drawing interface for 2D vector graphics. The origin is in the bottom left corner.
| 19 | // graphics. |
| 20 | // The origin is in the bottom left corner. |
| 21 | type Canvas interface { |
| 22 | // SetLineWidth sets the width of stroked paths. |
| 23 | // If the width is not positive then stroked lines |
| 24 | // are not drawn. |
| 25 | // |
| 26 | // The initial line width is 1 point. |
| 27 | SetLineWidth(Length) |
| 28 | |
| 29 | // SetLineDash sets the dash pattern for lines. |
| 30 | // The pattern slice specifies the lengths of |
| 31 | // alternating dashes and gaps, and the offset |
| 32 | // specifies the distance into the dash pattern |
| 33 | // to start the dash. |
| 34 | // |
| 35 | // The initial dash pattern is a solid line. |
| 36 | SetLineDash(pattern []Length, offset Length) |
| 37 | |
| 38 | // SetColor sets the current drawing color. |
| 39 | // Note that fill color and stroke color are |
| 40 | // the same, so if you want different fill |
| 41 | // and stroke colors then you must set a color, |
| 42 | // draw fills, set a new color and then draw lines. |
| 43 | // |
| 44 | // The initial color is black. |
| 45 | // If SetColor is called with a nil color then black is used. |
| 46 | SetColor(color.Color) |
| 47 | |
| 48 | // Rotate applies a rotation transform to the context. |
| 49 | // The parameter is specified in radians. |
| 50 | Rotate(rad float64) |
| 51 | |
| 52 | // Translate applies a translational transform |
| 53 | // to the context. |
| 54 | Translate(pt Point) |
| 55 | |
| 56 | // Scale applies a scaling transform to the |
| 57 | // context. |
| 58 | Scale(x, y float64) |
| 59 | |
| 60 | // Push saves the current line width, the |
| 61 | // current dash pattern, the current |
| 62 | // transforms, and the current color |
| 63 | // onto a stack so that the state can later |
| 64 | // be restored by calling Pop(). |
| 65 | Push() |
| 66 | |
| 67 | // Pop restores the context saved by the |
| 68 | // corresponding call to Push(). |
| 69 | Pop() |
| 70 | |
| 71 | // Stroke strokes the given path. |
| 72 | Stroke(Path) |
| 73 | |
| 74 | // Fill fills the given path. |
| 75 | Fill(Path) |
| 76 | |
| 77 | // FillString fills in text at the specified |
| 78 | // location using the given font. |