Skip to content

Commit

Permalink
Update with math.Hypot()
Browse files Browse the repository at this point in the history
  • Loading branch information
jphsd committed Apr 18, 2023
1 parent f8184b7 commit 95574d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion displace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gradient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
16 changes: 8 additions & 8 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}

0 comments on commit 95574d1

Please sign in to comment.