Bläddra i källkod

Change function name to "AdjustHues"

Changes the name of "AdjustHue" to "AdjustHues" which appears to be the proper term when talking about an entire image (instead of one individual color).
StruffelProductions 5 år sedan
förälder
incheckning
083d3988dd
7 ändrade filer med 21 tillägg och 21 borttagningar
  1. 2 2
      README.md
  2. 4 4
      adjust.go
  3. 15 15
      adjust_test.go
  4. 0 0
      testdata/out_hues_m120.png
  5. 0 0
      testdata/out_hues_m60.png
  6. 0 0
      testdata/out_hues_p120.png
  7. 0 0
      testdata/out_hues_p60.png

+ 2 - 2
README.md

@@ -132,12 +132,12 @@ Original image                     | Saturation = 30
 ### Hue adjustment
 ### Hue adjustment
 
 
 ```go
 ```go
-dstImage := imaging.AdjustHue(srcImage, 20)
+dstImage := imaging.AdjustHues(srcImage, 20)
 ```
 ```
 
 
 Original image                     | Hue = 60                                     | Hue = -60
 Original image                     | Hue = 60                                     | Hue = -60
 -----------------------------------|----------------------------------------------|---------------------------------------------
 -----------------------------------|----------------------------------------------|---------------------------------------------
-![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_hue_p60.png) | ![dstImage](testdata/out_hue_m60.png)
+![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_hues_p60.png) | ![dstImage](testdata/out_hues_m60.png)
 
 
 ## FAQ
 ## FAQ
 
 

+ 4 - 4
adjust.go

@@ -80,16 +80,16 @@ func AdjustSaturation(img image.Image, percentage float64) *image.NRGBA {
 	})
 	})
 }
 }
 
 
-// AdjustHue changes the hue of the image using the shift parameter (measued in degrees) and returns the adjusted image.
+// AdjustHues changes the hue of the image using the shift parameter (measured in degrees) and returns the adjusted image.
 // The shift must be in the range (-180, 180).
 // The shift must be in the range (-180, 180).
 // The shift = 0 gives the original image.
 // The shift = 0 gives the original image.
 // The shift = 180 (or -180) corresponds to a 180° degree rotation of the color wheel and thus gives the image with its hue inverted for each pixel.
 // The shift = 180 (or -180) corresponds to a 180° degree rotation of the color wheel and thus gives the image with its hue inverted for each pixel.
 //
 //
 // Examples:
 // Examples:
-//  dstImage = imaging.AdjustHue(srcImage, 90) // Shift Hue by 90°.
-//  dstImage = imaging.AdjustHue(srcImage, -30) // Shift Hue by -30°.
+//  dstImage = imaging.AdjustHues(srcImage, 90) // Shift Hue by 90°.
+//  dstImage = imaging.AdjustHues(srcImage, -30) // Shift Hue by -30°.
 //
 //
-func AdjustHue(img image.Image, shift float64) *image.NRGBA {
+func AdjustHues(img image.Image, shift float64) *image.NRGBA {
 	if shift == 0 {
 	if shift == 0 {
 		return Clone(img)
 		return Clone(img)
 	}
 	}

+ 15 - 15
adjust_test.go

@@ -247,7 +247,7 @@ func BenchmarkAdjustSaturation(b *testing.B) {
 	}
 	}
 }
 }
 
 
-func TestAdjustHue(t *testing.T) {
+func TestAdjustHues(t *testing.T) {
 	testCases := []struct {
 	testCases := []struct {
 		name string
 		name string
 		src  image.Image
 		src  image.Image
@@ -255,7 +255,7 @@ func TestAdjustHue(t *testing.T) {
 		want *image.NRGBA
 		want *image.NRGBA
 	}{
 	}{
 		{
 		{
-			"AdjustHue 3x3 10",
+			"AdjustHues 3x3 10",
 			&image.NRGBA{
 			&image.NRGBA{
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Stride: 3 * 4,
 				Stride: 3 * 4,
@@ -277,7 +277,7 @@ func TestAdjustHue(t *testing.T) {
 			},
 			},
 		},
 		},
 		{
 		{
-			"AdjustHue 3x3 180",
+			"AdjustHues 3x3 180",
 			&image.NRGBA{
 			&image.NRGBA{
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Stride: 3 * 4,
 				Stride: 3 * 4,
@@ -299,7 +299,7 @@ func TestAdjustHue(t *testing.T) {
 			},
 			},
 		},
 		},
 		{
 		{
-			"AdjustHue 3x3 -10",
+			"AdjustHues 3x3 -10",
 			&image.NRGBA{
 			&image.NRGBA{
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Stride: 3 * 4,
 				Stride: 3 * 4,
@@ -321,7 +321,7 @@ func TestAdjustHue(t *testing.T) {
 			},
 			},
 		},
 		},
 		{
 		{
-			"AdjustHue 3x3 -180",
+			"AdjustHues 3x3 -180",
 			&image.NRGBA{
 			&image.NRGBA{
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Stride: 3 * 4,
 				Stride: 3 * 4,
@@ -343,7 +343,7 @@ func TestAdjustHue(t *testing.T) {
 			},
 			},
 		},
 		},
 		{
 		{
-			"AdjustHue 3x3 0",
+			"AdjustHues 3x3 0",
 			&image.NRGBA{
 			&image.NRGBA{
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Rect:   image.Rect(-1, -1, 2, 2),
 				Stride: 3 * 4,
 				Stride: 3 * 4,
@@ -367,7 +367,7 @@ func TestAdjustHue(t *testing.T) {
 	}
 	}
 	for _, tc := range testCases {
 	for _, tc := range testCases {
 		t.Run(tc.name, func(t *testing.T) {
 		t.Run(tc.name, func(t *testing.T) {
-			got := AdjustHue(tc.src, tc.p)
+			got := AdjustHues(tc.src, tc.p)
 			if !compareNRGBA(got, tc.want, 0) {
 			if !compareNRGBA(got, tc.want, 0) {
 				t.Fatalf("got result %#v want %#v", got, tc.want)
 				t.Fatalf("got result %#v want %#v", got, tc.want)
 			}
 			}
@@ -375,14 +375,14 @@ func TestAdjustHue(t *testing.T) {
 	}
 	}
 }
 }
 
 
-func TestAdjustHueGolden(t *testing.T) {
+func TestAdjustHuesGolden(t *testing.T) {
 	for name, p := range map[string]float64{
 	for name, p := range map[string]float64{
-		"out_hue_m120.png": -120,
-		"out_hue_m60.png":  -60,
-		"out_hue_p60.png":  60,
-		"out_hue_p120.png": 120,
+		"out_hues_m120.png": -120,
+		"out_hues_m60.png":  -60,
+		"out_hues_p60.png":  60,
+		"out_hues_p120.png": 120,
 	} {
 	} {
-		got := AdjustHue(testdataFlowersSmallPNG, p)
+		got := AdjustHues(testdataFlowersSmallPNG, p)
 		want, err := Open("testdata/" + name)
 		want, err := Open("testdata/" + name)
 		if err != nil {
 		if err != nil {
 			t.Fatalf("failed to open image: %v", err)
 			t.Fatalf("failed to open image: %v", err)
@@ -393,10 +393,10 @@ func TestAdjustHueGolden(t *testing.T) {
 	}
 	}
 }
 }
 
 
-func BenchmarkAdjustHue(b *testing.B) {
+func BenchmarkAdjustHues(b *testing.B) {
 	b.ReportAllocs()
 	b.ReportAllocs()
 	for i := 0; i < b.N; i++ {
 	for i := 0; i < b.N; i++ {
-		AdjustHue(testdataBranchesJPG, 10)
+		AdjustHues(testdataBranchesJPG, 10)
 	}
 	}
 }
 }
 
 

+ 0 - 0
testdata/out_hue_m120.png → testdata/out_hues_m120.png


+ 0 - 0
testdata/out_hue_m60.png → testdata/out_hues_m60.png


+ 0 - 0
testdata/out_hue_p120.png → testdata/out_hues_p120.png


+ 0 - 0
testdata/out_hue_p60.png → testdata/out_hues_p60.png