Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export useful fields and functions #15

Merged
merged 2 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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