From 95574d17235c72e72431d25bf87f094fa5c99b12 Mon Sep 17 00:00:00 2001 From: Jonathan Hughes <10040216+jphsd@users.noreply.github.com> Date: Mon, 17 Apr 2023 20:44:41 -0700 Subject: [PATCH] Update with math.Hypot() --- displace.go | 2 +- gradient.go | 2 +- utils.go | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/displace.go b/displace.go index 916385a..07a022a 100644 --- a/displace.go +++ b/displace.go @@ -12,7 +12,7 @@ type Displace struct { Indep bool } -// NewDisplace creates a new Dispalce instance using the same source for both x and y displacements. +// NewDisplace creates a new Displace instance using the same transform for both x and y displacements. func NewDisplace(in, dx, dy Field, scale float64) *Displace { xfm := graphics2d.NewAff3() xfm.Scale(scale, scale) diff --git a/gradient.go b/gradient.go index 8c6bee2..0baec45 100644 --- a/gradient.go +++ b/gradient.go @@ -25,7 +25,7 @@ func NewRadialGradient(wf Wave) *RadialGradient { } func (g *RadialGradient) Eval2(x, y float64) float64 { - v := math.Sqrt(x*x + y*y) + v := math.Hypot(x, y) return g.WF.Eval(v) } diff --git a/utils.go b/utils.go index 1fa6d68..7aa72bb 100644 --- a/utils.go +++ b/utils.go @@ -12,7 +12,7 @@ import ( func NewLinearGray16(w, h int, p1, p2 []float64, wf *NonLinear, mirror, once bool) *TextureGray16 { dx, dy := p2[0]-p1[0], p2[1]-p1[1] th := math.Atan2(dy, dx) - lambda := math.Sqrt(dx*dx + dy*dy) + lambda := math.Hypot(dx, dy) if wf == nil { wf = NewNLLinear() @@ -54,16 +54,16 @@ func NewConicGray16(w, h int, c []float64, th float64, wf *NonLinear) *TextureGr return NewTextureGray16(w, h, cf, 0, 0, 1, 1) } -// Tinting wrappers around the grayscale gradients +// Colorizer wrappers around the grayscale gradients -func NewLinearRGBA(w, h int, p1, p2 []float64, c1, c2 color.Color, wf *NonLinear, mirror, once bool) *image.Tinter { - return image.NewTinter(NewLinearGray16(w, h, p1, p2, wf, mirror, once), c1, c2) +func NewLinearRGBA(w, h int, p1, p2 []float64, c1, c2 color.Color, wf *NonLinear, mirror, once bool) *image.Colorizer { + return image.NewColorizer(NewLinearGray16(w, h, p1, p2, wf, mirror, once), c1, c2, nil, nil, false) } -func NewRadialRGBA(w, h int, c []float64, r float64, c1, c2 color.Color, wf *NonLinear, mirror, once bool) *image.Tinter { - return image.NewTinter(NewRadialGray16(w, h, c, r, wf, mirror, once), c1, c2) +func NewRadialRGBA(w, h int, c []float64, r float64, c1, c2 color.Color, wf *NonLinear, mirror, once bool) *image.Colorizer { + return image.NewColorizer(NewRadialGray16(w, h, c, r, wf, mirror, once), c1, c2, nil, nil, false) } -func NewConicRGBA(w, h int, c []float64, th float64, c1, c2 color.Color, wf *NonLinear) *image.Tinter { - return image.NewTinter(NewConicGray16(w, h, c, th, wf), c1, c2) +func NewConicRGBA(w, h int, c []float64, th float64, c1, c2 color.Color, wf *NonLinear) *image.Colorizer { + return image.NewColorizer(NewConicGray16(w, h, c, th, wf), c1, c2, nil, nil, false) }