picrate 0.2.0-java → 0.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -5
- data/Rakefile +10 -2
- data/docs/_posts/2018-06-26-auto_install_picrate.md +15 -0
- data/lib/export.txt +8 -0
- data/lib/picrate/app.rb +4 -4
- data/lib/picrate/version.rb +1 -1
- data/picrate.gemspec +1 -1
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +16 -85
- data/src/main/java/processing/awt/PShapeJava2D.java +9 -33
- data/src/main/java/processing/awt/PSurfaceAWT.java +76 -169
- data/src/main/java/processing/core/PApplet.java +14019 -15963
- data/src/main/java/processing/core/PConstants.java +475 -981
- data/src/main/java/processing/core/PFont.java +50 -202
- data/src/main/java/processing/core/PGraphics.java +7330 -8477
- data/src/main/java/processing/core/PImage.java +42 -212
- data/src/main/java/processing/core/PMatrix.java +21 -160
- data/src/main/java/processing/core/PMatrix2D.java +18 -178
- data/src/main/java/processing/core/PMatrix3D.java +48 -324
- data/src/main/java/processing/core/PShape.java +294 -1181
- data/src/main/java/processing/core/PShapeOBJ.java +16 -91
- data/src/main/java/processing/core/PShapeSVG.java +53 -253
- data/src/main/java/processing/core/PStyle.java +34 -179
- data/src/main/java/processing/core/PSurface.java +13 -94
- data/src/main/java/processing/core/PSurfaceNone.java +35 -140
- data/src/main/java/processing/core/PVector.java +10 -87
- data/src/main/java/processing/event/Event.java +86 -69
- data/src/main/java/processing/event/MouseEvent.java +102 -102
- data/src/main/java/processing/opengl/PGL.java +23 -16
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -10
- data/src/main/java/processing/opengl/PJOGL.java +32 -12
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +154 -0
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +2 -2
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +160 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +2 -2
- metadata +7 -3
@@ -22,29 +22,16 @@ public class PShapeOBJ extends PShape {
|
|
22
22
|
|
23
23
|
/**
|
24
24
|
* Initializes a new OBJ Object with the given filename.
|
25
|
-
* @param parent
|
26
|
-
* @param filename
|
27
25
|
*/
|
28
26
|
public PShapeOBJ(PApplet parent, String filename) {
|
29
27
|
this(parent, parent.createReader(filename), getBasePath(parent, filename));
|
30
28
|
}
|
31
29
|
|
32
|
-
|
33
|
-
*
|
34
|
-
* @param parent
|
35
|
-
* @param reader
|
36
|
-
*/
|
37
|
-
public PShapeOBJ(PApplet parent, BufferedReader reader) {
|
30
|
+
public PShapeOBJ(PApplet parent, BufferedReader reader) {
|
38
31
|
this(parent, reader, "");
|
39
32
|
}
|
40
33
|
|
41
|
-
|
42
|
-
*
|
43
|
-
* @param parent
|
44
|
-
* @param reader
|
45
|
-
* @param basePath
|
46
|
-
*/
|
47
|
-
public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
|
34
|
+
public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
|
48
35
|
ArrayList<OBJFace> faces = new ArrayList<OBJFace>();
|
49
36
|
ArrayList<OBJMaterial> materials = new ArrayList<OBJMaterial>();
|
50
37
|
ArrayList<PVector> coords = new ArrayList<PVector>();
|
@@ -59,15 +46,8 @@ public class PShapeOBJ extends PShape {
|
|
59
46
|
addChildren(faces, materials, coords, normals, texcoords);
|
60
47
|
}
|
61
48
|
|
62
|
-
|
63
|
-
|
64
|
-
* @param face
|
65
|
-
* @param mtl
|
66
|
-
* @param coords
|
67
|
-
* @param normals
|
68
|
-
* @param texcoords
|
69
|
-
*/
|
70
|
-
protected PShapeOBJ(OBJFace face, OBJMaterial mtl,
|
49
|
+
|
50
|
+
protected PShapeOBJ(OBJFace face, OBJMaterial mtl,
|
71
51
|
ArrayList<PVector> coords,
|
72
52
|
ArrayList<PVector> normals,
|
73
53
|
ArrayList<PVector> texcoords) {
|
@@ -145,15 +125,8 @@ public class PShapeOBJ extends PShape {
|
|
145
125
|
}
|
146
126
|
}
|
147
127
|
|
148
|
-
|
149
|
-
|
150
|
-
* @param faces
|
151
|
-
* @param materials
|
152
|
-
* @param coords
|
153
|
-
* @param normals
|
154
|
-
* @param texcoords
|
155
|
-
*/
|
156
|
-
protected void addChildren(ArrayList<OBJFace> faces,
|
128
|
+
|
129
|
+
protected void addChildren(ArrayList<OBJFace> faces,
|
157
130
|
ArrayList<OBJMaterial> materials,
|
158
131
|
ArrayList<PVector> coords,
|
159
132
|
ArrayList<PVector> normals,
|
@@ -176,18 +149,8 @@ public class PShapeOBJ extends PShape {
|
|
176
149
|
}
|
177
150
|
}
|
178
151
|
|
179
|
-
|
180
|
-
|
181
|
-
* @param parent
|
182
|
-
* @param path
|
183
|
-
* @param reader
|
184
|
-
* @param faces
|
185
|
-
* @param materials
|
186
|
-
* @param coords
|
187
|
-
* @param normals
|
188
|
-
* @param texcoords
|
189
|
-
*/
|
190
|
-
static protected void parseOBJ(PApplet parent, String path,
|
152
|
+
|
153
|
+
static protected void parseOBJ(PApplet parent, String path,
|
191
154
|
BufferedReader reader,
|
192
155
|
ArrayList<OBJFace> faces,
|
193
156
|
ArrayList<OBJMaterial> materials,
|
@@ -353,16 +316,8 @@ public class PShapeOBJ extends PShape {
|
|
353
316
|
}
|
354
317
|
}
|
355
318
|
|
356
|
-
|
357
|
-
|
358
|
-
* @param parent
|
359
|
-
* @param mtlfn
|
360
|
-
* @param path
|
361
|
-
* @param reader
|
362
|
-
* @param materials
|
363
|
-
* @param materialsHash
|
364
|
-
*/
|
365
|
-
static protected void parseMTL(PApplet parent, String mtlfn, String path,
|
319
|
+
|
320
|
+
static protected void parseMTL(PApplet parent, String mtlfn, String path,
|
366
321
|
BufferedReader reader,
|
367
322
|
ArrayList<OBJMaterial> materials,
|
368
323
|
Map<String, Integer> materialsHash) {
|
@@ -433,14 +388,7 @@ public class PShapeOBJ extends PShape {
|
|
433
388
|
}
|
434
389
|
}
|
435
390
|
|
436
|
-
|
437
|
-
*
|
438
|
-
* @param mtlname
|
439
|
-
* @param materials
|
440
|
-
* @param materialsHash
|
441
|
-
* @return
|
442
|
-
*/
|
443
|
-
protected static OBJMaterial addMaterial(String mtlname,
|
391
|
+
protected static OBJMaterial addMaterial(String mtlname,
|
444
392
|
ArrayList<OBJMaterial> materials,
|
445
393
|
Map<String, Integer> materialsHash) {
|
446
394
|
OBJMaterial currentMtl = new OBJMaterial(mtlname);
|
@@ -449,24 +397,14 @@ public class PShapeOBJ extends PShape {
|
|
449
397
|
return currentMtl;
|
450
398
|
}
|
451
399
|
|
452
|
-
|
453
|
-
*
|
454
|
-
* @param color
|
455
|
-
* @return
|
456
|
-
*/
|
457
|
-
protected static int rgbaValue(PVector color) {
|
400
|
+
protected static int rgbaValue(PVector color) {
|
458
401
|
return 0xFF000000 | ((int)(color.x * 255) << 16) |
|
459
402
|
((int)(color.y * 255) << 8) |
|
460
403
|
(int)(color.z * 255);
|
461
404
|
}
|
462
405
|
|
463
|
-
|
464
|
-
|
465
|
-
* @param color
|
466
|
-
* @param alpha
|
467
|
-
* @return
|
468
|
-
*/
|
469
|
-
protected static int rgbaValue(PVector color, float alpha) {
|
406
|
+
|
407
|
+
protected static int rgbaValue(PVector color, float alpha) {
|
470
408
|
return ((int)(alpha * 255) << 24) |
|
471
409
|
((int)(color.x * 255) << 16) |
|
472
410
|
((int)(color.y * 255) << 8) |
|
@@ -475,10 +413,6 @@ public class PShapeOBJ extends PShape {
|
|
475
413
|
|
476
414
|
|
477
415
|
// Stores a face from an OBJ file
|
478
|
-
|
479
|
-
/**
|
480
|
-
*
|
481
|
-
*/
|
482
416
|
static protected class OBJFace {
|
483
417
|
ArrayList<Integer> vertIdx;
|
484
418
|
ArrayList<Integer> texIdx;
|
@@ -495,13 +429,8 @@ public class PShapeOBJ extends PShape {
|
|
495
429
|
}
|
496
430
|
}
|
497
431
|
|
498
|
-
|
499
|
-
|
500
|
-
* @param parent
|
501
|
-
* @param filename
|
502
|
-
* @return
|
503
|
-
*/
|
504
|
-
static protected String getBasePath(PApplet parent, String filename) {
|
432
|
+
|
433
|
+
static protected String getBasePath(PApplet parent, String filename) {
|
505
434
|
// Obtaining the path
|
506
435
|
File file = new File(parent.dataPath(filename));
|
507
436
|
if (!file.exists()) {
|
@@ -514,10 +443,6 @@ public class PShapeOBJ extends PShape {
|
|
514
443
|
|
515
444
|
|
516
445
|
// Stores a material defined in an MTL file.
|
517
|
-
|
518
|
-
/**
|
519
|
-
*
|
520
|
-
*/
|
521
446
|
static protected class OBJMaterial {
|
522
447
|
String name;
|
523
448
|
PVector ka;
|
@@ -89,10 +89,6 @@ public class PShapeSVG extends PShape {
|
|
89
89
|
XML element;
|
90
90
|
|
91
91
|
/// Values between 0 and 1.
|
92
|
-
|
93
|
-
/**
|
94
|
-
*
|
95
|
-
*/
|
96
92
|
protected float opacity;
|
97
93
|
float strokeOpacity;
|
98
94
|
float fillOpacity;
|
@@ -106,22 +102,15 @@ public class PShapeSVG extends PShape {
|
|
106
102
|
/** √((w² + h²)/2) of containing SVG (used for percentages). */
|
107
103
|
protected float svgSizeXY;
|
108
104
|
|
109
|
-
|
110
|
-
*
|
111
|
-
*/
|
112
|
-
protected Gradient strokeGradient;
|
105
|
+
protected Gradient strokeGradient;
|
113
106
|
String strokeName; // id of another object, gradients only?
|
114
107
|
|
115
|
-
|
116
|
-
*
|
117
|
-
*/
|
118
|
-
protected Gradient fillGradient;
|
108
|
+
protected Gradient fillGradient;
|
119
109
|
String fillName; // id of another object
|
120
110
|
|
121
111
|
|
122
112
|
/**
|
123
113
|
* Initializes a new SVG object from the given XML object.
|
124
|
-
* @param svg
|
125
114
|
*/
|
126
115
|
public PShapeSVG(XML svg) {
|
127
116
|
this(null, svg, true);
|
@@ -136,13 +125,8 @@ public class PShapeSVG extends PShape {
|
|
136
125
|
}
|
137
126
|
}
|
138
127
|
|
139
|
-
|
140
|
-
|
141
|
-
* @param parent
|
142
|
-
* @param properties
|
143
|
-
* @param parseKids
|
144
|
-
*/
|
145
|
-
protected PShapeSVG(PShapeSVG parent, XML properties, boolean parseKids) {
|
128
|
+
|
129
|
+
protected PShapeSVG(PShapeSVG parent, XML properties, boolean parseKids) {
|
146
130
|
setParent(parent);
|
147
131
|
|
148
132
|
// Need to get width/height in early.
|
@@ -229,11 +213,6 @@ public class PShapeSVG extends PShape {
|
|
229
213
|
|
230
214
|
// Broken out so that subclasses can copy any additional variables
|
231
215
|
// (i.e. fillGradientPaint and strokeGradientPaint)
|
232
|
-
|
233
|
-
/**
|
234
|
-
*
|
235
|
-
* @param parent
|
236
|
-
*/
|
237
216
|
protected void setParent(PShapeSVG parent) {
|
238
217
|
// Need to set this so that findChild() works.
|
239
218
|
// Otherwise 'parent' is null until addChild() is called later.
|
@@ -295,20 +274,13 @@ public class PShapeSVG extends PShape {
|
|
295
274
|
}
|
296
275
|
|
297
276
|
|
298
|
-
/** Factory method for subclasses.
|
299
|
-
* @param parent
|
300
|
-
* @param properties
|
301
|
-
* @param parseKids
|
302
|
-
* @return */
|
277
|
+
/** Factory method for subclasses. */
|
303
278
|
protected PShapeSVG createShape(PShapeSVG parent, XML properties, boolean parseKids) {
|
304
279
|
return new PShapeSVG(parent, properties, parseKids);
|
305
280
|
}
|
306
281
|
|
307
|
-
|
308
|
-
|
309
|
-
* @param graphics
|
310
|
-
*/
|
311
|
-
protected void parseChildren(XML graphics) {
|
282
|
+
|
283
|
+
protected void parseChildren(XML graphics) {
|
312
284
|
XML[] elements = graphics.getChildren();
|
313
285
|
children = new PShape[elements.length];
|
314
286
|
childCount = 0;
|
@@ -324,8 +296,6 @@ public class PShapeSVG extends PShape {
|
|
324
296
|
/**
|
325
297
|
* Parse a child XML element.
|
326
298
|
* Override this method to add parsing for more SVG elements.
|
327
|
-
* @param elem
|
328
|
-
* @return
|
329
299
|
*/
|
330
300
|
protected PShape parseChild(XML elem) {
|
331
301
|
// System.err.println("parsing child in pshape " + elem.getName());
|
@@ -419,10 +389,8 @@ public class PShapeSVG extends PShape {
|
|
419
389
|
return shape;
|
420
390
|
}
|
421
391
|
|
422
|
-
|
423
|
-
|
424
|
-
*/
|
425
|
-
protected void parseLine() {
|
392
|
+
|
393
|
+
protected void parseLine() {
|
426
394
|
kind = LINE;
|
427
395
|
family = PRIMITIVE;
|
428
396
|
params = new float[] {
|
@@ -460,10 +428,8 @@ public class PShapeSVG extends PShape {
|
|
460
428
|
params[3] = ry*2;
|
461
429
|
}
|
462
430
|
|
463
|
-
|
464
|
-
|
465
|
-
*/
|
466
|
-
protected void parseRect() {
|
431
|
+
|
432
|
+
protected void parseRect() {
|
467
433
|
kind = RECT;
|
468
434
|
family = PRIMITIVE;
|
469
435
|
params = new float[] {
|
@@ -497,10 +463,8 @@ public class PShapeSVG extends PShape {
|
|
497
463
|
}
|
498
464
|
}
|
499
465
|
|
500
|
-
|
501
|
-
|
502
|
-
*/
|
503
|
-
protected void parsePath() {
|
466
|
+
|
467
|
+
protected void parsePath() {
|
504
468
|
family = PATH;
|
505
469
|
kind = 0;
|
506
470
|
|
@@ -1073,12 +1037,8 @@ public class PShapeSVG extends PShape {
|
|
1073
1037
|
return outgoing;
|
1074
1038
|
}
|
1075
1039
|
|
1076
|
-
|
1077
|
-
|
1078
|
-
* @param matrixStr
|
1079
|
-
* @return
|
1080
|
-
*/
|
1081
|
-
static protected PMatrix2D parseSingleTransform(String matrixStr) {
|
1040
|
+
|
1041
|
+
static protected PMatrix2D parseSingleTransform(String matrixStr) {
|
1082
1042
|
//String[] pieces = PApplet.match(matrixStr, "^\\s*(\\w+)\\((.*)\\)\\s*$");
|
1083
1043
|
String[] pieces = PApplet.match(matrixStr, "[,\\s]*(\\w+)\\((.*)\\)");
|
1084
1044
|
if (pieces == null) {
|
@@ -1124,11 +1084,8 @@ public class PShapeSVG extends PShape {
|
|
1124
1084
|
return null;
|
1125
1085
|
}
|
1126
1086
|
|
1127
|
-
|
1128
|
-
|
1129
|
-
* @param properties
|
1130
|
-
*/
|
1131
|
-
protected void parseColors(XML properties) {
|
1087
|
+
|
1088
|
+
protected void parseColors(XML properties) {
|
1132
1089
|
if (properties.hasAttribute("opacity")) {
|
1133
1090
|
String opacityText = properties.getString("opacity");
|
1134
1091
|
setOpacity(opacityText);
|
@@ -1316,7 +1273,6 @@ public class PShapeSVG extends PShape {
|
|
1316
1273
|
/**
|
1317
1274
|
* Parses the "color" datatype only, and prints an error if it is not of this form.
|
1318
1275
|
* http://www.w3.org/TR/SVG/types.html#DataTypeColor
|
1319
|
-
* @param colorText
|
1320
1276
|
* @return 0xRRGGBB (no alpha). Zero on error.
|
1321
1277
|
*/
|
1322
1278
|
static protected int parseSimpleColor(String colorText) {
|
@@ -1388,13 +1344,6 @@ public class PShapeSVG extends PShape {
|
|
1388
1344
|
}
|
1389
1345
|
*/
|
1390
1346
|
|
1391
|
-
/**
|
1392
|
-
*
|
1393
|
-
* @param what
|
1394
|
-
* @return
|
1395
|
-
*/
|
1396
|
-
|
1397
|
-
|
1398
1347
|
static protected int parseRGB(String what) {
|
1399
1348
|
int leftParen = what.indexOf('(') + 1;
|
1400
1349
|
int rightParen = what.indexOf(')');
|
@@ -1418,12 +1367,6 @@ public class PShapeSVG extends PShape {
|
|
1418
1367
|
|
1419
1368
|
|
1420
1369
|
//static protected Map<String, String> parseStyleAttributes(String style) {
|
1421
|
-
|
1422
|
-
/**
|
1423
|
-
*
|
1424
|
-
* @param style
|
1425
|
-
* @return
|
1426
|
-
*/
|
1427
1370
|
static protected StringDict parseStyleAttributes(String style) {
|
1428
1371
|
//Map<String, String> table = new HashMap<String, String>();
|
1429
1372
|
StringDict table = new StringDict();
|
@@ -1467,11 +1410,9 @@ public class PShapeSVG extends PShape {
|
|
1467
1410
|
* <LI>"1cm" equals "35.43307px" (and therefore 35.43307 user units)
|
1468
1411
|
* <LI>"1in" equals "90px" (and therefore 90 user units)
|
1469
1412
|
* </UL>
|
1470
|
-
* @param text
|
1471
1413
|
* @param relativeTo (float) Used for %. When relative to viewbox, should
|
1472
1414
|
* be svgWidth for horizontal dimentions, svgHeight for vertical, and
|
1473
1415
|
* svgXYSize for anything else.
|
1474
|
-
* @return
|
1475
1416
|
*/
|
1476
1417
|
static protected float parseUnitSize(String text, float relativeTo) {
|
1477
1418
|
int len = text.length() - 2;
|
@@ -1495,12 +1436,8 @@ public class PShapeSVG extends PShape {
|
|
1495
1436
|
}
|
1496
1437
|
}
|
1497
1438
|
|
1498
|
-
|
1499
|
-
|
1500
|
-
* @param text
|
1501
|
-
* @return
|
1502
|
-
*/
|
1503
|
-
static protected float parseFloatOrPercent(String text) {
|
1439
|
+
|
1440
|
+
static protected float parseFloatOrPercent(String text) {
|
1504
1441
|
text = text.trim();
|
1505
1442
|
if (text.endsWith("%")) {
|
1506
1443
|
return Float.parseFloat(text.substring(0, text.length() - 1)) / 100.0f;
|
@@ -1512,35 +1449,15 @@ public class PShapeSVG extends PShape {
|
|
1512
1449
|
|
1513
1450
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
1514
1451
|
|
1515
|
-
/**
|
1516
|
-
*
|
1517
|
-
*/
|
1518
|
-
|
1519
1452
|
|
1520
1453
|
static public class Gradient extends PShapeSVG {
|
1521
1454
|
AffineTransform transform;
|
1522
1455
|
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
/**
|
1529
|
-
*
|
1530
|
-
*/
|
1531
|
-
public int[] color;
|
1532
|
-
|
1533
|
-
/**
|
1534
|
-
*
|
1535
|
-
*/
|
1536
|
-
public int count;
|
1537
|
-
|
1538
|
-
/**
|
1539
|
-
*
|
1540
|
-
* @param parent
|
1541
|
-
* @param properties
|
1542
|
-
*/
|
1543
|
-
public Gradient(PShapeSVG parent, XML properties) {
|
1456
|
+
public float[] offset;
|
1457
|
+
public int[] color;
|
1458
|
+
public int count;
|
1459
|
+
|
1460
|
+
public Gradient(PShapeSVG parent, XML properties) {
|
1544
1461
|
super(parent, properties, true);
|
1545
1462
|
|
1546
1463
|
XML elements[] = properties.getChildren();
|
@@ -1580,37 +1497,11 @@ public class PShapeSVG extends PShape {
|
|
1580
1497
|
}
|
1581
1498
|
}
|
1582
1499
|
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
/**
|
1589
|
-
*
|
1590
|
-
*/
|
1591
|
-
public float x1,
|
1592
|
-
|
1593
|
-
/**
|
1594
|
-
*
|
1595
|
-
*/
|
1596
|
-
y1,
|
1597
|
-
|
1598
|
-
/**
|
1599
|
-
*
|
1600
|
-
*/
|
1601
|
-
x2,
|
1602
|
-
|
1603
|
-
/**
|
1604
|
-
*
|
1605
|
-
*/
|
1606
|
-
y2;
|
1607
|
-
|
1608
|
-
/**
|
1609
|
-
*
|
1610
|
-
* @param parent
|
1611
|
-
* @param properties
|
1612
|
-
*/
|
1613
|
-
public LinearGradient(PShapeSVG parent, XML properties) {
|
1500
|
+
|
1501
|
+
public class LinearGradient extends Gradient {
|
1502
|
+
public float x1, y1, x2, y2;
|
1503
|
+
|
1504
|
+
public LinearGradient(PShapeSVG parent, XML properties) {
|
1614
1505
|
super(parent, properties);
|
1615
1506
|
|
1616
1507
|
this.x1 = getFloatWithUnit(properties, "x1", svgWidth);
|
@@ -1636,32 +1527,11 @@ public class PShapeSVG extends PShape {
|
|
1636
1527
|
}
|
1637
1528
|
}
|
1638
1529
|
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
/**
|
1645
|
-
*
|
1646
|
-
*/
|
1647
|
-
public float cx,
|
1648
|
-
|
1649
|
-
/**
|
1650
|
-
*
|
1651
|
-
*/
|
1652
|
-
cy,
|
1653
|
-
|
1654
|
-
/**
|
1655
|
-
*
|
1656
|
-
*/
|
1657
|
-
r;
|
1658
|
-
|
1659
|
-
/**
|
1660
|
-
*
|
1661
|
-
* @param parent
|
1662
|
-
* @param properties
|
1663
|
-
*/
|
1664
|
-
public RadialGradient(PShapeSVG parent, XML properties) {
|
1530
|
+
|
1531
|
+
public class RadialGradient extends Gradient {
|
1532
|
+
public float cx, cy, r;
|
1533
|
+
|
1534
|
+
public RadialGradient(PShapeSVG parent, XML properties) {
|
1665
1535
|
super(parent, properties);
|
1666
1536
|
|
1667
1537
|
this.cx = getFloatWithUnit(properties, "cx", svgWidth);
|
@@ -1688,51 +1558,21 @@ public class PShapeSVG extends PShape {
|
|
1688
1558
|
|
1689
1559
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
1690
1560
|
|
1691
|
-
/**
|
1692
|
-
*
|
1693
|
-
*/
|
1694
|
-
|
1695
1561
|
|
1696
1562
|
public static class Font extends PShapeSVG {
|
1563
|
+
public FontFace face;
|
1697
1564
|
|
1698
|
-
|
1699
|
-
|
1700
|
-
*/
|
1701
|
-
public FontFace face;
|
1702
|
-
|
1703
|
-
/**
|
1704
|
-
*
|
1705
|
-
*/
|
1706
|
-
public Map<String, FontGlyph> namedGlyphs;
|
1565
|
+
public Map<String, FontGlyph> namedGlyphs;
|
1566
|
+
public Map<Character, FontGlyph> unicodeGlyphs;
|
1707
1567
|
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
public Map<Character, FontGlyph> unicodeGlyphs;
|
1712
|
-
|
1713
|
-
/**
|
1714
|
-
*
|
1715
|
-
*/
|
1716
|
-
public int glyphCount;
|
1717
|
-
|
1718
|
-
/**
|
1719
|
-
*
|
1720
|
-
*/
|
1721
|
-
public FontGlyph[] glyphs;
|
1722
|
-
|
1723
|
-
/**
|
1724
|
-
*
|
1725
|
-
*/
|
1726
|
-
public FontGlyph missingGlyph;
|
1568
|
+
public int glyphCount;
|
1569
|
+
public FontGlyph[] glyphs;
|
1570
|
+
public FontGlyph missingGlyph;
|
1727
1571
|
|
1728
1572
|
int horizAdvX;
|
1729
1573
|
|
1730
|
-
|
1731
|
-
|
1732
|
-
* @param parent
|
1733
|
-
* @param properties
|
1734
|
-
*/
|
1735
|
-
public Font(PShapeSVG parent, XML properties) {
|
1574
|
+
|
1575
|
+
public Font(PShapeSVG parent, XML properties) {
|
1736
1576
|
super(parent, properties, false);
|
1737
1577
|
// handle(parent, properties);
|
1738
1578
|
|
@@ -1773,22 +1613,13 @@ public class PShapeSVG extends PShape {
|
|
1773
1613
|
}
|
1774
1614
|
}
|
1775
1615
|
|
1776
|
-
|
1777
|
-
|
1778
|
-
*/
|
1779
|
-
protected void drawShape() {
|
1616
|
+
|
1617
|
+
protected void drawShape() {
|
1780
1618
|
// does nothing for fonts
|
1781
1619
|
}
|
1782
1620
|
|
1783
|
-
|
1784
|
-
|
1785
|
-
* @param g
|
1786
|
-
* @param str
|
1787
|
-
* @param x
|
1788
|
-
* @param y
|
1789
|
-
* @param size
|
1790
|
-
*/
|
1791
|
-
public void drawString(PGraphics g, String str, float x, float y, float size) {
|
1621
|
+
|
1622
|
+
public void drawString(PGraphics g, String str, float x, float y, float size) {
|
1792
1623
|
// 1) scale by the 1.0/unitsPerEm
|
1793
1624
|
// 2) scale up by a font size
|
1794
1625
|
g.pushMatrix();
|
@@ -1812,15 +1643,8 @@ public class PShapeSVG extends PShape {
|
|
1812
1643
|
g.popMatrix();
|
1813
1644
|
}
|
1814
1645
|
|
1815
|
-
|
1816
|
-
|
1817
|
-
* @param g
|
1818
|
-
* @param c
|
1819
|
-
* @param x
|
1820
|
-
* @param y
|
1821
|
-
* @param size
|
1822
|
-
*/
|
1823
|
-
public void drawChar(PGraphics g, char c, float x, float y, float size) {
|
1646
|
+
|
1647
|
+
public void drawChar(PGraphics g, char c, float x, float y, float size) {
|
1824
1648
|
g.pushMatrix();
|
1825
1649
|
float s = size / face.unitsPerEm;
|
1826
1650
|
g.translate(x, y);
|
@@ -1830,13 +1654,8 @@ public class PShapeSVG extends PShape {
|
|
1830
1654
|
g.popMatrix();
|
1831
1655
|
}
|
1832
1656
|
|
1833
|
-
|
1834
|
-
|
1835
|
-
* @param str
|
1836
|
-
* @param size
|
1837
|
-
* @return
|
1838
|
-
*/
|
1839
|
-
public float textWidth(String str, float size) {
|
1657
|
+
|
1658
|
+
public float textWidth(String str, float size) {
|
1840
1659
|
float w = 0;
|
1841
1660
|
char[] c = str.toCharArray();
|
1842
1661
|
for (int i = 0; i < c.length; i++) {
|
@@ -1890,27 +1709,13 @@ public class PShapeSVG extends PShape {
|
|
1890
1709
|
|
1891
1710
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
1892
1711
|
|
1893
|
-
/**
|
1894
|
-
*
|
1895
|
-
*/
|
1896
|
-
|
1897
1712
|
|
1898
1713
|
public static class FontGlyph extends PShapeSVG { // extends Path
|
1899
|
-
|
1900
|
-
/**
|
1901
|
-
*
|
1902
|
-
*/
|
1903
1714
|
public String name;
|
1904
1715
|
char unicode;
|
1905
1716
|
int horizAdvX;
|
1906
1717
|
|
1907
|
-
|
1908
|
-
*
|
1909
|
-
* @param parent
|
1910
|
-
* @param properties
|
1911
|
-
* @param font
|
1912
|
-
*/
|
1913
|
-
public FontGlyph(PShapeSVG parent, XML properties, Font font) {
|
1718
|
+
public FontGlyph(PShapeSVG parent, XML properties, Font font) {
|
1914
1719
|
super(parent, properties, true);
|
1915
1720
|
super.parsePath(); // ??
|
1916
1721
|
|
@@ -1933,11 +1738,8 @@ public class PShapeSVG extends PShape {
|
|
1933
1738
|
}
|
1934
1739
|
}
|
1935
1740
|
|
1936
|
-
|
1937
|
-
|
1938
|
-
* @return
|
1939
|
-
*/
|
1940
|
-
protected boolean isLegit() { // TODO need a better way to handle this...
|
1741
|
+
|
1742
|
+
protected boolean isLegit() { // TODO need a better way to handle this...
|
1941
1743
|
return vertexCount != 0;
|
1942
1744
|
}
|
1943
1745
|
}
|
@@ -1956,8 +1758,6 @@ public class PShapeSVG extends PShape {
|
|
1956
1758
|
* // This code grabs "Layer 3" and the shapes beneath it.
|
1957
1759
|
* PShape layer3 = svg.getChild("Layer 3");
|
1958
1760
|
* </PRE>
|
1959
|
-
* @param name
|
1960
|
-
* @return
|
1961
1761
|
*/
|
1962
1762
|
@Override
|
1963
1763
|
public PShape getChild(String name) {
|