Этот коммит содержится в:
Christopher Speller
2017-08-17 17:19:06 -07:00
коммит произвёл GitHub
родитель 2c895ee66e
Коммит 96eab12027
400 изменённых файлов: 45331 добавлений и 11832 удалений

18
vendor/github.com/disintegration/imaging/adjust.go сгенерированный поставляемый
Просмотреть файл

@@ -10,17 +10,17 @@ import (
//
// Example:
//
// dstImage = imaging.AdjustFunc(
// srcImage,
// func(c color.NRGBA) color.NRGBA {
// // shift the red channel by 16
// dstImage = imaging.AdjustFunc(
// srcImage,
// func(c color.NRGBA) color.NRGBA {
// // shift the red channel by 16
// r := int(c.R) + 16
// if r > 255 {
// r = 255
// }
// return color.NRGBA{uint8(r), c.G, c.B, c.A}
// }
// )
// r = 255
// }
// return color.NRGBA{uint8(r), c.G, c.B, c.A}
// }
// )
//
func AdjustFunc(img image.Image, fn func(c color.NRGBA) color.NRGBA) *image.NRGBA {
src := toNRGBA(img)

4
vendor/github.com/disintegration/imaging/effects.go сгенерированный поставляемый
Просмотреть файл

@@ -14,7 +14,7 @@ func gaussianBlurKernel(x, sigma float64) float64 {
//
// Usage example:
//
// dstImage := imaging.Blur(srcImage, 3.5)
// dstImage := imaging.Blur(srcImage, 3.5)
//
func Blur(img image.Image, sigma float64) *image.NRGBA {
if sigma <= 0 {
@@ -138,7 +138,7 @@ func blurVertical(src *image.NRGBA, kernel []float64) *image.NRGBA {
//
// Usage example:
//
// dstImage := imaging.Sharpen(srcImage, 3.5)
// dstImage := imaging.Sharpen(srcImage, 3.5)
//
func Sharpen(img image.Image, sigma float64) *image.NRGBA {
if sigma <= 0 {

8
vendor/github.com/disintegration/imaging/resize.go сгенерированный поставляемый
Просмотреть файл

@@ -59,7 +59,7 @@ func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) [][]indexWei
//
// Usage example:
//
// dstImage := imaging.Resize(srcImage, 800, 600, imaging.Lanczos)
// dstImage := imaging.Resize(srcImage, 800, 600, imaging.Lanczos)
//
func Resize(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
dstW, dstH := width, height
@@ -239,7 +239,7 @@ func resizeNearest(src *image.NRGBA, width, height int) *image.NRGBA {
//
// Usage example:
//
// dstImage := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
// dstImage := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
//
func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
maxW, maxH := width, height
@@ -284,7 +284,7 @@ func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA
//
// Usage example:
//
// dstImage := imaging.Fill(srcImage, 800, 600, imaging.Center, imaging.Lanczos)
// dstImage := imaging.Fill(srcImage, 800, 600, imaging.Center, imaging.Lanczos)
//
func Fill(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA {
minW, minH := width, height
@@ -326,7 +326,7 @@ func Fill(img image.Image, width, height int, anchor Anchor, filter ResampleFilt
//
// Usage example:
//
// dstImage := imaging.Thumbnail(srcImage, 100, 100, imaging.Lanczos)
// dstImage := imaging.Thumbnail(srcImage, 100, 100, imaging.Lanczos)
//
func Thumbnail(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
return Fill(img, width, height, Center, filter)

8
vendor/github.com/disintegration/imaging/tools.go сгенерированный поставляемый
Просмотреть файл

@@ -136,11 +136,11 @@ func PasteCenter(background, img image.Image) *image.NRGBA {
//
// Usage examples:
//
// // draw the sprite over the background at position (50, 50)
// dstImage := imaging.Overlay(backgroundImage, spriteImage, image.Pt(50, 50), 1.0)
// // draw the sprite over the background at position (50, 50)
// dstImage := imaging.Overlay(backgroundImage, spriteImage, image.Pt(50, 50), 1.0)
//
// // blend two opaque images of the same size
// dstImage := imaging.Overlay(imageOne, imageTwo, image.Pt(0, 0), 0.5)
// // blend two opaque images of the same size
// dstImage := imaging.Overlay(imageOne, imageTwo, image.Pt(0, 0), 0.5)
//
func Overlay(background, img image.Image, pos image.Point, opacity float64) *image.NRGBA {
opacity = math.Min(math.Max(opacity, 0.0), 1.0) // check: 0.0 <= opacity <= 1.0

13
vendor/github.com/disintegration/imaging/transform.go сгенерированный поставляемый
Просмотреть файл

@@ -206,6 +206,19 @@ func Rotate270(img image.Image) *image.NRGBA {
// The angle parameter is the rotation angle in degrees.
// The bgColor parameter specifies the color of the uncovered zone after the rotation.
func Rotate(img image.Image, angle float64, bgColor color.Color) *image.NRGBA {
angle = angle - math.Floor(angle/360)*360
switch angle {
case 0:
return Clone(img)
case 90:
return Rotate90(img)
case 180:
return Rotate180(img)
case 270:
return Rotate270(img)
}
src := toNRGBA(img)
srcW := src.Bounds().Max.X
srcH := src.Bounds().Max.Y

164
vendor/github.com/disintegration/imaging/transform_test.go сгенерированный поставляемый
Просмотреть файл

@@ -406,6 +406,170 @@ func TestRotate(t *testing.T) {
},
},
},
{
"Rotate -360*10",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff,
},
},
-360 * 10,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 1, 2),
Stride: 1 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff,
},
},
},
{
"Rotate -360*10 + 90",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff,
},
},
-360*10 + 90,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 2, 1),
Stride: 2 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
},
},
},
{
"Rotate -360*10 + 180",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff,
},
},
-360*10 + 180,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 1, 2),
Stride: 1 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff,
},
},
},
{
"Rotate -360*10 + 270",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff,
},
},
-360*10 + 270,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 2, 1),
Stride: 2 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
},
},
},
{
"Rotate 360*10",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff,
},
},
360 * 10,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 1, 2),
Stride: 1 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff,
},
},
},
{
"Rotate 360*10 + 90",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff,
},
},
360*10 + 90,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 2, 1),
Stride: 2 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
},
},
},
{
"Rotate 360*10 + 180",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff,
},
},
360*10 + 180,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 1, 2),
Stride: 1 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff,
},
},
},
{
"Rotate 360*10 + 270",
&image.NRGBA{
Rect: image.Rect(-1, -1, 0, 1),
Stride: 1 * 4,
Pix: []uint8{
0xff, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff,
},
},
360*10 + 270,
color.Black,
&image.NRGBA{
Rect: image.Rect(0, 0, 2, 1),
Stride: 2 * 4,
Pix: []uint8{
0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
},
},
},
}
for _, test := range testCases {
got := Rotate(test.src, test.angle, test.bg)