func Contrast(percentage float32) Filter {
	if percentage == 0 {
		return &copyimageFilter{}
	}

	p := 1 + minf32(maxf32(percentage, -100), 100)/100

	return &colorchanFilter{
		fn: func(x float32) float32 {
			if 0 <= p && p <= 1 {
				return 0.5 + (x-0.5)*p
			} else if 1 < p && p < 2 {
				return 0.5 + (x-0.5)*(1/(2.0-p))
			} else {
				if x < 0.5 {
					return 0
				}
				return 1
			}
		},
		lut: false,
	}
}
// Contrast creates a filter that changes the contrast of an image.
// The percentage parameter must be in range (-100, 100). The percentage = 0 gives the original image.
// The percentage = -100 gives solid grey image. The percentage = 100 gives an overcontrasted image.
Contrast creates a filter that changes the contrast of an image.
The percentage parameter must be in range (-100, 100). The percentage = 0 gives the original image.
The percentage = -100 gives solid grey image. The percentage = 100 gives an overcontrasted image.
// Contrast creates a filter that changes the contrast of an image . // The percentage parameter must be in range ( - 100 100 ) . The percentage = 0 gives the original image . // The percentage = - 100 gives solid grey image . The percentage = 100 gives an overcontrasted image .
func Contrast(percentage float32) Filter {
	if percentage == 0 {
		return &copyimageFilter{}
	}
	p := 1 + minf32(maxf32(percentage, -100), 100)/100
	return &colorchanFilter{
		fn: func(x float32) float32 {
			if 0 <= p && p <= 1 {
				return 0.5 + (x-0.5)*p
			} else if 1 < p && p < 2 {
				return 0.5 + (x-0.5)*(1/(2.0-p))
			} else {
				if x < 0.5 {
					return 0
				}
				return 1
			}
		},
		lut: false,
	}
}
func Contrast ( percentage float32 ) Filter { if percentage == 0 { return & copyimageFilter { } } p := 1 + minf32 ( maxf32 ( percentage , - 100 ) , 100 ) / 100 return & colorchanFilter { fn : func ( x float32 ) float32 { if 0 <= p && p <= 1 { return 0.5 + ( x - 0.5 ) * p } else if 1 < p && p < 2 { return 0.5 + ( x - 0.5 ) * ( 1 / ( 2.0 - p ) ) } else { if x < 0.5 { return 0 } return 1 } } , lut : false , } }
Contrast creates a filter that changes the contrast of an image.
Contrast creates a filter that changes the contrast of an image .