Forráskód Böngészése

Rename "AdjustHues" to "AdjustHue"

Renames the function "AdjustHues" to "AdjustHue" (along with the tests, documentation and sample files).
StruffelProductions 4 éve
szülő
commit
84be08e612
7 módosított fájl, 21 hozzáadás és 21 törlés
  1. 2 2
      README.md
  2. 4 4
      adjust.go
  3. 15 15
      adjust_test.go
  4. 0 0
      testdata/out_hue_m120.png
  5. 0 0
      testdata/out_hue_m60.png
  6. 0 0
      testdata/out_hue_p120.png
  7. 0 0
      testdata/out_hue_p60.png

+ 2 - 2
README.md

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

+ 4 - 4
adjust.go

@@ -80,16 +80,16 @@ func AdjustSaturation(img image.Image, percentage float64) *image.NRGBA {
 	})
 }
 
-// AdjustHues changes the hue of the image using the shift parameter (measured in degrees) and returns the adjusted image.
+// AdjustHue 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 = 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.
 //
 // Examples:
-//  dstImage = imaging.AdjustHues(srcImage, 90) // Shift Hue by 90°.
-//  dstImage = imaging.AdjustHues(srcImage, -30) // Shift Hue by -30°.
+//  dstImage = imaging.AdjustHue(srcImage, 90) // Shift Hue by 90°.
+//  dstImage = imaging.AdjustHue(srcImage, -30) // Shift Hue by -30°.
 //
-func AdjustHues(img image.Image, shift float64) *image.NRGBA {
+func AdjustHue(img image.Image, shift float64) *image.NRGBA {
 	if shift == 0 {
 		return Clone(img)
 	}

+ 15 - 15
adjust_test.go

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

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


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


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


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