From d60a19b37a387a7330b11b1ee17c7b6e742368f6 Mon Sep 17 00:00:00 2001 From: wsw Date: Tue, 22 Nov 2016 12:56:58 +0800 Subject: [PATCH] int/float64 things --- gradient.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gradient.go b/gradient.go index 836dcda..1625520 100644 --- a/gradient.go +++ b/gradient.go @@ -115,7 +115,7 @@ func (g *radialGradient) ColorAt(x, y int) color.Color { if b == 0 { return color.Transparent } - t := 2 * c / b + t := 0.5 * c / b if t*g.cd.r >= g.mindr { return getColor(t, g.stops) } @@ -148,7 +148,10 @@ func NewRadialGradient(x0, y0, r0, x1, y1, r1 float64) Gradient { c1 := circle{x1, y1, r1} cd := circle{x1 - x0, y1 - y0, r1 - r0} a := dot3(cd.x, cd.y, -cd.r, cd.x, cd.y, cd.r) - inva := 1 / a + var inva float64 + if a != 0 { + inva = 1.0 / a + } mindr := -c0.r g := &radialGradient{ c0: c0,