@@ -41,6 +41,8 @@ public class ColorWheel extends ParametrizedFilter {
41
41
@ Serial
42
42
private static final long serialVersionUID = -8398979151631397821L ;
43
43
44
+ private static final double SPIRAL_EFFECT_SCALE = 0.0005 ;
45
+
44
46
public enum ColorSpaceType {
45
47
HSB {
46
48
@ Override
@@ -65,11 +67,13 @@ int toRGB(float hue, float sat, float bri) {
65
67
private final AngleParam hueRotParam = new AngleParam ("Rotate" , 0 );
66
68
private final RangeParam brgLumParam = new RangeParam ("Brightness (%)" , 0 , 75 , 100 );
67
69
private final RangeParam satParam = new RangeParam ("Saturation (%)" , 0 , 90 , 100 );
70
+ private final RangeParam spiralParam = new RangeParam ("Spiral" , -100 , 0 , 100 );
68
71
69
72
public ColorWheel () {
70
73
super (false );
71
74
72
- setParams (type , center , hueRotParam , brgLumParam , satParam );
75
+ setParams (type , center ,
76
+ hueRotParam , brgLumParam , satParam , spiralParam );
73
77
}
74
78
75
79
@ Override
@@ -88,13 +92,15 @@ public BufferedImage transform(BufferedImage src, BufferedImage dest) {
88
92
double sat = satParam .getPercentage ();
89
93
double brgLum = brgLumParam .getPercentage ();
90
94
95
+ double spiral = spiralParam .getValueAsDouble ();
96
+
91
97
var pt = new StatusBarProgressTracker (NAME , height );
92
98
93
99
Future <?>[] rowFutures = new Future [height ];
94
100
for (int y = 0 ; y < height ; y ++) {
95
101
int finalY = y ;
96
102
Runnable rowTask = () -> processRow (
97
- destPixels , width , finalY , cx , cy , hueRot , sat , brgLum , space );
103
+ destPixels , width , finalY , cx , cy , hueRot , sat , brgLum , space , spiral );
98
104
rowFutures [y ] = ThreadPool .submit (rowTask );
99
105
}
100
106
ThreadPool .waitFor (rowFutures , pt );
@@ -105,11 +111,19 @@ public BufferedImage transform(BufferedImage src, BufferedImage dest) {
105
111
106
112
private static void processRow (int [] destPixels , int width , int y ,
107
113
double cx , double cy , double hueRot ,
108
- double saturation , double brightness , ColorSpaceType model ) {
114
+ double saturation , double brightness ,
115
+ ColorSpaceType model , double spiral ) {
109
116
for (int x = 0 ; x < width ; x ++) {
110
117
double yDiff = cy - y ;
111
118
double xDiff = x - cx ;
112
- double angle = FastMath .atan2 (yDiff , xDiff ) + hueRot ;
119
+ double baseAngle = FastMath .atan2 (yDiff , xDiff );
120
+ double angle = baseAngle + hueRot ;
121
+ if (spiral != 0.0 ) {
122
+ double radius = FastMath .hypot (xDiff , yDiff );
123
+ double spiralAngleOffset = spiral * radius * SPIRAL_EFFECT_SCALE ;
124
+ angle += spiralAngleOffset ;
125
+ }
126
+
113
127
double hue = angle / (2 * Math .PI );
114
128
115
129
destPixels [x + y * width ] = model .toRGB ((float ) hue , (float ) saturation , (float ) brightness );
0 commit comments