From 637509b5d42bc7cdd76bd3254005464e8a231767 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Fri, 14 Feb 2020 16:28:24 +0100 Subject: [PATCH] minor fixes --- backend/goglbackend/clip.go | 9 +++++---- backend/goglbackend/fill.go | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/goglbackend/clip.go b/backend/goglbackend/clip.go index 3ccec5c..be4d75a 100644 --- a/backend/goglbackend/clip.go +++ b/backend/goglbackend/clip.go @@ -17,11 +17,12 @@ func (b *GoGLBackend) Clip(pts [][2]float64) { b.activate() b.ptsBuf = b.ptsBuf[:0] + min, max := extent(pts) b.ptsBuf = append(b.ptsBuf, - 0, 0, - 0, float32(b.fh), - float32(b.fw), float32(b.fh), - float32(b.fw), 0) + float32(min[0]), float32(min[1]), + float32(min[0]), float32(max[1]), + float32(max[0]), float32(max[1]), + float32(max[0]), float32(min[1])) for _, pt := range pts { b.ptsBuf = append(b.ptsBuf, float32(pt[0]), float32(pt[1])) } diff --git a/backend/goglbackend/fill.go b/backend/goglbackend/fill.go index 39d67c2..fefd4c0 100644 --- a/backend/goglbackend/fill.go +++ b/backend/goglbackend/fill.go @@ -72,6 +72,8 @@ func (b *GoGLBackend) clearRect(x, y, w, h int) { } func extent(pts [][2]float64) (min, max vec) { + max[0] = -math.MaxFloat64 + max[1] = -math.MaxFloat64 min[0] = math.MaxFloat64 min[1] = math.MaxFloat64 for _, v := range pts {