From a3cc6f790ee2238adfd7047f843dc8eaad459b88 Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Tue, 14 Mar 2017 22:58:06 +0100 Subject: [PATCH] add IMDraw.Reset --- graphics.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/graphics.go b/graphics.go index 7062805..7ed1e90 100644 --- a/graphics.go +++ b/graphics.go @@ -92,11 +92,11 @@ type point struct { type EndShape int const ( - // RoundEndShape is a circular end shape. - RoundEndShape EndShape = iota - // SharpEndShape is a square end shape. - SharpEndShape + SharpEndShape EndShape = iota + + // RoundEndShape is a circular end shape. + RoundEndShape ) // NewIMDraw creates a new empty IMDraw. An optional Picture can be used to draw with a Picture. @@ -108,9 +108,9 @@ func NewIMDraw(pic Picture) *IMDraw { tri: tri, d: Drawer{Triangles: tri, Picture: pic}, } - im.Precision(64) im.SetMatrix(IM) im.SetColorMask(NRGBA{1, 1, 1, 1}) + im.Reset() return im } @@ -120,6 +120,15 @@ func (imd *IMDraw) Clear() { imd.d.Dirty() } +// Reset restores all point properties to defaults and removes all Pushed points. +// +// This does not affect matrix and color mask set by SetMatrix and SetColorMask. +func (imd *IMDraw) Reset() { + imd.points = nil + imd.opts = point{} + imd.Precision(64) +} + // Draw draws all currently drawn shapes inside the IM onto another Target. func (imd *IMDraw) Draw(t Target) { imd.d.Draw(t) -- GitLab