From 43258d7dd7114b9b1c28511fe3fe1c0c1f02513d Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Fri, 19 Feb 2016 21:00:56 -0500 Subject: [PATCH] InvertY --- README.md | 1 + context.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8dd6cdb..34a1a8e 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ Rotate(angle float64) RotateAbout(angle, x, y float64) Shear(x, y float64) TransformPoint(x, y float64) (tx, ty float64) +InvertY() Push() Pop() ``` diff --git a/context.go b/context.go index bacc9f5..090da64 100644 --- a/context.go +++ b/context.go @@ -257,7 +257,8 @@ func (dc *Context) Fill() { // Convenient Drawing Functions func (dc *Context) Clear() { - draw.Draw(dc.im, dc.im.Bounds(), image.NewUniform(dc.color), image.ZP, draw.Src) + src := image.NewUniform(dc.color) + draw.Draw(dc.im, dc.im.Bounds(), src, image.ZP, draw.Src) } func (dc *Context) DrawLine(x1, y1, x2, y2 float64) { @@ -375,6 +376,11 @@ func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) { return dc.matrix.TransformPoint(x, y) } +func (dc *Context) InvertY() { + dc.Translate(0, float64(dc.height)) + dc.Scale(1, -1) +} + // Stack func (dc *Context) Push() {