From 65947eb0478c6de3aed7afe1640d49d6ee7f0cd7 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Wed, 14 Dec 2016 14:43:30 -0500 Subject: [PATCH] add SetPixel and DrawPoint --- context.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/context.go b/context.go index e961953..f6120f2 100644 --- a/context.go +++ b/context.go @@ -483,6 +483,22 @@ func (dc *Context) Clear() { draw.Draw(dc.im, dc.im.Bounds(), src, image.ZP, draw.Src) } +// SetPixel sets the color of the specified pixel using the current color. +func (dc *Context) SetPixel(x, y int) { + dc.im.Set(x, y, dc.color) +} + +// DrawPoint is like DrawCircle but ensures that a circle of the specified +// size is drawn regardless of the current transformation matrix. The position +// is still transformed, but not the shape of the point. +func (dc *Context) DrawPoint(x, y, r float64) { + dc.Push() + tx, ty := dc.TransformPoint(x, y) + dc.Identity() + dc.DrawCircle(tx, ty, r) + dc.Pop() +} + func (dc *Context) DrawLine(x1, y1, x2, y2 float64) { dc.MoveTo(x1, y1) dc.LineTo(x2, y2)