propane 3.10.0-java → 3.11.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +2 -0
- data/README.md +7 -7
- data/lib/propane/app.rb +2 -5
- data/lib/propane/helper_methods.rb +6 -6
- data/lib/propane/version.rb +1 -1
- data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
- data/pom.rb +6 -6
- data/pom.xml +6 -6
- data/propane.gemspec +3 -3
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
- data/src/main/java/processing/awt/PImageAWT.java +6 -4
- data/src/main/java/processing/core/PApplet.java +71 -59
- data/src/main/java/processing/core/PImage.java +14 -14
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
- data/src/main/java/processing/opengl/PShader.java +1 -6
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
- data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
- data/test/test_helper.rb +1 -0
- data/vendors/Rakefile +1 -1
- metadata +29 -155
- data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
- data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/lib/java/monkstone/ColorUtil.java +0 -127
- data/lib/java/monkstone/MathToolModule.java +0 -287
- data/lib/java/monkstone/PropaneLibrary.java +0 -46
- data/lib/java/monkstone/core/LibraryProxy.java +0 -136
- data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
- data/lib/java/monkstone/fastmath/Deglut.java +0 -71
- data/lib/java/monkstone/fastmath/package-info.java +0 -6
- data/lib/java/monkstone/filechooser/Chooser.java +0 -39
- data/lib/java/monkstone/noise/FastTerrain.java +0 -874
- data/lib/java/monkstone/noise/Noise.java +0 -90
- data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
- data/lib/java/monkstone/noise/NoiseMode.java +0 -28
- data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
- data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
- data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
- data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
- data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
- data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
- data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
- data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
- data/lib/java/monkstone/slider/Slider.java +0 -61
- data/lib/java/monkstone/slider/SliderBar.java +0 -245
- data/lib/java/monkstone/slider/SliderGroup.java +0 -56
- data/lib/java/monkstone/slider/WheelHandler.java +0 -35
- data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
- data/lib/java/monkstone/vecmath/JRender.java +0 -56
- data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
- data/lib/java/monkstone/vecmath/package-info.java +0 -20
- data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
- data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
- data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
- data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
- data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
- data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
- data/lib/java/monkstone/videoevent/package-info.java +0 -20
- data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
- data/lib/java/processing/awt/PImageAWT.java +0 -377
- data/lib/java/processing/awt/PShapeJava2D.java +0 -387
- data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
- data/lib/java/processing/awt/ShimAWT.java +0 -581
- data/lib/java/processing/core/PApplet.java +0 -15156
- data/lib/java/processing/core/PConstants.java +0 -523
- data/lib/java/processing/core/PFont.java +0 -1126
- data/lib/java/processing/core/PGraphics.java +0 -8600
- data/lib/java/processing/core/PImage.java +0 -3377
- data/lib/java/processing/core/PMatrix.java +0 -208
- data/lib/java/processing/core/PMatrix2D.java +0 -562
- data/lib/java/processing/core/PMatrix3D.java +0 -890
- data/lib/java/processing/core/PShape.java +0 -3561
- data/lib/java/processing/core/PShapeOBJ.java +0 -483
- data/lib/java/processing/core/PShapeSVG.java +0 -2016
- data/lib/java/processing/core/PStyle.java +0 -63
- data/lib/java/processing/core/PSurface.java +0 -198
- data/lib/java/processing/core/PSurfaceNone.java +0 -431
- data/lib/java/processing/core/PVector.java +0 -1066
- data/lib/java/processing/core/ThinkDifferent.java +0 -115
- data/lib/java/processing/data/DoubleDict.java +0 -850
- data/lib/java/processing/data/DoubleList.java +0 -928
- data/lib/java/processing/data/FloatDict.java +0 -847
- data/lib/java/processing/data/FloatList.java +0 -936
- data/lib/java/processing/data/IntDict.java +0 -807
- data/lib/java/processing/data/IntList.java +0 -936
- data/lib/java/processing/data/JSONArray.java +0 -1260
- data/lib/java/processing/data/JSONObject.java +0 -2282
- data/lib/java/processing/data/JSONTokener.java +0 -435
- data/lib/java/processing/data/LongDict.java +0 -802
- data/lib/java/processing/data/LongList.java +0 -937
- data/lib/java/processing/data/Sort.java +0 -46
- data/lib/java/processing/data/StringDict.java +0 -613
- data/lib/java/processing/data/StringList.java +0 -800
- data/lib/java/processing/data/Table.java +0 -4936
- data/lib/java/processing/data/TableRow.java +0 -198
- data/lib/java/processing/data/XML.java +0 -1156
- data/lib/java/processing/dxf/RawDXF.java +0 -404
- data/lib/java/processing/event/Event.java +0 -125
- data/lib/java/processing/event/KeyEvent.java +0 -70
- data/lib/java/processing/event/MouseEvent.java +0 -114
- data/lib/java/processing/event/TouchEvent.java +0 -57
- data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
- data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
- data/lib/java/processing/net/Client.java +0 -744
- data/lib/java/processing/net/Server.java +0 -388
- data/lib/java/processing/opengl/FontTexture.java +0 -378
- data/lib/java/processing/opengl/FrameBuffer.java +0 -513
- data/lib/java/processing/opengl/LinePath.java +0 -627
- data/lib/java/processing/opengl/LineStroker.java +0 -681
- data/lib/java/processing/opengl/PGL.java +0 -3483
- data/lib/java/processing/opengl/PGraphics2D.java +0 -615
- data/lib/java/processing/opengl/PGraphics3D.java +0 -281
- data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
- data/lib/java/processing/opengl/PJOGL.java +0 -2008
- data/lib/java/processing/opengl/PShader.java +0 -1484
- data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
- data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
- data/lib/java/processing/opengl/Texture.java +0 -1696
- data/lib/java/processing/opengl/VertexBuffer.java +0 -88
- data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
- data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
- data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
- data/src/main/java/processing/opengl/cursors/cross.png +0 -0
- data/src/main/java/processing/opengl/cursors/hand.png +0 -0
- data/src/main/java/processing/opengl/cursors/license.txt +0 -27
- data/src/main/java/processing/opengl/cursors/move.png +0 -0
- data/src/main/java/processing/opengl/cursors/text.png +0 -0
- data/src/main/java/processing/opengl/cursors/wait.png +0 -0
- data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
- data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
- data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
- data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
- data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
- data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
- data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
- data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
- data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
- data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
- data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
- data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
- data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,387 +0,0 @@
|
|
1
|
-
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
/*
|
4
|
-
Part of the Processing project - http://processing.org
|
5
|
-
|
6
|
-
Copyright (c) 2015 The Processing Foundation
|
7
|
-
|
8
|
-
This library is free software; you can redistribute it and/or
|
9
|
-
modify it under the terms of the GNU Lesser General Public
|
10
|
-
License version 2.1 as published by the Free Software Foundation.
|
11
|
-
|
12
|
-
This library is distributed in the hope that it will be useful,
|
13
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
-
Lesser General Public License for more details.
|
16
|
-
|
17
|
-
You should have received a copy of the GNU Lesser General
|
18
|
-
Public License along with this library; if not, write to the
|
19
|
-
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
|
-
Boston, MA 02111-1307 USA
|
21
|
-
*/
|
22
|
-
|
23
|
-
package processing.awt;
|
24
|
-
|
25
|
-
import java.awt.Paint;
|
26
|
-
import java.awt.PaintContext;
|
27
|
-
import java.awt.Rectangle;
|
28
|
-
import java.awt.RenderingHints;
|
29
|
-
import java.awt.geom.AffineTransform;
|
30
|
-
import java.awt.geom.Point2D;
|
31
|
-
import java.awt.geom.Rectangle2D;
|
32
|
-
import java.awt.image.ColorModel;
|
33
|
-
import java.awt.image.Raster;
|
34
|
-
import java.awt.image.WritableRaster;
|
35
|
-
|
36
|
-
import processing.core.PApplet;
|
37
|
-
import processing.core.PGraphics;
|
38
|
-
import processing.core.PShapeSVG;
|
39
|
-
import processing.data.*;
|
40
|
-
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Implements features for PShape that are specific to AWT and Java2D.
|
44
|
-
* At the moment, this is gradients and java.awt.Paint handling.
|
45
|
-
*/
|
46
|
-
public class PShapeJava2D extends PShapeSVG {
|
47
|
-
Paint strokeGradientPaint;
|
48
|
-
Paint fillGradientPaint;
|
49
|
-
|
50
|
-
|
51
|
-
public PShapeJava2D(XML svg) {
|
52
|
-
super(svg);
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
public PShapeJava2D(PShapeSVG parent, XML properties, boolean parseKids) {
|
57
|
-
super(parent, properties, parseKids);
|
58
|
-
}
|
59
|
-
|
60
|
-
|
61
|
-
@Override
|
62
|
-
protected void setParent(PShapeSVG parent) {
|
63
|
-
super.setParent(parent);
|
64
|
-
|
65
|
-
if (parent instanceof PShapeJava2D) {
|
66
|
-
PShapeJava2D pj = (PShapeJava2D) parent;
|
67
|
-
fillGradientPaint = pj.fillGradientPaint;
|
68
|
-
strokeGradientPaint = pj.strokeGradientPaint;
|
69
|
-
|
70
|
-
} else { // parent is null or not Java2D
|
71
|
-
fillGradientPaint = null;
|
72
|
-
strokeGradientPaint = null;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
/** Factory method for subclasses. */
|
78
|
-
@Override
|
79
|
-
protected PShapeSVG createShape(PShapeSVG parent, XML properties, boolean parseKids) {
|
80
|
-
return new PShapeJava2D(parent, properties, parseKids);
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
/*
|
85
|
-
@Override
|
86
|
-
public void setColor(String colorText, boolean isFill) {
|
87
|
-
super.setColor(colorText, isFill);
|
88
|
-
|
89
|
-
if (fillGradient != null) {
|
90
|
-
fillGradientPaint = calcGradientPaint(fillGradient);
|
91
|
-
}
|
92
|
-
if (strokeGradient != null) {
|
93
|
-
strokeGradientPaint = calcGradientPaint(strokeGradient);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
*/
|
97
|
-
|
98
|
-
|
99
|
-
static class LinearGradientPaint implements Paint {
|
100
|
-
float x1, y1, x2, y2;
|
101
|
-
float[] offset;
|
102
|
-
int[] color;
|
103
|
-
int count;
|
104
|
-
float opacity;
|
105
|
-
|
106
|
-
public LinearGradientPaint(float x1, float y1, float x2, float y2,
|
107
|
-
float[] offset, int[] color, int count,
|
108
|
-
float opacity) {
|
109
|
-
this.x1 = x1;
|
110
|
-
this.y1 = y1;
|
111
|
-
this.x2 = x2;
|
112
|
-
this.y2 = y2;
|
113
|
-
this.offset = offset;
|
114
|
-
this.color = color;
|
115
|
-
this.count = count;
|
116
|
-
this.opacity = opacity;
|
117
|
-
}
|
118
|
-
|
119
|
-
@Override
|
120
|
-
public PaintContext createContext(ColorModel cm,
|
121
|
-
Rectangle deviceBounds, Rectangle2D userBounds,
|
122
|
-
AffineTransform xform, RenderingHints hints) {
|
123
|
-
Point2D t1 = xform.transform(new Point2D.Float(x1, y1), null);
|
124
|
-
Point2D t2 = xform.transform(new Point2D.Float(x2, y2), null);
|
125
|
-
return new LinearGradientContext((float) t1.getX(), (float) t1.getY(),
|
126
|
-
(float) t2.getX(), (float) t2.getY());
|
127
|
-
}
|
128
|
-
|
129
|
-
@Override
|
130
|
-
public int getTransparency() {
|
131
|
-
return TRANSLUCENT; // why not.. rather than checking each color
|
132
|
-
}
|
133
|
-
|
134
|
-
public class LinearGradientContext implements PaintContext {
|
135
|
-
int ACCURACY = 2;
|
136
|
-
float tx1, ty1, tx2, ty2;
|
137
|
-
|
138
|
-
public LinearGradientContext(float tx1, float ty1, float tx2, float ty2) {
|
139
|
-
this.tx1 = tx1;
|
140
|
-
this.ty1 = ty1;
|
141
|
-
this.tx2 = tx2;
|
142
|
-
this.ty2 = ty2;
|
143
|
-
}
|
144
|
-
|
145
|
-
@Override
|
146
|
-
public void dispose() { }
|
147
|
-
|
148
|
-
@Override
|
149
|
-
public ColorModel getColorModel() { return ColorModel.getRGBdefault(); }
|
150
|
-
|
151
|
-
@Override
|
152
|
-
public Raster getRaster(int x, int y, int w, int h) {
|
153
|
-
WritableRaster raster =
|
154
|
-
getColorModel().createCompatibleWritableRaster(w, h);
|
155
|
-
|
156
|
-
int[] data = new int[w * h * 4];
|
157
|
-
|
158
|
-
// make normalized version of base vector
|
159
|
-
float nx = tx2 - tx1;
|
160
|
-
float ny = ty2 - ty1;
|
161
|
-
float len = (float) Math.sqrt(nx*nx + ny*ny);
|
162
|
-
if (len != 0) {
|
163
|
-
nx /= len;
|
164
|
-
ny /= len;
|
165
|
-
}
|
166
|
-
|
167
|
-
int span = (int) PApplet.dist(tx1, ty1, tx2, ty2) * ACCURACY;
|
168
|
-
if (span <= 0) {
|
169
|
-
//System.err.println("span is too small");
|
170
|
-
// annoying edge case where the gradient isn't legit
|
171
|
-
int index = 0;
|
172
|
-
for (int j = 0; j < h; j++) {
|
173
|
-
for (int i = 0; i < w; i++) {
|
174
|
-
data[index++] = 0;
|
175
|
-
data[index++] = 0;
|
176
|
-
data[index++] = 0;
|
177
|
-
data[index++] = 255;
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
} else {
|
182
|
-
int[][] interp = new int[span][4];
|
183
|
-
int prev = 0;
|
184
|
-
for (int i = 1; i < count; i++) {
|
185
|
-
int c0 = color[i-1];
|
186
|
-
int c1 = color[i];
|
187
|
-
int last = (int) (offset[i] * (span-1));
|
188
|
-
//System.out.println("last is " + last);
|
189
|
-
for (int j = prev; j <= last; j++) {
|
190
|
-
float btwn = PApplet.norm(j, prev, last);
|
191
|
-
interp[j][0] = (int) PApplet.lerp((c0 >> 16) & 0xff, (c1 >> 16) & 0xff, btwn);
|
192
|
-
interp[j][1] = (int) PApplet.lerp((c0 >> 8) & 0xff, (c1 >> 8) & 0xff, btwn);
|
193
|
-
interp[j][2] = (int) PApplet.lerp(c0 & 0xff, c1 & 0xff, btwn);
|
194
|
-
interp[j][3] = (int) (PApplet.lerp((c0 >> 24) & 0xff, (c1 >> 24) & 0xff, btwn) * opacity);
|
195
|
-
//System.out.println(j + " " + interp[j][0] + " " + interp[j][1] + " " + interp[j][2]);
|
196
|
-
}
|
197
|
-
prev = last;
|
198
|
-
}
|
199
|
-
|
200
|
-
int index = 0;
|
201
|
-
for (int j = 0; j < h; j++) {
|
202
|
-
for (int i = 0; i < w; i++) {
|
203
|
-
//float distance = 0; //PApplet.dist(cx, cy, x + i, y + j);
|
204
|
-
//int which = PApplet.min((int) (distance * ACCURACY), interp.length-1);
|
205
|
-
float px = (x + i) - tx1;
|
206
|
-
float py = (y + j) - ty1;
|
207
|
-
// distance up the line is the dot product of the normalized
|
208
|
-
// vector of the gradient start/stop by the point being tested
|
209
|
-
int which = (int) ((px*nx + py*ny) * ACCURACY);
|
210
|
-
if (which < 0) which = 0;
|
211
|
-
if (which > interp.length-1) which = interp.length-1;
|
212
|
-
//if (which > 138) System.out.println("grabbing " + which);
|
213
|
-
|
214
|
-
data[index++] = interp[which][0];
|
215
|
-
data[index++] = interp[which][1];
|
216
|
-
data[index++] = interp[which][2];
|
217
|
-
data[index++] = interp[which][3];
|
218
|
-
}
|
219
|
-
}
|
220
|
-
}
|
221
|
-
raster.setPixels(0, 0, w, h, data);
|
222
|
-
|
223
|
-
return raster;
|
224
|
-
}
|
225
|
-
}
|
226
|
-
}
|
227
|
-
|
228
|
-
|
229
|
-
static class RadialGradientPaint implements Paint {
|
230
|
-
float cx, cy, radius;
|
231
|
-
float[] offset;
|
232
|
-
int[] color;
|
233
|
-
int count;
|
234
|
-
float opacity;
|
235
|
-
|
236
|
-
public RadialGradientPaint(float cx, float cy, float radius,
|
237
|
-
float[] offset, int[] color, int count,
|
238
|
-
float opacity) {
|
239
|
-
this.cx = cx;
|
240
|
-
this.cy = cy;
|
241
|
-
this.radius = radius;
|
242
|
-
this.offset = offset;
|
243
|
-
this.color = color;
|
244
|
-
this.count = count;
|
245
|
-
this.opacity = opacity;
|
246
|
-
}
|
247
|
-
|
248
|
-
@Override
|
249
|
-
public PaintContext createContext(ColorModel cm,
|
250
|
-
Rectangle deviceBounds, Rectangle2D userBounds,
|
251
|
-
AffineTransform xform, RenderingHints hints) {
|
252
|
-
return new RadialGradientContext();
|
253
|
-
}
|
254
|
-
|
255
|
-
@Override
|
256
|
-
public int getTransparency() {
|
257
|
-
return TRANSLUCENT;
|
258
|
-
}
|
259
|
-
|
260
|
-
public class RadialGradientContext implements PaintContext {
|
261
|
-
int ACCURACY = 5;
|
262
|
-
|
263
|
-
@Override
|
264
|
-
public void dispose() {}
|
265
|
-
|
266
|
-
@Override
|
267
|
-
public ColorModel getColorModel() { return ColorModel.getRGBdefault(); }
|
268
|
-
|
269
|
-
@Override
|
270
|
-
public Raster getRaster(int x, int y, int w, int h) {
|
271
|
-
WritableRaster raster =
|
272
|
-
getColorModel().createCompatibleWritableRaster(w, h);
|
273
|
-
|
274
|
-
int span = (int) radius * ACCURACY;
|
275
|
-
int[][] interp = new int[span][4];
|
276
|
-
int prev = 0;
|
277
|
-
for (int i = 1; i < count; i++) {
|
278
|
-
int c0 = color[i-1];
|
279
|
-
int c1 = color[i];
|
280
|
-
int last = (int) (offset[i] * (span - 1));
|
281
|
-
for (int j = prev; j <= last; j++) {
|
282
|
-
float btwn = PApplet.norm(j, prev, last);
|
283
|
-
interp[j][0] = (int) PApplet.lerp((c0 >> 16) & 0xff, (c1 >> 16) & 0xff, btwn);
|
284
|
-
interp[j][1] = (int) PApplet.lerp((c0 >> 8) & 0xff, (c1 >> 8) & 0xff, btwn);
|
285
|
-
interp[j][2] = (int) PApplet.lerp(c0 & 0xff, c1 & 0xff, btwn);
|
286
|
-
interp[j][3] = (int) (PApplet.lerp((c0 >> 24) & 0xff, (c1 >> 24) & 0xff, btwn) * opacity);
|
287
|
-
}
|
288
|
-
prev = last;
|
289
|
-
}
|
290
|
-
|
291
|
-
int[] data = new int[w * h * 4];
|
292
|
-
int index = 0;
|
293
|
-
for (int j = 0; j < h; j++) {
|
294
|
-
for (int i = 0; i < w; i++) {
|
295
|
-
float distance = PApplet.dist(cx, cy, x + i, y + j);
|
296
|
-
int which = PApplet.min((int) (distance * ACCURACY), interp.length-1);
|
297
|
-
|
298
|
-
data[index++] = interp[which][0];
|
299
|
-
data[index++] = interp[which][1];
|
300
|
-
data[index++] = interp[which][2];
|
301
|
-
data[index++] = interp[which][3];
|
302
|
-
}
|
303
|
-
}
|
304
|
-
raster.setPixels(0, 0, w, h, data);
|
305
|
-
|
306
|
-
return raster;
|
307
|
-
}
|
308
|
-
}
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
protected Paint calcGradientPaint(Gradient gradient) {
|
313
|
-
if (gradient instanceof LinearGradient) {
|
314
|
-
// System.out.println("creating linear gradient");
|
315
|
-
LinearGradient grad = (LinearGradient) gradient;
|
316
|
-
return new LinearGradientPaint(grad.x1, grad.y1, grad.x2, grad.y2,
|
317
|
-
grad.offset, grad.color, grad.count,
|
318
|
-
opacity);
|
319
|
-
|
320
|
-
} else if (gradient instanceof RadialGradient) {
|
321
|
-
// System.out.println("creating radial gradient");
|
322
|
-
RadialGradient grad = (RadialGradient) gradient;
|
323
|
-
return new RadialGradientPaint(grad.cx, grad.cy, grad.r,
|
324
|
-
grad.offset, grad.color, grad.count,
|
325
|
-
opacity);
|
326
|
-
}
|
327
|
-
return null;
|
328
|
-
}
|
329
|
-
|
330
|
-
|
331
|
-
// protected Paint calcGradientPaint(Gradient gradient,
|
332
|
-
// float x1, float y1, float x2, float y2) {
|
333
|
-
// if (gradient instanceof LinearGradient) {
|
334
|
-
// LinearGradient grad = (LinearGradient) gradient;
|
335
|
-
// return new LinearGradientPaint(x1, y1, x2, y2,
|
336
|
-
// grad.offset, grad.color, grad.count,
|
337
|
-
// opacity);
|
338
|
-
// }
|
339
|
-
// throw new RuntimeException("Not a linear gradient.");
|
340
|
-
// }
|
341
|
-
|
342
|
-
|
343
|
-
// protected Paint calcGradientPaint(Gradient gradient,
|
344
|
-
// float cx, float cy, float r) {
|
345
|
-
// if (gradient instanceof RadialGradient) {
|
346
|
-
// RadialGradient grad = (RadialGradient) gradient;
|
347
|
-
// return new RadialGradientPaint(cx, cy, r,
|
348
|
-
// grad.offset, grad.color, grad.count,
|
349
|
-
// opacity);
|
350
|
-
// }
|
351
|
-
// throw new RuntimeException("Not a radial gradient.");
|
352
|
-
// }
|
353
|
-
|
354
|
-
|
355
|
-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
356
|
-
|
357
|
-
|
358
|
-
@Override
|
359
|
-
protected void styles(PGraphics g) {
|
360
|
-
super.styles(g);
|
361
|
-
|
362
|
-
//if (g instanceof PGraphicsJava2D) {
|
363
|
-
PGraphicsJava2D p2d = (PGraphicsJava2D) g;
|
364
|
-
|
365
|
-
if (strokeGradient != null) {
|
366
|
-
p2d.strokeGradient = true;
|
367
|
-
if (strokeGradientPaint == null) {
|
368
|
-
strokeGradientPaint = calcGradientPaint(strokeGradient);
|
369
|
-
}
|
370
|
-
p2d.strokeGradientObject = strokeGradientPaint;
|
371
|
-
} else {
|
372
|
-
// need to shut off, in case parent object has a gradient applied
|
373
|
-
//p2d.strokeGradient = false;
|
374
|
-
}
|
375
|
-
if (fillGradient != null) {
|
376
|
-
p2d.fillGradient = true;
|
377
|
-
if (fillGradientPaint == null) {
|
378
|
-
fillGradientPaint = calcGradientPaint(fillGradient);
|
379
|
-
}
|
380
|
-
p2d.fillGradientObject = fillGradientPaint;
|
381
|
-
} else {
|
382
|
-
// need to shut off, in case parent object has a gradient applied
|
383
|
-
//p2d.fillGradient = false;
|
384
|
-
}
|
385
|
-
//}
|
386
|
-
}
|
387
|
-
}
|