Skip to content

Commit

Permalink
cli: updated to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
esimov committed Apr 20, 2022
1 parent b704471 commit 1758be5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
6 changes: 3 additions & 3 deletions cmd/triangle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"text/template"
"time"

"github.com/esimov/triangle"
"github.com/esimov/triangle/utils"
"github.com/esimov/triangle/v2"
"github.com/esimov/triangle/v2/utils"
"golang.org/x/image/bmp"
"golang.org/x/term"
)
Expand Down Expand Up @@ -85,7 +85,7 @@ func main() {
maxPoints = flag.Int("pts", 2500, "Maximum number of points")
wireframe = flag.Int("wf", 0, "Wireframe mode (0: without stroke, 1: with stroke, 2: stroke only)")
noise = flag.Int("nf", 0, "Noise factor")
strokeWidth = flag.Float64("stw", 1, "Stroke width")
strokeWidth = flag.Float64("sw", 1, "Stroke width")
isStrokeSolid = flag.Bool("sl", false, "Use solid stroke color (yes/no)")
grayscale = flag.Bool("gr", false, "Output in grayscale mode")
showInBrowser = flag.Bool("web", false, "Open the SVG file in the web browser")
Expand Down
12 changes: 6 additions & 6 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Check the supported commands by typing:
Using Go interfaces the API can expose the result either as raster or vector type.
Example to generate triangulated image and output the result as raster type:
Example to generate triangulated image and output the result as a raster type:
package main
import (
"fmt"
"github.com/esimov/triangle"
"github.com/esimov/triangle/v2"
)
func main() {
Expand All @@ -23,7 +23,7 @@ Example to generate triangulated image and output the result as raster type:
}
img := &triangle.Image{*p}
_, _, err = img.Draw(file, fq, func() {})
_, _, _, err := img.Draw(srcImg, p, func() {})
if err != nil {
fmt.Printf("Error on triangulation process: %s", err.Error())
}
Expand All @@ -36,7 +36,7 @@ Example to generate triangulated image and output the result as SVG:
import (
"fmt"
"github.com/esimov/triangle"
"github.com/esimov/triangle/v2"
)
func main() {
Expand All @@ -52,13 +52,13 @@ Example to generate triangulated image and output the result as SVG:
StrokeLineCap: "round", //butt, round, square
Processor: *p,
}
_, _, err = svg.Draw(file, fq, func() {
_, _, _, err := svg.Draw(srcImg, p, func() {
// Call the closure function
})
if err != nil {
fmt.Printf("Error on triangulation process: %s", err.Error())
}
}
*/
*/
package triangle
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/esimov/triangle
module github.com/esimov/triangle/v2

go 1.18

Expand Down
72 changes: 37 additions & 35 deletions imop.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,41 +86,8 @@ func ImgToNRGBA(img image.Image) *image.NRGBA {
return dst
}

// setBlurMatrix populates a matrix table with values used in conjunction with the convolution filter operator.
func setBlurMatrix(size int) []float64 {
var (
side = size*2 + 1
length = side * side
matrix = make([]float64, length)
)

for i := 0; i < length; i++ {
matrix[i] = 1
}

return matrix
}

// setEdgeMatrix populates a matrix table with values used in conjunction with the convolution filter operator.
func setEdgeMatrix(size int) []float64 {
var (
side = size*2 + 1
length = side * side
center = int(length / 2)
matrix = make([]float64, length)
)

for i := 0; i < length; i++ {
if i == center {
matrix[i] = float64(-length)
} else {
matrix[i] = 1
}

}
return matrix
}

// convolutionFilter applies a mathematical operation over the source image by taking
// the matrix table as input parameter and convolving the matrix values over the pixels data.
func convolutionFilter(matrix []float64, img *image.NRGBA, divisor float64) {
var (
divscalar float64
Expand Down Expand Up @@ -198,3 +165,38 @@ func Max[T constraints.Ordered](values ...T) T {
}
return acc
}

// setBlurMatrix populates a matrix table with values used in conjunction with the convolution filter operator.
func setBlurMatrix(size int) []float64 {
var (
side = size*2 + 1
length = side * side
matrix = make([]float64, length)
)

for i := 0; i < length; i++ {
matrix[i] = 1
}

return matrix
}

// setEdgeMatrix populates a matrix table with values used in conjunction with the convolution filter operator.
func setEdgeMatrix(size int) []float64 {
var (
side = size*2 + 1
length = side * side
center = int(length / 2)
matrix = make([]float64, length)
)

for i := 0; i < length; i++ {
if i == center {
matrix[i] = float64(-length)
} else {
matrix[i] = 1
}

}
return matrix
}

0 comments on commit 1758be5

Please sign in to comment.