MCPcopy
hub / github.com/tdewolff/canvas / DrawPath

Method DrawPath

canvas.go:638–659  ·  view source on GitHub ↗

DrawPath draws a path at position (x,y) using the current draw state.

(x, y float64, paths ...*Path)

Source from the content-addressed store, hash-verified

636
637// DrawPath draws a path at position (x,y) using the current draw state.
638func (c *Context) DrawPath(x, y float64, paths ...*Path) {
639 if !c.Style.HasFill() && !c.Style.HasStroke() {
640 return
641 }
642
643 style := c.Style
644 m := c.CoordSystemView()
645
646 // get view
647 coord := c.coordView.Dot(Point{x, y})
648 m = m.Mul(c.view).Translate(coord.X, coord.Y)
649
650 dashes := style.Dashes
651 for _, path := range paths {
652 var ok bool
653 style.Dashes, ok = path.checkDash(c.Style.DashOffset, dashes)
654 if !ok {
655 style.Stroke = Paint{}
656 }
657 c.RenderPath(path, style, m)
658 }
659}
660
661// DrawText draws text at position (x,y) using the current draw state.
662func (c *Context) DrawText(x, y float64, text *Text) {

Callers 15

DrawPreviewWithAssetsFunction · 0.95
FillMethod · 0.95
StrokeMethod · 0.95
FillStrokeMethod · 0.95
TestCanvasFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 8

CoordSystemViewMethod · 0.95
HasFillMethod · 0.80
HasStrokeMethod · 0.80
checkDashMethod · 0.80
RenderPathMethod · 0.65
DotMethod · 0.45
TranslateMethod · 0.45
MulMethod · 0.45

Tested by 2

TestCanvasFunction · 0.76
TestStarTexFunction · 0.76