golint fixes
This commit is contained in:
parent
fe06e5046c
commit
55b5c931cf
5 changed files with 32 additions and 20 deletions
|
@ -15,8 +15,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
flattening_threshold float64 = 0.5
|
||||
testsCubicFloat64 = []CubicCurveFloat64{
|
||||
flatteningThreshold = 0.5
|
||||
testsCubicFloat64 = []CubicCurveFloat64{
|
||||
CubicCurveFloat64{100, 100, 200, 100, 100, 200, 200, 200},
|
||||
CubicCurveFloat64{100, 100, 300, 200, 200, 200, 300, 100},
|
||||
CubicCurveFloat64{100, 100, 0, 300, 200, 0, 300, 300},
|
||||
|
@ -110,7 +110,7 @@ func TestCubicCurveRec(t *testing.T) {
|
|||
for i, curve := range testsCubicFloat64 {
|
||||
var p Path
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.SegmentRec(&p, flattening_threshold)
|
||||
curve.SegmentRec(&p, flatteningThreshold)
|
||||
img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
|
||||
raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, curve[:]...)
|
||||
raster.PolylineBresenham(img, image.Black, p.points...)
|
||||
|
@ -126,7 +126,7 @@ func TestCubicCurve(t *testing.T) {
|
|||
for i, curve := range testsCubicFloat64 {
|
||||
var p Path
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.Segment(&p, flattening_threshold)
|
||||
curve.Segment(&p, flatteningThreshold)
|
||||
img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
|
||||
raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, curve[:]...)
|
||||
raster.PolylineBresenham(img, image.Black, p.points...)
|
||||
|
@ -174,7 +174,7 @@ func TestCubicCurveParabolic(t *testing.T) {
|
|||
for i, curve := range testsCubicFloat64 {
|
||||
var p Path
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.ParabolicSegment(&p, flattening_threshold)
|
||||
curve.ParabolicSegment(&p, flatteningThreshold)
|
||||
img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
|
||||
raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, curve[:]...)
|
||||
raster.PolylineBresenham(img, image.Black, p.points...)
|
||||
|
@ -190,7 +190,7 @@ func TestQuadCurve(t *testing.T) {
|
|||
for i, curve := range testsQuadFloat64 {
|
||||
var p Path
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.Segment(&p, flattening_threshold)
|
||||
curve.Segment(&p, flatteningThreshold)
|
||||
img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
|
||||
raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, curve[:]...)
|
||||
raster.PolylineBresenham(img, image.Black, p.points...)
|
||||
|
@ -207,7 +207,7 @@ func BenchmarkCubicCurveRec(b *testing.B) {
|
|||
for _, curve := range testsCubicFloat64 {
|
||||
p := Path{make([]float64, 0, 32)}
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.SegmentRec(&p, flattening_threshold)
|
||||
curve.SegmentRec(&p, flatteningThreshold)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ func BenchmarkCubicCurve(b *testing.B) {
|
|||
for _, curve := range testsCubicFloat64 {
|
||||
p := Path{make([]float64, 0, 32)}
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.Segment(&p, flattening_threshold)
|
||||
curve.Segment(&p, flatteningThreshold)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ func BenchmarkCubicCurveParabolic(b *testing.B) {
|
|||
for _, curve := range testsCubicFloat64 {
|
||||
p := Path{make([]float64, 0, 32)}
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.ParabolicSegment(&p, flattening_threshold)
|
||||
curve.ParabolicSegment(&p, flatteningThreshold)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ func BenchmarkQuadCurve(b *testing.B) {
|
|||
for _, curve := range testsQuadFloat64 {
|
||||
p := Path{make([]float64, 0, 32)}
|
||||
p.LineTo(curve[0], curve[1])
|
||||
curve.Segment(&p, flattening_threshold)
|
||||
curve.Segment(&p, flatteningThreshold)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/llgcode/draw2d/curve"
|
||||
)
|
||||
|
||||
var flattening_threshold float64 = 0.5
|
||||
var flatteningThreshold = 0.5
|
||||
|
||||
func savepng(filePath string, m image.Image) {
|
||||
f, err := os.Create(filePath)
|
||||
|
@ -55,7 +55,7 @@ func TestFreetype(t *testing.T) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
|
||||
|
@ -81,7 +81,7 @@ func TestFreetypeNonZeroWinding(t *testing.T) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
|
||||
|
@ -108,7 +108,7 @@ func TestRasterizer(t *testing.T) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
tr := [6]float64{1, 0, 0, 1, 0, 0}
|
||||
|
@ -124,7 +124,7 @@ func TestRasterizerNonZeroWinding(t *testing.T) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
tr := [6]float64{1, 0, 0, 1, 0, 0}
|
||||
|
@ -139,7 +139,7 @@ func BenchmarkFreetype(b *testing.B) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
|
||||
|
@ -165,7 +165,7 @@ func BenchmarkFreetypeNonZeroWinding(b *testing.B) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
|
||||
|
@ -191,7 +191,7 @@ func BenchmarkRasterizerNonZeroWinding(b *testing.B) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
tr := [6]float64{1, 0, 0, 1, 0, 0}
|
||||
|
@ -206,7 +206,7 @@ func BenchmarkRasterizer(b *testing.B) {
|
|||
var p Path
|
||||
p.LineTo(10, 190)
|
||||
c := curve.CubicCurveFloat64{10, 190, 10, 10, 190, 10, 190, 190}
|
||||
c.Segment(&p, flattening_threshold)
|
||||
c.Segment(&p, flatteningThreshold)
|
||||
poly := Polygon(p.points)
|
||||
color := color.RGBA{0, 0, 0, 0xff}
|
||||
tr := [6]float64{1, 0, 0, 1, 0, 0}
|
||||
|
|
|
@ -11,11 +11,15 @@ import (
|
|||
"math"
|
||||
)
|
||||
|
||||
// ImageFilter defines sampling filter (linear, bilinear or bicubic)
|
||||
type ImageFilter int
|
||||
|
||||
const (
|
||||
// LinearFilter uses linear interpolation
|
||||
LinearFilter ImageFilter = iota
|
||||
// BilinearFilter uses bilinear interpolation
|
||||
BilinearFilter
|
||||
// BicubicFilter uses bicubic interpolation
|
||||
BicubicFilter
|
||||
)
|
||||
|
||||
|
@ -103,6 +107,7 @@ func cubic(offset, v0, v1, v2, v3 float64) uint32 {
|
|||
(-9*v0+9*v2))*offset + (v0 + 16*v1 + v2)) / 18.0)
|
||||
}
|
||||
|
||||
// DrawImage draws a source image on an destination image.
|
||||
func DrawImage(src image.Image, dest draw.Image, tr MatrixTransform, op draw.Op, filter ImageFilter) {
|
||||
bounds := src.Bounds()
|
||||
x0, y0, x1, y1 := float64(bounds.Min.X), float64(bounds.Min.Y), float64(bounds.Max.X), float64(bounds.Max.Y)
|
||||
|
|
2
test
2
test
|
@ -1,5 +1,5 @@
|
|||
echo golint
|
||||
golint ./... | grep "draw2dpdf\|samples"
|
||||
golint ./... | grep "draw2dpdf\|samples\|^advanced_path\|^arc\|draw2d[.]\|fileutil\|^gc\|math\|^path[.]\|rgba_interpolation\|test\|vertex2d"
|
||||
echo
|
||||
echo go vet
|
||||
go vet ./...
|
||||
|
|
|
@ -3,16 +3,23 @@
|
|||
|
||||
package draw2d
|
||||
|
||||
// VertexCommand defines different commands to describe the vertex of a path.
|
||||
type VertexCommand byte
|
||||
|
||||
const (
|
||||
// VertexNoCommand does nothing
|
||||
VertexNoCommand VertexCommand = iota
|
||||
// VertexStartCommand starts a (sub)path
|
||||
VertexStartCommand
|
||||
// VertexJoinCommand joins the two edges at the vertex
|
||||
VertexJoinCommand
|
||||
// VertexCloseCommand closes the subpath
|
||||
VertexCloseCommand
|
||||
// VertexStopCommand is the endpoint of the path.
|
||||
VertexStopCommand
|
||||
)
|
||||
|
||||
// VertexConverter allows to convert vertices.
|
||||
type VertexConverter interface {
|
||||
NextCommand(cmd VertexCommand)
|
||||
Vertex(x, y float64)
|
||||
|
|
Loading…
Reference in a new issue