Skip to content

Commit

Permalink
Merge pull request #15 from whereswaldon/master
Browse files Browse the repository at this point in the history
Export useful fields and functions
  • Loading branch information
esimov committed Apr 12, 2021
2 parents 87346c6 + 5280c4b commit 06fa40a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions delaunay.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package triangle

import "image"

// Point defines a struct having as components the point X and Y coordinate position.
type Point struct {
x, y int
}
type Point = image.Point

// Node defines a struct having as components the node X and Y coordinate position.
type Node struct {
Expand Down Expand Up @@ -143,8 +143,8 @@ func (d *Delaunay) Insert(points []Point) *Delaunay {
)

for k = 0; k < len(points); k++ {
x = points[k].x
y = points[k].y
x = points[k].X
y = points[k].Y

triangles := d.triangles
edges = edges[:0]
Expand Down
2 changes: 1 addition & 1 deletion edges.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GetEdgePoints(img *image.NRGBA, threshold, maxPoints int) []Point {
sum /= total
}
if sum > threshold {
points = append(points, Point{x: x, y: y})
points = append(points, Point{X: x, Y: y})
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions process.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (im *Image) Draw(input interface{}, output interface{}, fn func()) (image.I
ctx.Fill()

delaunay := &Delaunay{}
img := toNRGBA(src.(image.Image))
img := ToNRGBA(src.(image.Image))

blur := StackBlur(img, uint32(im.BlurRadius))
gray := Grayscale(blur)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (svg *SVG) Draw(input io.Reader, output io.Writer, fn func()) (image.Image,
ctx.Fill()

delaunay := &Delaunay{}
img := toNRGBA(src)
img := ToNRGBA(src)

blur := StackBlur(img, uint32(svg.BlurRadius))
gray := Grayscale(blur)
Expand Down Expand Up @@ -305,8 +305,8 @@ func (svg *SVG) Draw(input io.Reader, output io.Writer, fn func()) (image.Image,
return nil, triangles, points, err
}

// toNRGBA converts any image type to *image.NRGBA with min-point at (0, 0).
func toNRGBA(img image.Image) *image.NRGBA {
// ToNRGBA converts any image type to *image.NRGBA with min-point at (0, 0).
func ToNRGBA(img image.Image) *image.NRGBA {
srcBounds := img.Bounds()
if srcBounds.Min.X == 0 && srcBounds.Min.Y == 0 {
if src0, ok := img.(*image.NRGBA); ok {
Expand Down

0 comments on commit 06fa40a

Please sign in to comment.