geomerative 1.1.0-java → 2.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.mvn/extensions.xml +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  5. data/CHANGELOG.md +3 -0
  6. data/COPYING.md +1 -1
  7. data/README.md +0 -1
  8. data/Rakefile +2 -15
  9. data/docs/_includes/header.html +6 -6
  10. data/docs/_includes/icon-github.svg +3 -1
  11. data/docs/_includes/icon-twitter.svg +3 -1
  12. data/docs/_includes/navigation.html +18 -18
  13. data/docs/_sass/_base.scss +79 -79
  14. data/docs/_sass/_layout.scss +137 -137
  15. data/docs/_sass/_syntax-highlighting.scss +64 -64
  16. data/docs/index.html +18 -18
  17. data/examples/data/bot1.svg +1 -1
  18. data/examples/data/lion.svg +156 -156
  19. data/examples/data/ruby.svg +1 -1
  20. data/geomerative.gemspec +1 -2
  21. data/lib/geomerative/version.rb +1 -1
  22. data/mvnw +234 -0
  23. data/mvnw.cmd +145 -0
  24. data/pom.rb +14 -13
  25. data/pom.xml +14 -13
  26. data/src/geomerative/FastRClip.java +2149 -2156
  27. data/src/geomerative/RClip.java +2237 -2539
  28. data/src/geomerative/RClosest.java +33 -31
  29. data/src/geomerative/RCommand.java +1750 -1758
  30. data/src/geomerative/RContour.java +290 -292
  31. data/src/geomerative/RFont.java +277 -246
  32. data/src/geomerative/RG.java +722 -727
  33. data/src/geomerative/RGeomElem.java +967 -960
  34. data/src/geomerative/RGroup.java +508 -467
  35. data/src/geomerative/RMatrix.java +304 -289
  36. data/src/geomerative/RMesh.java +241 -229
  37. data/src/geomerative/RPath.java +924 -925
  38. data/src/geomerative/RPoint.java +391 -391
  39. data/src/geomerative/RPolygon.java +998 -988
  40. data/src/geomerative/RRectangle.java +43 -52
  41. data/src/geomerative/RSVG.java +480 -516
  42. data/src/geomerative/RShape.java +1767 -1777
  43. data/src/geomerative/RStrip.java +173 -176
  44. data/src/geomerative/RStyle.java +197 -194
  45. data/src/org/apache/batik/svggen/font/Font.java +141 -142
  46. data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
  47. data/src/org/apache/batik/svggen/font/Point.java +12 -12
  48. data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
  49. data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
  50. data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
  51. data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
  52. data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
  53. data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
  54. data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
  55. data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
  56. data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
  57. data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
  58. data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
  59. data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
  60. data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
  61. data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
  62. data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
  63. data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
  64. data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
  65. data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
  66. data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
  67. data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
  68. data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
  69. data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
  70. data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
  71. data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
  72. data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
  73. data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
  74. data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
  75. data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
  76. data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
  77. data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
  78. data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
  79. data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
  80. data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
  81. data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
  82. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
  83. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
  84. data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
  85. data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
  86. data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
  87. data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
  88. data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
  89. data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
  90. data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
  91. data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
  92. data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
  93. data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
  94. data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
  95. data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
  96. data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
  97. data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
  98. data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
  99. data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
  100. data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
  101. data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
  102. data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
  103. data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
  104. data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
  105. data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
  106. data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
  107. data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
  108. data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
  109. data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
  110. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
  111. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
  112. data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
  113. data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
  114. data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
  115. metadata +10 -11
  116. data/.travis.yml +0 -9
@@ -18,741 +18,736 @@
18
18
  */
19
19
  package geomerative;
20
20
 
21
-
22
-
23
21
  import processing.core.PApplet;
24
22
  import processing.core.PConstants;
25
23
  import processing.core.PGraphics;
26
24
 
27
-
28
25
  /**
29
26
  * RG is a static class containing all the states, modes, etc.. Geomerative is
30
27
  * mostly used by calling RG methods. e.g. RShape s = RG.getEllipse(30, 40, 80,
31
28
  * 80)
32
29
  */
33
- public class RG {
34
-
35
- /**
36
- * @invisible
37
- */
38
- private static boolean initialized = false;
39
-
40
- /**
41
- * @invisible
42
- */
43
- private static PApplet parent;
44
-
45
- /**
46
- * @invisible
47
- */
48
- public static boolean ignoreStyles = false;
49
-
50
- /**
51
- * @invisible
52
- */
53
- public static boolean useFastClip = true;
54
-
55
- /**
56
- * The adaptor adapts the shape to a particular shape by adapting each of
57
- * the groups points. This can cause deformations of the individual elements
58
- * in the group.
59
- */
60
- public final static int BYPOINT = 0;
61
-
62
- /**
63
- * The adaptor adapts the shape to a particular shape by adapting each of
64
- * the groups elements positions. This mantains the proportions of the
65
- * shapes.
66
- */
67
- public final static int BYELEMENTPOSITION = 1;
68
-
69
- /**
70
- * The adaptor adapts the shape to a particular shape by adapting each of
71
- * the groups elements indices. This mantains the proportions of the shapes.
72
- */
73
- public final static int BYELEMENTINDEX = 2;
74
-
75
- /**
76
- * @invisible
77
- */
78
- static int adaptorType = BYELEMENTPOSITION;
79
-
80
- /**
81
- * @invisible
82
- */
83
- static float adaptorScale = 1F;
84
-
85
- /**
86
- * @invisible
87
- */
88
- static float adaptorLengthOffset = 0F;
89
-
90
- /**
91
- * ADAPTATIVE segmentator minimizes the number of segments avoiding
92
- * perceptual artifacts like angles or cusps. Use this in order to have
93
- * polygons and meshes with the fewest possible vertices.
94
- */
95
- public static int ADAPTATIVE = RCommand.ADAPTATIVE;
96
-
97
- /**
98
- * UNIFORMLENGTH segmentator is the slowest segmentator and it segments the
99
- * curve on segments of equal length. This can be useful for very specific
100
- * applications when for example drawing incrementaly a shape with a uniform
101
- * speed.
102
- */
103
- public static int UNIFORMLENGTH = RCommand.UNIFORMLENGTH;
104
-
105
- /**
106
- * UNIFORMSTEP segmentator is the fastest segmentator and it segments the
107
- * curve based on a constant value of the step of the curve parameter, or on
108
- * the number of segments wanted. This can be useful when segmpointsentating
109
- * very often a Shape or when we know the amount of segments necessary for
110
- * our specific application.
111
- */
112
- public static int UNIFORMSTEP = RCommand.UNIFORMSTEP;
113
-
114
- static int dpi = 72;
115
-
116
- /**
117
- * @invisible
118
- */
119
- public static class LibraryNotInitializedException extends NullPointerException {
120
-
121
- private static final long serialVersionUID = -3710605630786298671L;
122
-
123
- LibraryNotInitializedException() {
124
- super("Must call RG.init(this); before using this library.");
125
- }
126
- }
127
-
128
- /**
129
- * @invisible
130
- */
131
- public static class FontNotLoadedException extends NullPointerException {
132
-
133
- private static final long serialVersionUID = -3710605630786298672L;
134
-
135
- FontNotLoadedException() {
136
- super("Use RG.loadFont(filename) and RG.textFont(font, size) to load and set fonts first.");
137
- }
138
- }
139
-
140
- /**
141
- * @invisible
142
- */
143
- public static class NoPathInitializedException extends NullPointerException {
144
-
145
- private static final long serialVersionUID = -3710605630786298673L;
146
-
147
- NoPathInitializedException() {
148
- super("Must initialize a path by calling RG.beginShape() first.");
149
- }
150
- }
151
-
152
- static RShape shape;
153
-
154
- static RFont fntLoader = null;
155
-
156
- // Font methods
157
- /**
158
- * Load and get the font object that can be used in the textFont method.
159
- *
160
- * @eexample loadFont
161
- * @param fontFile the filename of the font to be loaded
162
- * @return RFont, the font object
163
- */
164
- public static RFont loadFont(String fontFile) {
165
- RFont newFntLoader = new RFont(fontFile);
166
- if (fntLoader == null) {
167
- fntLoader = newFntLoader;
168
- }
169
- return newFntLoader;
170
-
171
- }
172
-
173
- /**
174
- * Draw text to the screen using the font set using the textFont method.
175
- *
176
- * @eexample text
177
- * @param text the string to be drawn on the screen
178
- */
179
- public static void text(String text) {
180
- RShape grp = getText(text);
181
- grp.draw();
182
- }
183
-
184
- /**
185
- * Set the font object to be used in all text calls.
186
- *
187
- * @eexample textFont
188
- * @param font the font object to be set
189
- * @param size the size of the font
190
- */
191
- public static void textFont(RFont font, int size) {
192
- font.setSize(size);
193
- fntLoader = font;
194
- }
195
-
196
- /**
197
- * Get the shape corresponding to a text. Use the textFont method to select
198
- * the font and size.
199
- *
200
- * @eexample getText
201
- * @param font the filename of the font to be loaded
202
- * @param text the string to be created
203
- * @param size the size of the font to be used
204
- * @param align the alignment. Use RG.CENTER, RG.LEFT or RG.RIGHT
205
- * @return RShape, the shape created
206
- */
207
- public static RShape getText(String text, String font, int size, int align) {
208
- RFont tempFntLoader = new RFont(font, size, align);
209
- return tempFntLoader.toShape(text);
210
- }
211
-
212
- public static RShape getText(String text) {
213
- if (fntLoader == null) {
214
- throw new FontNotLoadedException();
215
- }
216
-
217
- return fntLoader.toShape(text);
218
- }
219
-
220
- // Shape methods
221
- /**
222
- * Draw a shape to a given position on the screen.
223
- *
224
- * @eexample shape
225
- * @param shp the shape to be drawn
226
- * @param x the horizontal coordinate
227
- * @param y the vertical coordinate
228
- * @param w the width with which we draw the shape
229
- * @param h the height with which we draw the shape
230
- */
231
- public static void shape(RShape shp, float x, float y, float w, float h) {
232
- RShape tshp = new RShape(shp);
233
-
234
- RMatrix transf = new RMatrix();
235
- transf.translate(x, y);
236
- transf.scale(w / tshp.getOrigWidth(), h / tshp.getOrigHeight());
237
- tshp.transform(transf);
238
-
239
- tshp.draw();
240
- }
241
-
242
- public static void shape(RShape shp, float x, float y) {
243
- RShape tshp = new RShape(shp);
244
-
245
- RMatrix transf = new RMatrix();
246
- transf.translate(x, y);
247
- tshp.transform(transf);
248
-
249
- tshp.draw();
250
- }
251
-
252
- public static void shape(RShape shp) {
253
- shp.draw();
254
- }
255
-
256
- /**
257
- * Create a shape from an array of point arrays.
258
- *
259
- * @param points
260
- * @return
261
- * @eexample createShape
262
- */
263
- public static RShape createShape(RPoint[][] points) {
264
- return new RShape(points);
265
- }
266
-
267
- /**
268
- * Load a shape object from a file.
269
- *
270
- * @return
271
- * @eexample loadShape
272
- * @param filename the SVG file to be loaded. Must be in the data directory
273
- */
274
- public static RShape loadShape(String filename) {
275
- RSVG svgLoader = new RSVG();
276
- return svgLoader.toShape(filename);
277
- }
278
-
279
- /**
280
- * Save a shape object to a file.
281
- *
282
- * @eexample saveShape
283
- * @param filename the SVG file to be saved.
284
- * @param shape the shape to be saved.
285
- */
286
- public static void saveShape(String filename, RShape shape) {
287
- RSVG svgSaver = new RSVG();
288
- String str = svgSaver.fromShape(shape);
289
- String[] strs = PApplet.split(str, "\n");
290
- RG.parent().saveStrings(filename, strs);
291
- }
292
-
293
- // Methods to create shapes
294
- /**
295
- * Begin to create a shape.
296
- *
297
- * @eexample createShape
298
- */
299
- public static void beginShape() {
300
- shape = new RShape();
301
- }
302
-
303
- /**
304
- * Begin a new path in the current shape. Can only be called inside
305
- * beginShape() and endShape().
306
- *
307
- * @param endMode if called with RG.CLOSE it closes the current path before
308
- * starting the new one.
309
- * @eexample createShape
310
- */
311
- public static void breakShape(int endMode) {
312
- if (endMode == PConstants.CLOSE) {
313
- shape.addClose();
314
- }
315
-
316
- shape.updateOrigParams();
317
-
318
- breakShape();
319
- }
320
-
321
- public static void breakShape() {
322
- shape.addPath();
323
- }
324
-
325
- /**
326
- * Add a vertex to the shape. Can only be called inside beginShape() and
327
- * endShape().
328
- *
329
- * @eexample createShape
330
- * @param x the x coordinate of the vertex
331
- * @param y the y coordinate of the vertex
332
- */
333
- public static void vertex(float x, float y) {
334
- if (shape.countPaths() == 0) {
335
- shape.addMoveTo(x, y);
336
- } else {
337
- shape.addLineTo(x, y);
338
- }
339
- }
340
-
341
- /**
342
- * Add a bezierVertex to the shape. Can only be called inside beginShape()
343
- * and endShape().
344
- *
345
- * @eexample createShape
346
- * @param cx1 the x coordinate of the first control point
347
- * @param cy1 the y coordinate of the first control point
348
- * @param cx2 the x coordinate of the second control point
349
- * @param cy2 the y coordinate of the second control point
350
- * @param x the x coordinate of the end point
351
- * @param y the y coordinate of the end point
352
- */
353
- public static void bezierVertex(float cx1, float cy1, float cx2, float cy2, float x, float y) {
354
- if (shape.countPaths() == 0) {
355
- throw new NoPathInitializedException();
356
- } else {
357
- shape.addBezierTo(cx1, cy1, cx2, cy2, x, y);
358
- }
359
- }
360
-
361
- /**
362
- * End the shape being created and draw it to the screen or the PGraphics
363
- * passed as parameter.
364
- *
365
- * @eexample createShape
366
- * @param g the canvas on which to draw. By default it draws on the screen
367
- */
368
- public static void endShape(PGraphics g) {
369
- shape.draw(g);
370
- shape = null;
371
- }
372
-
373
- public static void endShape() {
374
- shape.draw();
375
- shape = null;
376
- }
377
-
378
- /**
379
- * End the shape being created and get it as an object.
380
- *
381
- * @return
382
- * @eexample getShape
383
- */
384
- public static RShape getShape() {
385
- RShape returningGroup = new RShape();
386
- returningGroup.addChild(shape);
387
-
388
- shape = null;
389
-
390
- returningGroup.updateOrigParams();
391
-
392
- return returningGroup;
393
- }
394
-
395
- /**
396
- * Get an ellipse as a shape object.
397
- *
398
- * @eexample getEllipse
399
- * @param x x coordinate of the center of the shape
400
- * @param y y coordinate of the center of the shape
401
- * @param w width of the ellipse
402
- * @param h height of the ellipse
403
- * @return RShape, the shape created
404
- */
405
- public static RShape getEllipse(float x, float y, float w, float h) {
406
- return RShape.createEllipse(x, y, w, h);
407
- }
408
-
409
- public static RShape getEllipse(float x, float y, float w) {
410
- return getEllipse(x, y, w, w);
411
- }
412
-
413
- /**
414
- * Get a line as a shape object.
415
- *
416
- * @eexample getLine
417
- * @param x1 x coordinate of the first point of the line
418
- * @param y1 y coordinate of the first point of the line
419
- * @param x2 x coordinate of the last point of the line
420
- * @param y2 y coordinate of the last point of the line
421
- * @return RShape, the shape created
422
- */
423
- public static RShape getLine(float x1, float y1, float x2, float y2) {
424
- return RShape.createLine(x1, y1, x2, y2);
425
- }
426
-
427
- /**
428
- * Get an rectangle as a shape object.
429
- *
430
- * @eexample getRect
431
- * @param x x coordinate of the top left corner of the shape
432
- * @param y y coordinate of the top left of the shape
433
- * @param w width of the rectangle
434
- * @param h height of the rectangle
435
- * @return RShape, the shape created
436
- */
437
- public static RShape getRect(float x, float y, float w, float h) {
438
- return RShape.createRectangle(x, y, w, h);
439
- }
440
-
441
- public static RShape getRect(float x, float y, float w) {
442
- return getRect(x, y, w, w);
443
- }
444
-
445
- /**
446
- * Get a star as a shape object.
447
- *
448
- * @eexample getStar
449
- * @param x x coordinate of the center of the shape
450
- * @param y y coordinate of the center of the shape
451
- * @param widthBig the outter width of the star polygon
452
- * @param widthSmall the inner width of the star polygon
453
- * @param spikes the amount of spikes on the star polygon
454
- * @return RShape, the shape created
455
- */
456
- public static RShape getStar(float x, float y, float widthBig, float widthSmall, int spikes) {
457
- return RShape.createStar(x, y, widthBig, widthSmall, spikes);
458
- }
459
-
460
- /**
461
- * Get a ring as a shape object.
462
- *
463
- * @eexample getRing
464
- * @param x x coordinate of the center of the shape
465
- * @param y y coordinate of the center of the shape
466
- * @param widthBig the outter width of the ring polygon
467
- * @param widthSmall the inner width of the ring polygon
468
- * @return RShape, the shape created
469
- */
470
- public static RShape getRing(float x, float y, float widthBig, float widthSmall) {
471
- return RShape.createRing(x, y, widthBig, widthSmall);
472
- }
473
-
474
- // Transformation methods
475
- public static RShape centerIn(RShape grp, PGraphics g, float margin) {
476
- RShape ret = new RShape(grp);
477
- ret.centerIn(g, margin);
478
- return ret;
479
- }
480
-
481
- public static RShape centerIn(RShape grp, PGraphics g) {
482
- return centerIn(grp, g, 0);
483
- }
484
-
485
- /**
486
- * Split a shape along the curve length in two parts.
487
- *
488
- * @eexample split
489
- * @param shp the shape to be splited
490
- * @param t the proportion (a value from 0 to 1) along the curve where to
491
- * split
492
- * @return RShape[], an array of shapes with two elements, one for each side
493
- * of the split
494
- */
495
- public static RShape[] split(RShape shp, float t) {
496
- return shp.split(t);
497
- }
498
-
499
- /**
500
- * Adapt a shape along the curve of another shape.
501
- *
502
- * @eexample split
503
- * @param shp the shape to be adapted
504
- * @param path the shape which curve will be followed
505
- * @return RShape the adapted shape
506
- * @related setAdaptor ( )
507
- */
508
- public static RShape adapt(RShape shp, RShape path) {
509
- RShape ret = new RShape(shp);
510
- ret.adapt(path);
511
- return ret;
512
- }
513
-
514
- /**
515
- * Polygonize a shape.
516
- *
517
- * @eexample split
518
- * @param shp the shape to be polygonized
519
- * @return RShape, the polygonized shape
520
- * @related setPolygonizer ( )
521
- */
522
- public static RShape polygonize(RShape shp) {
523
- RShape ret = new RShape(shp);
524
- ret.polygonize();
525
- return ret;
526
- }
527
-
528
- // State methods
529
- /**
530
- * Initialize the library. Must be called before any call to Geomerative
531
- * methods. Must be called by passing the PApplet. e.g. RG.init(this)
532
- *
533
- * @param _parent
534
- */
535
- public static void init(PApplet _parent) {
536
- parent = _parent;
537
- initialized = true;
538
- }
539
-
540
- /**
541
- * @return @invisible
542
- */
543
- public static boolean initialized() {
544
- return initialized;
545
- }
546
-
547
- /**
548
- * @return @invisible
549
- */
550
- protected static PApplet parent() {
551
- if (parent == null) {
552
- throw new LibraryNotInitializedException();
553
- }
554
-
555
- return parent;
556
- }
557
-
558
- /**
559
- * @return @invisible
560
- */
561
- protected static int dpi() {
562
- return dpi;
563
- }
564
-
565
- /**
566
- * Use this to set the resolution of the display. This specifies the Dots
567
- * Per Inch of the display.
568
- *
569
- * @param _dpi the dots per inch of the display
570
- *
571
- */
572
- public static void setDpi(int _dpi) {
573
- dpi = _dpi;
574
- }
575
-
576
- /**
577
- * Binary difference between two shapes.
578
- *
579
- * @eexample binaryOps
580
- * @param a first shape to operate on
581
- * @param b second shape to operate on
582
- * @return RShape, the result of the operation
583
- * @related diff ( )
584
- * @related union ( )
585
- * @related intersection ( )
586
- * @related xor ( )
587
- */
588
- public static RShape diff(RShape a, RShape b) {
589
- return a.diff(b);
590
- }
591
-
592
- /**
593
- * Binary union between two shapes.
594
- *
595
- * @eexample binaryOps
596
- * @param a first shape to operate on
597
- * @param b second shape to operate on
598
- * @return RShape, the result of the operation
599
- * @related diff ( )
600
- * @related union ( )
601
- * @related intersection ( )
602
- * @related xor ( )
603
- */
604
- public static RShape union(RShape a, RShape b) {
605
- return a.union(b);
606
- }
607
-
608
- /**
609
- * Binary intersection between two shapes.
610
- *
611
- * @eexample binaryOps
612
- * @param a first shape to operate on
613
- * @param b second shape to operate on
614
- * @return RShape, the result of the operation
615
- * @related diff ( )
616
- * @related union ( )
617
- * @related intersection ( )
618
- * @related xor ( )
619
- */
620
- public static RShape intersection(RShape a, RShape b) {
621
- return a.intersection(b);
622
- }
623
-
624
- /**
625
- * Binary xor between two shapes.
626
- *
627
- * @eexample binaryOps
628
- * @param a first shape to operate on
629
- * @param b second shape to operate on
630
- * @return RShape, the result of the operation
631
- * @related diff ( )
632
- * @related union ( )
633
- * @related intersection ( )
634
- * @related xor ( )
635
- */
636
- public static RShape xor(RShape a, RShape b) {
637
- return a.xor(b);
638
- }
639
-
640
- /**
641
- * Ignore the styles of the shapes when drawing and use the Processing style
642
- * methods.
643
- *
644
- * @eexample ignoreStyles
645
- * @param value value to which the ignoreStyles state should be set
646
- */
647
- public static void ignoreStyles(boolean value) {
648
- ignoreStyles = value;
649
- }
650
-
651
- public static void ignoreStyles() {
652
- ignoreStyles = true;
653
- }
654
-
655
- /**
656
- * Use this to set the adaptor type.
657
- *
658
- * @eexample RShape_setAdaptor
659
- * @param adptorType it can be RG.BYPOINT, RG.BYELEMENTPOSITION or
660
- * RG.BYELEMENTINDEX
661
- * @related BYPOINT
662
- * @related BYELEMENTPOSITION
663
- * @related BYELEMENTINDEX
664
- */
665
- public static void setAdaptor(int adptorType) {
666
- adaptorType = adptorType;
667
- }
668
-
669
- /**
670
- * Use this to set the adaptor scaling. This scales the transformation of
671
- * the adaptor.
672
- *
673
- * @eexample RShape_setAdaptor
674
- * @param adptorScale the scaling coefficient
675
- */
676
- public static void setAdaptorScale(float adptorScale) {
677
- adaptorScale = adptorScale;
678
- }
679
-
680
- /**
681
- * Use this to set the adaptor length offset. This specifies where to start
682
- * adapting the group to the shape.
683
- *
684
- * @eexample RShape_setAdaptorLengthOffset
685
- * @param adptorLengthOffset the offset along the curve of the shape. Must
686
- * be a value between 0 and 1;
687
- *
688
- */
689
- public static void setAdaptorLengthOffset(float adptorLengthOffset) throws RuntimeException {
690
- if (adptorLengthOffset >= 0F && adptorLengthOffset <= 1F) {
691
- adaptorLengthOffset = adptorLengthOffset;
692
- } else {
693
- throw new RuntimeException("The adaptor length offset must take a value between 0 and 1.");
694
- }
695
- }
696
-
697
- /**
698
- * Use this to set the polygonizer type.
699
- *
700
- * @param segmenterMethod can be RG.ADAPTATIVE, RG.UNIFORMLENGTH or
701
- * RG.UNIFORMSTEP.
702
- *
703
- * @eexample setPolygonizer
704
- * @related ADAPTATIVE
705
- * @related UNIFORMLENGTH
706
- * @related UNIFORMSTEP
707
- *
708
- */
709
- public static void setPolygonizer(int segmenterMethod) {
710
- RCommand.setSegmentator(segmenterMethod);
711
- }
712
-
713
- /**
714
- * Use this to set the segmentator angle tolerance for the ADAPTATIVE
715
- * segmentator and set the segmentator to ADAPTATIVE.
716
- *
717
- * @eexample setPolygonizerAngle
718
- * @param angle an angle from 0 to PI/2 it defines the maximum angle between
719
- * segments.
720
- * @related ADAPTATIVE
721
- *
722
- */
723
- public static void setPolygonizerAngle(float angle) {
724
- RCommand.setSegmentAngle(angle);
725
- }
726
-
727
- /**
728
- * Use this to set the segmentator length for the UNIFORMLENGTH segmentator
729
- * and set the segmentator to UNIFORMLENGTH.
730
- *
731
- * @eexample setPolygonizerLength
732
- * @param length the length of each resulting segment.
733
- * @related UNIFORMLENGTH
734
- * @related polygonize ( )
735
- */
736
- public static void setPolygonizerLength(float length) {
737
- RCommand.setSegmentLength(length);
738
- }
739
-
740
- /**
741
- * Use this to set the segmentator step for the UNIFORMSTEP segmentator and
742
- * set the segmentator to UNIFORMSTEP.
743
- *
744
- * @eexample setSegmentStep
745
- * @param step if a float from +0.0 to 1.0 is passed it's considered as the
746
- * step, else it's considered as the number of steps. When a value of 0.0 is
747
- * used the steps will be calculated automatically depending on an
748
- * estimation of the length of the curve. The special value -1 is the same
749
- * as 0.0 but also turning of the segmentation of lines (faster
750
- * segmentation).
751
- * @related UNIFORMSTEP
752
- * @related polygonize ( )
753
- */
754
- public static void setPolygonizerStep(float step) {
755
- RCommand.setSegmentStep(step);
756
- }
30
+ public class RG {
31
+
32
+ /**
33
+ *
34
+ */
35
+ private static boolean initialized = false;
36
+
37
+ /**
38
+ *
39
+ */
40
+ private static PApplet parent;
41
+
42
+ /**
43
+ *
44
+ */
45
+ public static boolean ignoreStyles = false;
46
+
47
+ /**
48
+ *
49
+ */
50
+ public static boolean useFastClip = true;
51
+
52
+ /**
53
+ * The adaptor adapts the shape to a particular shape by adapting each of the
54
+ * groups points. This can cause deformations of the individual elements in
55
+ * the group.
56
+ */
57
+ public final static int BYPOINT = 0;
58
+
59
+ /**
60
+ * The adaptor adapts the shape to a particular shape by adapting each of the
61
+ * groups elements positions. This maintains the proportions of the shapes.
62
+ */
63
+ public final static int BYELEMENTPOSITION = 1;
64
+
65
+ /**
66
+ * The adaptor adapts the shape to a particular shape by adapting each of the
67
+ * groups elements indices. This maintains the proportions of the shapes.
68
+ */
69
+ public final static int BYELEMENTINDEX = 2;
70
+
71
+ /**
72
+ *
73
+ */
74
+ static int adaptorType = BYELEMENTPOSITION;
75
+
76
+ /**
77
+ *
78
+ */
79
+ static float adaptorScale = 1F;
80
+
81
+ /**
82
+ *
83
+ */
84
+ static float adaptorLengthOffset = 0F;
85
+
86
+ /**
87
+ * ADAPTATIVE segmentator minimizes the number of segments avoiding perceptual
88
+ * artifacts like angles or cusps. Use this in order to have polygons and
89
+ * meshes with the fewest possible vertices.
90
+ */
91
+ public static int ADAPTATIVE = RCommand.ADAPTATIVE;
92
+
93
+ /**
94
+ * UNIFORMLENGTH segmentator is the slowest segmentator and it segments the
95
+ * curve on segments of equal length. This can be useful for very specific
96
+ * applications when for example drawing incrementaly a shape with a uniform
97
+ * speed.
98
+ */
99
+ public static int UNIFORMLENGTH = RCommand.UNIFORMLENGTH;
100
+
101
+ /**
102
+ * UNIFORMSTEP segmentator is the fastest segmentator and it segments the
103
+ * curve based on a constant value of the step of the curve parameter, or on
104
+ * the number of segments wanted. This can be useful when segmpointsentating
105
+ * very often a Shape or when we know the amount of segments necessary for our
106
+ * specific application.
107
+ */
108
+ public static int UNIFORMSTEP = RCommand.UNIFORMSTEP;
109
+
110
+ static int dpi = 72;
111
+
112
+ /**
113
+ *
114
+ */
115
+ public static class LibraryNotInitializedException extends NullPointerException {
116
+
117
+ private static final long serialVersionUID = -3710605630786298671L;
118
+
119
+ LibraryNotInitializedException() {
120
+ super("Must call RG.init(this); before using this library.");
121
+ }
122
+ }
123
+
124
+ /**
125
+ *
126
+ */
127
+ public static class FontNotLoadedException extends NullPointerException {
128
+
129
+ private static final long serialVersionUID = -3710605630786298672L;
130
+
131
+ FontNotLoadedException() {
132
+ super("Use RG.loadFont(filename) and RG.textFont(font, size) to load and set fonts first.");
133
+ }
134
+ }
135
+
136
+ /**
137
+ *
138
+ */
139
+ public static class NoPathInitializedException extends NullPointerException {
140
+
141
+ private static final long serialVersionUID = -3710605630786298673L;
142
+
143
+ NoPathInitializedException() {
144
+ super("Must initialize a path by calling RG.beginShape() first.");
145
+ }
146
+ }
147
+
148
+ static RShape shape;
149
+
150
+ static RFont fntLoader = null;
151
+
152
+ // Font methods
153
+ /**
154
+ * Load and get the font object that can be used in the textFont method.
155
+ *
156
+ loadFont
157
+ * @param fontFile the filename of the font to be loaded
158
+ * @return RFont, the font object
159
+ */
160
+ public static RFont loadFont(String fontFile) {
161
+ RFont newFntLoader = new RFont(fontFile);
162
+ if (fntLoader == null) {
163
+ fntLoader = newFntLoader;
164
+ }
165
+ return newFntLoader;
166
+
167
+ }
168
+
169
+ /**
170
+ * Draw text to the screen using the font set using the textFont method.
171
+ *
172
+ text
173
+ * @param text the string to be drawn on the screen
174
+ */
175
+ public static void text(String text) {
176
+ RShape grp = getText(text);
177
+ grp.draw();
178
+ }
179
+
180
+ /**
181
+ * Set the font object to be used in all text calls.
182
+ *
183
+ textFont
184
+ * @param font the font object to be set
185
+ * @param size the size of the font
186
+ */
187
+ public static void textFont(RFont font, int size) {
188
+ font.setSize(size);
189
+ fntLoader = font;
190
+ }
191
+
192
+ /**
193
+ * Get the shape corresponding to a text. Use the textFont method to select
194
+ * the font and size.
195
+ *
196
+ getText
197
+ * @param font the filename of the font to be loaded
198
+ * @param text the string to be created
199
+ * @param size the size of the font to be used
200
+ * @param align the alignment. Use RG.CENTER, RG.LEFT or RG.RIGHT
201
+ * @return RShape, the shape created
202
+ */
203
+ public static RShape getText(String text, String font, int size, int align) {
204
+ RFont tempFntLoader = new RFont(font, size, align);
205
+ return tempFntLoader.toShape(text);
206
+ }
207
+
208
+ public static RShape getText(String text) {
209
+ if (fntLoader == null) {
210
+ throw new FontNotLoadedException();
211
+ }
212
+
213
+ return fntLoader.toShape(text);
214
+ }
215
+
216
+ // Shape methods
217
+ /**
218
+ * Draw a shape to a given position on the screen.
219
+ *
220
+ shape
221
+ * @param shp the shape to be drawn
222
+ * @param x the horizontal coordinate
223
+ * @param y the vertical coordinate
224
+ * @param w the width with which we draw the shape
225
+ * @param h the height with which we draw the shape
226
+ */
227
+ public static void shape(RShape shp, float x, float y, float w, float h) {
228
+ RShape tshp = new RShape(shp);
229
+
230
+ RMatrix transf = new RMatrix();
231
+ transf.translate(x, y);
232
+ transf.scale(w / tshp.getOrigWidth(), h / tshp.getOrigHeight());
233
+ tshp.transform(transf);
234
+
235
+ tshp.draw();
236
+ }
237
+
238
+ public static void shape(RShape shp, float x, float y) {
239
+ RShape tshp = new RShape(shp);
240
+
241
+ RMatrix transf = new RMatrix();
242
+ transf.translate(x, y);
243
+ tshp.transform(transf);
244
+
245
+ tshp.draw();
246
+ }
247
+
248
+ public static void shape(RShape shp) {
249
+ shp.draw();
250
+ }
251
+
252
+ /**
253
+ * Create a shape from an array of point arrays.
254
+ *
255
+ * @param points
256
+ * @return
257
+ createShape
258
+ */
259
+ public static RShape createShape(RPoint[][] points) {
260
+ return new RShape(points);
261
+ }
262
+
263
+ /**
264
+ * Load a shape object from a file.
265
+ *
266
+ * @return
267
+ loadShape
268
+ * @param filename the SVG file to be loaded. Must be in the data directory
269
+ */
270
+ public static RShape loadShape(String filename) {
271
+ RSVG svgLoader = new RSVG();
272
+ return svgLoader.toShape(filename);
273
+ }
274
+
275
+ /**
276
+ * Save a shape object to a file.
277
+ *
278
+ saveShape
279
+ * @param filename the SVG file to be saved.
280
+ * @param shape the shape to be saved.
281
+ */
282
+ public static void saveShape(String filename, RShape shape) {
283
+ RSVG svgSaver = new RSVG();
284
+ String str = svgSaver.fromShape(shape);
285
+ String[] strs = PApplet.split(str, "\n");
286
+ RG.parent().saveStrings(filename, strs);
287
+ }
288
+
289
+ // Methods to create shapes
290
+ /**
291
+ * Begin to create a shape.
292
+ *
293
+ createShape
294
+ */
295
+ public static void beginShape() {
296
+ shape = new RShape();
297
+ }
298
+
299
+ /**
300
+ * Begin a new path in the current shape. Can only be called inside
301
+ * beginShape() and endShape().
302
+ *
303
+ * @param endMode if called with RG.CLOSE it closes the current path before
304
+ * starting the new one.
305
+ createShape
306
+ */
307
+ public static void breakShape(int endMode) {
308
+ if (endMode == PConstants.CLOSE) {
309
+ shape.addClose();
310
+ }
311
+
312
+ shape.updateOrigParams();
313
+
314
+ breakShape();
315
+ }
316
+
317
+ public static void breakShape() {
318
+ shape.addPath();
319
+ }
320
+
321
+ /**
322
+ * Add a vertex to the shape. Can only be called inside beginShape() and
323
+ * endShape().
324
+ *
325
+ createShape
326
+ * @param x the x coordinate of the vertex
327
+ * @param y the y coordinate of the vertex
328
+ */
329
+ public static void vertex(float x, float y) {
330
+ if (shape.countPaths() == 0) {
331
+ shape.addMoveTo(x, y);
332
+ } else {
333
+ shape.addLineTo(x, y);
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Add a bezierVertex to the shape. Can only be called inside beginShape() and
339
+ * endShape().
340
+ *
341
+ createShape
342
+ * @param cx1 the x coordinate of the first control point
343
+ * @param cy1 the y coordinate of the first control point
344
+ * @param cx2 the x coordinate of the second control point
345
+ * @param cy2 the y coordinate of the second control point
346
+ * @param x the x coordinate of the end point
347
+ * @param y the y coordinate of the end point
348
+ */
349
+ public static void bezierVertex(float cx1, float cy1, float cx2, float cy2, float x, float y) {
350
+ if (shape.countPaths() == 0) {
351
+ throw new NoPathInitializedException();
352
+ } else {
353
+ shape.addBezierTo(cx1, cy1, cx2, cy2, x, y);
354
+ }
355
+ }
356
+
357
+ /**
358
+ * End the shape being created and draw it to the screen or the PGraphics
359
+ * passed as parameter.
360
+ *
361
+ createShape
362
+ * @param g the canvas on which to draw. By default it draws on the screen
363
+ */
364
+ public static void endShape(PGraphics g) {
365
+ shape.draw(g);
366
+ shape = null;
367
+ }
368
+
369
+ public static void endShape() {
370
+ shape.draw();
371
+ shape = null;
372
+ }
373
+
374
+ /**
375
+ * End the shape being created and get it as an object.
376
+ *
377
+ * @return
378
+ getShape
379
+ */
380
+ public static RShape getShape() {
381
+ RShape returningGroup = new RShape();
382
+ returningGroup.addChild(shape);
383
+
384
+ shape = null;
385
+
386
+ returningGroup.updateOrigParams();
387
+
388
+ return returningGroup;
389
+ }
390
+
391
+ /**
392
+ * Get an ellipse as a shape object.
393
+ *
394
+ getEllipse
395
+ * @param x x coordinate of the center of the shape
396
+ * @param y y coordinate of the center of the shape
397
+ * @param w width of the ellipse
398
+ * @param h height of the ellipse
399
+ * @return RShape, the shape created
400
+ */
401
+ public static RShape getEllipse(float x, float y, float w, float h) {
402
+ return RShape.createEllipse(x, y, w, h);
403
+ }
404
+
405
+ public static RShape getEllipse(float x, float y, float w) {
406
+ return getEllipse(x, y, w, w);
407
+ }
408
+
409
+ /**
410
+ * Get a line as a shape object.
411
+ *
412
+ getLine
413
+ * @param x1 x coordinate of the first point of the line
414
+ * @param y1 y coordinate of the first point of the line
415
+ * @param x2 x coordinate of the last point of the line
416
+ * @param y2 y coordinate of the last point of the line
417
+ * @return RShape, the shape created
418
+ */
419
+ public static RShape getLine(float x1, float y1, float x2, float y2) {
420
+ return RShape.createLine(x1, y1, x2, y2);
421
+ }
422
+
423
+ /**
424
+ * Get an rectangle as a shape object.
425
+ *
426
+ getRect
427
+ * @param x x coordinate of the top left corner of the shape
428
+ * @param y y coordinate of the top left of the shape
429
+ * @param w width of the rectangle
430
+ * @param h height of the rectangle
431
+ * @return RShape, the shape created
432
+ */
433
+ public static RShape getRect(float x, float y, float w, float h) {
434
+ return RShape.createRectangle(x, y, w, h);
435
+ }
436
+
437
+ public static RShape getRect(float x, float y, float w) {
438
+ return getRect(x, y, w, w);
439
+ }
440
+
441
+ /**
442
+ * Get a star as a shape object.
443
+ *
444
+ getStar
445
+ * @param x x coordinate of the center of the shape
446
+ * @param y y coordinate of the center of the shape
447
+ * @param widthBig the outter width of the star polygon
448
+ * @param widthSmall the inner width of the star polygon
449
+ * @param spikes the amount of spikes on the star polygon
450
+ * @return RShape, the shape created
451
+ */
452
+ public static RShape getStar(float x, float y, float widthBig, float widthSmall, int spikes) {
453
+ return RShape.createStar(x, y, widthBig, widthSmall, spikes);
454
+ }
455
+
456
+ /**
457
+ * Get a ring as a shape object.
458
+ *
459
+ getRing
460
+ * @param x x coordinate of the center of the shape
461
+ * @param y y coordinate of the center of the shape
462
+ * @param widthBig the outter width of the ring polygon
463
+ * @param widthSmall the inner width of the ring polygon
464
+ * @return RShape, the shape created
465
+ */
466
+ public static RShape getRing(float x, float y, float widthBig, float widthSmall) {
467
+ return RShape.createRing(x, y, widthBig, widthSmall);
468
+ }
469
+
470
+ // Transformation methods
471
+ public static RShape centerIn(RShape grp, PGraphics g, float margin) {
472
+ RShape ret = new RShape(grp);
473
+ ret.centerIn(g, margin);
474
+ return ret;
475
+ }
476
+
477
+ public static RShape centerIn(RShape grp, PGraphics g) {
478
+ return centerIn(grp, g, 0);
479
+ }
480
+
481
+ /**
482
+ * Split a shape along the curve length in two parts.
483
+ *
484
+ split
485
+ * @param shp the shape to be splited
486
+ * @param t the proportion (a value from 0 to 1) along the curve where to
487
+ * split
488
+ * @return RShape[], an array of shapes with two elements, one for each side
489
+ * of the split
490
+ */
491
+ public static RShape[] split(RShape shp, float t) {
492
+ return shp.split(t);
493
+ }
494
+
495
+ /**
496
+ * Adapt a shape along the curve of another shape.
497
+ *
498
+ split
499
+ * @param shp the shape to be adapted
500
+ * @param path the shape which curve will be followed
501
+ * @return RShape the adapted shape
502
+ * setAdaptor ( )
503
+ */
504
+ public static RShape adapt(RShape shp, RShape path) {
505
+ RShape ret = new RShape(shp);
506
+ ret.adapt(path);
507
+ return ret;
508
+ }
509
+
510
+ /**
511
+ * Polygonize a shape.
512
+ *
513
+ split
514
+ * @param shp the shape to be polygonized
515
+ * @return RShape, the polygonized shape
516
+ * setPolygonizer ( )
517
+ */
518
+ public static RShape polygonize(RShape shp) {
519
+ RShape ret = new RShape(shp);
520
+ ret.polygonize();
521
+ return ret;
522
+ }
523
+
524
+ // State methods
525
+ /**
526
+ * Initialize the library. Must be called before any call to Geomerative
527
+ * methods. Must be called by passing the PApplet. e.g. RG.init(this)
528
+ *
529
+ * @param _parent
530
+ */
531
+ public static void init(PApplet _parent) {
532
+ parent = _parent;
533
+ initialized = true;
534
+ }
535
+
536
+ /**
537
+ * @return
538
+ */
539
+ public static boolean initialized() {
540
+ return initialized;
541
+ }
542
+
543
+ /**
544
+ * @return
545
+ */
546
+ protected static PApplet parent() {
547
+ if (parent == null) {
548
+ throw new LibraryNotInitializedException();
549
+ }
550
+
551
+ return parent;
552
+ }
553
+
554
+ /**
555
+ * @return
556
+ */
557
+ protected static int dpi() {
558
+ return dpi;
559
+ }
560
+
561
+ /**
562
+ * Use this to set the resolution of the display. This specifies the Dots Per
563
+ * Inch of the display.
564
+ *
565
+ * @param _dpi the dots per inch of the display
566
+ *
567
+ */
568
+ public static void setDpi(int _dpi) {
569
+ dpi = _dpi;
570
+ }
571
+
572
+ /**
573
+ * Binary difference between two shapes.
574
+ *
575
+ binaryOps
576
+ * @param a first shape to operate on
577
+ * @param b second shape to operate on
578
+ * @return RShape, the result of the operation
579
+ * diff ( )
580
+ * union ( )
581
+ * intersection ( )
582
+ * xor ( )
583
+ */
584
+ public static RShape diff(RShape a, RShape b) {
585
+ return a.diff(b);
586
+ }
587
+
588
+ /**
589
+ * Binary union between two shapes.
590
+ *
591
+ binaryOps
592
+ * @param a first shape to operate on
593
+ * @param b second shape to operate on
594
+ * @return RShape, the result of the operation
595
+ * diff ( )
596
+ * union ( )
597
+ * intersection ( )
598
+ * xor ( )
599
+ */
600
+ public static RShape union(RShape a, RShape b) {
601
+ return a.union(b);
602
+ }
603
+
604
+ /**
605
+ * Binary intersection between two shapes.
606
+ *
607
+ binaryOps
608
+ * @param a first shape to operate on
609
+ * @param b second shape to operate on
610
+ * @return RShape, the result of the operation
611
+ * diff ( )
612
+ * union ( )
613
+ * intersection ( )
614
+ * xor ( )
615
+ */
616
+ public static RShape intersection(RShape a, RShape b) {
617
+ return a.intersection(b);
618
+ }
619
+
620
+ /**
621
+ * Binary xor between two shapes.
622
+ *
623
+ binaryOps
624
+ * @param a first shape to operate on
625
+ * @param b second shape to operate on
626
+ * @return RShape, the result of the operation
627
+ * diff ( )
628
+ * union ( )
629
+ * intersection ( )
630
+ * xor ( )
631
+ */
632
+ public static RShape xor(RShape a, RShape b) {
633
+ return a.xor(b);
634
+ }
635
+
636
+ /**
637
+ * Ignore the styles of the shapes when drawing and use the Processing style
638
+ * methods.
639
+ *
640
+ ignoreStyles
641
+ * @param value value to which the ignoreStyles state should be set
642
+ */
643
+ public static void ignoreStyles(boolean value) {
644
+ ignoreStyles = value;
645
+ }
646
+
647
+ public static void ignoreStyles() {
648
+ ignoreStyles = true;
649
+ }
650
+
651
+ /**
652
+ * Use this to set the adaptor type.
653
+ *
654
+ RShape_setAdaptor
655
+ * @param adptorType it can be RG.BYPOINT, RG.BYELEMENTPOSITION or
656
+ * RG.BYELEMENTINDEX
657
+ * BYPOINT
658
+ * BYELEMENTPOSITION
659
+ * BYELEMENTINDEX
660
+ */
661
+ public static void setAdaptor(int adptorType) {
662
+ adaptorType = adptorType;
663
+ }
664
+
665
+ /**
666
+ * Use this to set the adaptor scaling. This scales the transformation of the
667
+ * adaptor.
668
+ *
669
+ RShape_setAdaptor
670
+ * @param adptorScale the scaling coefficient
671
+ */
672
+ public static void setAdaptorScale(float adptorScale) {
673
+ adaptorScale = adptorScale;
674
+ }
675
+
676
+ /**
677
+ * Use this to set the adaptor length offset. This specifies where to start
678
+ * adapting the group to the shape.
679
+ *
680
+ RShape_setAdaptorLengthOffset
681
+ * @param adptorLengthOffset the offset along the curve of the shape. Must be
682
+ * a value between 0 and 1;
683
+ *
684
+ */
685
+ public static void setAdaptorLengthOffset(float adptorLengthOffset) throws RuntimeException {
686
+ if (adptorLengthOffset >= 0F && adptorLengthOffset <= 1F) {
687
+ adaptorLengthOffset = adptorLengthOffset;
688
+ } else {
689
+ throw new RuntimeException("The adaptor length offset must take a value between 0 and 1.");
690
+ }
691
+ }
692
+
693
+ /**
694
+ * Use this to set the polygonizer type.
695
+ *
696
+ * @param segmenterMethod can be RG.ADAPTATIVE, RG.UNIFORMLENGTH or
697
+ * RG.UNIFORMSTEP.
698
+ *
699
+ setPolygonizer
700
+ * ADAPTATIVE
701
+ * UNIFORMLENGTH
702
+ * UNIFORMSTEP
703
+ *
704
+ */
705
+ public static void setPolygonizer(int segmenterMethod) {
706
+ RCommand.setSegmentator(segmenterMethod);
707
+ }
708
+
709
+ /**
710
+ * Use this to set the segmentator angle tolerance for the ADAPTATIVE
711
+ * segmentator and set the segmentator to ADAPTATIVE.
712
+ *
713
+ setPolygonizerAngle
714
+ * @param angle an angle from 0 to PI/2 it defines the maximum angle between
715
+ * segments.
716
+ * ADAPTATIVE
717
+ *
718
+ */
719
+ public static void setPolygonizerAngle(float angle) {
720
+ RCommand.setSegmentAngle(angle);
721
+ }
722
+
723
+ /**
724
+ * Use this to set the segmentator length for the UNIFORMLENGTH segmentator
725
+ * and set the segmentator to UNIFORMLENGTH.
726
+ *
727
+ setPolygonizerLength
728
+ * @param length the length of each resulting segment.
729
+ * UNIFORMLENGTH
730
+ * polygonize ( )
731
+ */
732
+ public static void setPolygonizerLength(float length) {
733
+ RCommand.setSegmentLength(length);
734
+ }
735
+
736
+ /**
737
+ * Use this to set the segmentator step for the UNIFORMSTEP segmentator and
738
+ * set the segmentator to UNIFORMSTEP.
739
+ *
740
+ setSegmentStep
741
+ * @param step if a float from +0.0 to 1.0 is passed it's considered as the
742
+ * step, else it's considered as the number of steps. When a value of 0.0 is
743
+ * used the steps will be calculated automatically depending on an estimation
744
+ * of the length of the curve. The special value -1 is the same as 0.0 but
745
+ * also turning of the segmentation of lines (faster segmentation).
746
+ * UNIFORMSTEP
747
+ * polygonize ( )
748
+ */
749
+ public static void setPolygonizerStep(float step) {
750
+ RCommand.setSegmentStep(step);
751
+ }
757
752
 
758
753
  }