tests
This commit is contained in:
33
scale_test.go
Normal file
33
scale_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package imageutils
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/potassium5703/texture"
|
||||
)
|
||||
|
||||
func Render(img image.Image, rect image.Rectangle) image.Image {
|
||||
newimg := image.NewRGBA(rect)
|
||||
draw.Draw(newimg, rect, image.White, image.ZP, draw.Src)
|
||||
draw.Draw(newimg, rect, img, image.ZP, draw.Over)
|
||||
return newimg
|
||||
}
|
||||
|
||||
func BenchmarkScale(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
err := png.Encode(io.Discard,
|
||||
Scale(Render(
|
||||
texture.New(color.White, color.Black, 2),
|
||||
image.Rect(0, 0, 32, 32),
|
||||
), 32),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user