geomerative 1.1.0-java → 2.0.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
3
3
  *
4
- This file is part of Geomerative.
4
+ * This file is part of Geomerative.
5
5
  *
6
6
  * Geomerative is free software: you can redistribute it and/or modify it under
7
7
  * the terms of the GNU General Public License as published by the Free Software
@@ -17,8 +17,7 @@
17
17
  * Geomerative. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  package geomerative;
20
- import java.util.Arrays;
21
- import java.util.stream.Stream;
20
+
22
21
  import processing.core.PApplet;
23
22
  import processing.core.PGraphics;
24
23
 
@@ -26,1047 +25,1055 @@ import processing.core.PGraphics;
26
25
  * RGeomElem is an interface to any geometric element that can be drawn and
27
26
  * transformed, such as shapes, polygons or meshes.
28
27
  *
29
- * @extended
28
+
30
29
  */
31
30
  public abstract class RGeomElem {
32
31
 
33
- /**
34
- * @invisible
35
- */
36
- public static final int SHAPE = 0;
37
- /**
38
- * @invisible
39
- */
40
- public static final int SUBSHAPE = 1;
41
- /**
42
- * @invisible
43
- */
44
- public static final int COMMAND = 2;
45
-
46
- /**
47
- * @invisible
48
- */
49
- public static final int POLYGON = 3;
50
- /**
51
- * @invisible
52
- */
53
- public static final int CONTOUR = 4;
54
-
55
- /**
56
- * @invisible
57
- */
58
- public static final int MESH = 5;
59
- /**
60
- * @invisible
61
- */
62
- public static final int TRISTRIP = 6;
63
-
64
- /**
65
- * @invisible
66
- */
67
- public static final int GROUP = 7;
68
-
69
- /**
70
- * @invisible
71
- */
72
- public static final int UNKNOWN = 8;
73
-
74
- /**
75
- * Shape document width.
76
- */
77
- public float width;
78
-
79
- /**
80
- * Shape document height.
81
- */
82
- public float height;
83
-
84
- float origWidth;
85
- float origHeight;
32
+ /**
33
+ *
34
+ */
35
+ public static final int SHAPE = 0;
36
+ /**
37
+ *
38
+ */
39
+ public static final int SUBSHAPE = 1;
40
+ /**
41
+ *
42
+ */
43
+ public static final int COMMAND = 2;
86
44
 
87
- // Functions dependent of the type of element
88
- // They must be overrided
89
- public abstract void draw(PGraphics g);
45
+ /**
46
+ *
47
+ */
48
+ public static final int POLYGON = 3;
49
+ /**
50
+ *
51
+ */
52
+ public static final int CONTOUR = 4;
90
53
 
91
- /**
92
- *
93
- * @param g
94
- */
95
- public abstract void draw(PApplet g);
54
+ /**
55
+ *
56
+ */
57
+ public static final int MESH = 5;
58
+ /**
59
+ *
60
+ */
61
+ public static final int TRISTRIP = 6;
96
62
 
97
- public void draw() {
98
- this.draw(RG.parent());
99
- }
63
+ /**
64
+ *
65
+ */
66
+ public static final int GROUP = 7;
100
67
 
101
- public abstract RPoint getPoint(float t);
68
+ /**
69
+ *
70
+ */
71
+ public static final int UNKNOWN = 8;
102
72
 
103
- public abstract RPoint getTangent(float t);
73
+ /**
74
+ * Shape document width.
75
+ */
76
+ public float width;
104
77
 
105
- public abstract RPoint[] getHandles();
78
+ /**
79
+ * Shape document height.
80
+ */
81
+ public float height;
106
82
 
107
- public abstract RPoint[] getPoints();
83
+ float origWidth;
84
+ float origHeight;
108
85
 
109
- public abstract RPoint[] getTangents();
86
+ // Functions dependent of the type of element
87
+ // They must be overrided
88
+ public abstract void draw(PGraphics g);
110
89
 
111
- public abstract RPoint[][] getHandlesInPaths();
90
+ /**
91
+ *
92
+ * @param g
93
+ */
94
+ public abstract void draw(PApplet g);
112
95
 
113
- public abstract RPoint[][] getPointsInPaths();
96
+ public void draw() {
97
+ this.draw(RG.parent());
98
+ }
114
99
 
115
- public abstract RPoint[][] getTangentsInPaths();
100
+ public abstract RPoint getPoint(float t);
116
101
 
117
- public abstract boolean contains(RPoint p);
102
+ public abstract RPoint getTangent(float t);
118
103
 
119
- /**
120
- * Use this method to test if the shape contains all the points of another
121
- * shape.
122
- *
123
- * @param shp
124
- * @eexample contains
125
- * @return boolean, true if the shape contains all the points of the other
126
- * shape
127
- * @related containsBounds ( )
128
- * @related containsHandles ( )
129
- */
130
- public boolean containsShape(RShape shp) {
131
- return containsPoints(shp.getPoints());
132
- }
104
+ public abstract RPoint[] getHandles();
133
105
 
134
- /**
135
- * Use this method to test if the shape contains the bounding box of another
136
- * shape.
137
- *
138
- * @param shp
139
- * @eexample contains
140
- * @return boolean, true if the shape contains the bounding box of the other
141
- * shape
142
- * @related contains ( )
143
- * @related containsHandles ( )
144
- */
145
- public boolean containsBounds(RGeomElem shp) {
146
- RPoint tl = shp.getTopLeft();
147
- RPoint tr = shp.getTopRight();
148
- RPoint bl = shp.getBottomRight();
149
- RPoint br = shp.getBottomLeft();
150
-
151
- return this.contains(tl)
152
- && this.contains(tr)
153
- && this.contains(bl)
154
- && this.contains(br);
155
- }
106
+ public abstract RPoint[] getPoints();
156
107
 
157
- /**
158
- * Use this method to test if the shape contains the handles of another
159
- * shape. This method is faster than contains(), but the results might not
160
- * be perfect.
161
- *
162
- * @param shp
163
- * @eexample contains
164
- * @return boolean, true if the shape contains all the handles of the other
165
- * shape
166
- * @related containsBounds ( )
167
- * @related contains ( )
168
- */
169
- public boolean containsHandles(RGeomElem shp) {
170
- return containsPoints(shp.getHandles());
171
- }
108
+ public abstract RPoint[] getTangents();
172
109
 
173
- /**
174
- * Use this method to test if the shape contains an array of points.
175
- *
176
- * @param pts
177
- * @eexample contains
178
- * @return boolean, true if the shape contains all the points
179
- * @related containsShape ( )
180
- * @related containsBounds ( )
181
- * @related containsHandles ( )
182
- */
183
- public boolean containsPoints(RPoint[] pts) {
184
- Stream<RPoint> outside = Arrays.stream(pts).filter(pt -> !contains(pt));
185
- return outside.count() == 0;
186
- }
187
-
188
-
189
- /**
190
- * Use this method to test if the shape intersects another shape.
191
- *
192
- * @param shp
193
- * @eexample intersects
194
- * @return boolean, true if the shape intersects all the points of the other
195
- * shape
196
- * @related intersectsBounds ( )
197
- * @related intersectsHandles ( )
198
- */
199
- public boolean intersects(RGeomElem shp) {
200
- return intersects(shp.getPoints());
201
- }
110
+ public abstract RPoint[][] getHandlesInPaths();
202
111
 
203
- /**
204
- * Use this method to test if the shape intersects the bounding box of
205
- * another shape.
206
- *
207
- * @param shp
208
- * @eexample intersects
209
- * @return boolean, true if the shape intersects the bounding box of the
210
- * other shape
211
- * @related intersects ( )
212
- * @related intersectsHandles ( )
213
- */
214
- public boolean intersectsBounds(RGeomElem shp) {
215
- RPoint tl = shp.getTopLeft();
216
- RPoint tr = shp.getTopRight();
217
- RPoint bl = shp.getBottomRight();
218
- RPoint br = shp.getBottomLeft();
219
- return (this.contains(tl)
220
- || this.contains(tr)
221
- || this.contains(bl)
222
- || this.contains(br));
223
- }
112
+ public abstract RPoint[][] getPointsInPaths();
224
113
 
225
- /**
226
- * Use this method to test if the shape intersects the handles of another
227
- * shape. This method is faster than intersects(), but the results might not
228
- * be perfect.
229
- *
230
- * @param shp
231
- * @eexample intersects
232
- * @return boolean, true if the shape intersects all the handles of the
233
- * other shape
234
- * @related intersectsBounds ( )
235
- * @related intersects ( )
236
- */
237
- public boolean intersectsHandles(RGeomElem shp) {
238
- return intersects(shp.getHandles());
239
- }
114
+ public abstract RPoint[][] getTangentsInPaths();
240
115
 
241
- /**
242
- * Use this method to test if the shape intersects an array of points.
243
- *
244
- * @param ps
245
- * @eexample intersects
246
- * @return boolean, true if the shape intersects all the points
247
- * @related intersects ( )
248
- * @related intersectsBounds ( )
249
- * @related intersectsHandles ( )
250
- */
251
- public boolean intersects(RPoint[] ps) {
252
- boolean intersects = false;
253
- if (ps != null) {
254
- for (RPoint p : ps) {
255
- intersects |= this.contains(p);
256
- }
257
- }
258
- return intersects;
259
- }
116
+ public abstract boolean contains(RPoint p);
260
117
 
261
- public abstract int getType();
118
+ /**
119
+ * Use this method to test if the shape contains all the points of another
120
+ * shape.
121
+ *
122
+ * @param shp
123
+ contains
124
+ * @return boolean, true if the shape contains all the points of the other
125
+ * shape
126
+ * containsBounds ( )
127
+ * containsHandles ( )
128
+ */
129
+ public boolean containsShape(RShape shp) {
130
+ return containsPoints(shp.getPoints());
131
+ }
132
+
133
+ /**
134
+ * Use this method to test if the shape contains the bounding box of another
135
+ * shape.
136
+ *
137
+ * @param shp
138
+ contains
139
+ * @return boolean, true if the shape contains the bounding box of the other
140
+ * shape
141
+ * contains ( )
142
+ * containsHandles ( )
143
+ */
144
+ public boolean containsBounds(RGeomElem shp) {
145
+ RPoint tl = shp.getTopLeft();
146
+ RPoint tr = shp.getTopRight();
147
+ RPoint bl = shp.getBottomRight();
148
+ RPoint br = shp.getBottomLeft();
149
+
150
+ return this.contains(tl)
151
+ && this.contains(tr)
152
+ && this.contains(bl)
153
+ && this.contains(br);
154
+ }
155
+
156
+ /**
157
+ * Use this method to test if the shape contains the handles of another shape.
158
+ * This method is faster than contains(), but the results might not be
159
+ * perfect.
160
+ *
161
+ * @param shp
162
+ contains
163
+ * @return boolean, true if the shape contains all the handles of the other
164
+ * shape
165
+ * containsBounds ( )
166
+ * contains ( )
167
+ */
168
+ public boolean containsHandles(RGeomElem shp) {
169
+ return containsPoints(shp.getHandles());
170
+ }
171
+
172
+ /**
173
+ * Use this method to test if the shape contains an array of points.
174
+ *
175
+ * @param pts
176
+ contains
177
+ * @return boolean, true if the shape contains all the points
178
+ * containsShape ( )
179
+ * containsBounds ( )
180
+ * containsHandles ( )
181
+ */
182
+ public boolean containsPoints(RPoint[] pts) {
183
+ if (pts.length == 0) {
184
+ return false;
185
+ }
186
+ boolean inside = true;
187
+ for (RPoint pt : pts) {
188
+ if (!contains(pt)) {
189
+ inside = false;
190
+ break;
191
+ }
192
+ }
193
+ return inside;
194
+ }
195
+
196
+ /**
197
+ * Use this method to test if the shape intersects another shape.
198
+ *
199
+ * @param shp
200
+ intersects
201
+ * @return boolean, true if the shape intersects all the points of the other
202
+ * shape
203
+ * intersectsBounds ( )
204
+ * intersectsHandles ( )
205
+ */
206
+ public boolean intersects(RGeomElem shp) {
207
+ return intersects(shp.getPoints());
208
+ }
209
+
210
+ /**
211
+ * Use this method to test if the shape intersects the bounding box of another
212
+ * shape.
213
+ *
214
+ * @param shp
215
+ intersects
216
+ * @return boolean, true if the shape intersects the bounding box of the other
217
+ * shape
218
+ * intersects ( )
219
+ * intersectsHandles ( )
220
+ */
221
+ public boolean intersectsBounds(RGeomElem shp) {
222
+ RPoint tl = shp.getTopLeft();
223
+ RPoint tr = shp.getTopRight();
224
+ RPoint bl = shp.getBottomRight();
225
+ RPoint br = shp.getBottomLeft();
226
+ return (this.contains(tl)
227
+ || this.contains(tr)
228
+ || this.contains(bl)
229
+ || this.contains(br));
230
+ }
231
+
232
+ /**
233
+ * Use this method to test if the shape intersects the handles of another
234
+ * shape. This method is faster than intersects(), but the results might not
235
+ * be perfect.
236
+ *
237
+ * @param shp
238
+ intersects
239
+ * @return boolean, true if the shape intersects all the handles of the other
240
+ * shape
241
+ * intersectsBounds ( )
242
+ * intersects ( )
243
+ */
244
+ public boolean intersectsHandles(RGeomElem shp) {
245
+ return intersects(shp.getHandles());
246
+ }
247
+
248
+ /**
249
+ * Use this method to test if the shape intersects an array of points.
250
+ *
251
+ * @param ps
252
+ intersects
253
+ * @return boolean, true if the shape intersects all the points
254
+ * intersects ( )
255
+ * intersectsBounds ( )
256
+ * intersectsHandles ( )
257
+ */
258
+ public boolean intersects(RPoint[] ps) {
259
+ boolean intersects = false;
260
+ if (ps != null) {
261
+ for (RPoint p : ps) {
262
+ intersects |= this.contains(p);
263
+ }
264
+ }
265
+ return intersects;
266
+ }
267
+
268
+ public abstract int getType();
262
269
 
263
270
  //public abstract RMesh toMesh();
264
- //public abstract RPolygon toPolygon();
265
- public abstract RShape toShape();
271
+ //public abstract RPolygon toPolygon();
272
+ public abstract RShape toShape();
266
273
 
267
- public void print() {
268
- }
269
- ;
274
+ public void print() {
275
+ }
276
+ ;
270
277
 
271
278
  protected float[] lenCurves;
272
- protected float lenCurve = -1F;
279
+ protected float lenCurve = -1F;
273
280
 
274
- public String name = "";
281
+ public String name = "";
275
282
 
276
- protected RStyle style = new RStyle();
283
+ protected RStyle style = new RStyle();
277
284
 
278
- public void setFill(boolean _fill) {
279
- style.setFill(_fill);
280
- }
285
+ public void setFill(boolean _fill) {
286
+ style.setFill(_fill);
287
+ }
281
288
 
282
- public void setFill(int _fillColor) {
283
- style.setFill(_fillColor);
284
- }
289
+ public void setFill(int _fillColor) {
290
+ style.setFill(_fillColor);
291
+ }
285
292
 
286
- public void setFill(String str) {
287
- style.setFill(str);
288
- }
293
+ public void setFill(String str) {
294
+ style.setFill(str);
295
+ }
289
296
 
290
- public void setStroke(boolean _stroke) {
291
- style.setStroke(_stroke);
292
- }
297
+ public void setStroke(boolean _stroke) {
298
+ style.setStroke(_stroke);
299
+ }
293
300
 
294
- public void setStroke(int _strokeColor) {
295
- style.setStroke(_strokeColor);
296
- }
301
+ public void setStroke(int _strokeColor) {
302
+ style.setStroke(_strokeColor);
303
+ }
297
304
 
298
- public void setStroke(String str) {
299
- style.setStroke(str);
300
- }
305
+ public void setStroke(String str) {
306
+ style.setStroke(str);
307
+ }
301
308
 
302
- public void setStrokeWeight(float value) {
303
- style.setStrokeWeight(value);
304
- }
309
+ public void setStrokeWeight(float value) {
310
+ style.setStrokeWeight(value);
311
+ }
305
312
 
306
- public void setStrokeWeight(String str) {
307
- style.setStrokeWeight(str);
308
- }
313
+ public void setStrokeWeight(String str) {
314
+ style.setStrokeWeight(str);
315
+ }
309
316
 
310
- public void setStrokeCap(String str) {
311
- style.setStrokeCap(str);
312
- }
317
+ public void setStrokeCap(String str) {
318
+ style.setStrokeCap(str);
319
+ }
313
320
 
314
- public void setStrokeJoin(String str) {
315
- style.setStrokeJoin(str);
316
- }
321
+ public void setStrokeJoin(String str) {
322
+ style.setStrokeJoin(str);
323
+ }
317
324
 
318
- public void setStrokeAlpha(int opacity) {
319
- style.setStrokeAlpha(opacity);
320
- }
325
+ public void setStrokeAlpha(int opacity) {
326
+ style.setStrokeAlpha(opacity);
327
+ }
321
328
 
322
- public void setStrokeAlpha(String str) {
323
- style.setStrokeAlpha(str);
324
- }
329
+ public void setStrokeAlpha(String str) {
330
+ style.setStrokeAlpha(str);
331
+ }
325
332
 
326
- public void setFillAlpha(int opacity) {
327
- style.setFillAlpha(opacity);
328
- }
333
+ public void setFillAlpha(int opacity) {
334
+ style.setFillAlpha(opacity);
335
+ }
329
336
 
330
- public void setFillAlpha(String str) {
331
- style.setFillAlpha(str);
332
- }
337
+ public void setFillAlpha(String str) {
338
+ style.setFillAlpha(str);
339
+ }
333
340
 
334
- public void setAlpha(float opacity) {
335
- style.setAlpha(opacity);
336
- }
341
+ public void setAlpha(float opacity) {
342
+ style.setAlpha(opacity);
343
+ }
337
344
 
338
- public void setAlpha(int opacity) {
339
- style.setAlpha(opacity);
340
- }
345
+ public void setAlpha(int opacity) {
346
+ style.setAlpha(opacity);
347
+ }
341
348
 
342
- public void setAlpha(String str) {
343
- style.setAlpha(str);
344
- }
349
+ public void setAlpha(String str) {
350
+ style.setAlpha(str);
351
+ }
345
352
 
346
- public RStyle getStyle() {
347
- return this.style;
348
- }
353
+ public RStyle getStyle() {
354
+ return this.style;
355
+ }
349
356
 
350
- protected void saveContext(PGraphics g) {
351
- style.saveContext(g);
352
- }
357
+ protected void saveContext(PGraphics g) {
358
+ style.saveContext(g);
359
+ }
353
360
 
354
- protected void saveContext(PApplet p) {
355
- style.saveContext(p);
356
- }
361
+ protected void saveContext(PApplet p) {
362
+ style.saveContext(p);
363
+ }
357
364
 
358
- protected void saveContext() {
359
- style.saveContext();
360
- }
365
+ protected void saveContext() {
366
+ style.saveContext();
367
+ }
361
368
 
362
- protected void restoreContext(PGraphics g) {
363
- style.restoreContext(g);
364
- }
369
+ protected void restoreContext(PGraphics g) {
370
+ style.restoreContext(g);
371
+ }
365
372
 
366
- protected void restoreContext(PApplet p) {
367
- style.restoreContext(p);
368
- }
373
+ protected void restoreContext(PApplet p) {
374
+ style.restoreContext(p);
375
+ }
369
376
 
370
- protected void restoreContext() {
371
- style.restoreContext();
372
- }
377
+ protected void restoreContext() {
378
+ style.restoreContext();
379
+ }
373
380
 
374
- protected void setContext(PGraphics g) {
375
- style.setContext(g);
376
- }
381
+ protected void setContext(PGraphics g) {
382
+ style.setContext(g);
383
+ }
377
384
 
378
- protected void setContext(PApplet p) {
379
- style.setContext(p);
380
- }
385
+ protected void setContext(PApplet p) {
386
+ style.setContext(p);
387
+ }
381
388
 
382
- protected void setContext() {
383
- style.setContext();
384
- }
389
+ protected void setContext() {
390
+ style.setContext();
391
+ }
385
392
 
386
- public void setStyle(RStyle s) {
387
- style = s;
388
- }
393
+ public void setStyle(RStyle s) {
394
+ style = s;
395
+ }
389
396
 
390
- protected void setStyle(RGeomElem p) {
391
- name = p.name;
392
- width = p.width;
393
- height = p.height;
394
- origWidth = p.origWidth;
395
- origHeight = p.origHeight;
397
+ protected void setStyle(RGeomElem p) {
398
+ name = p.name;
399
+ width = p.width;
400
+ height = p.height;
401
+ origWidth = p.origWidth;
402
+ origHeight = p.origHeight;
396
403
 
397
- style = new RStyle(p.style);
398
- }
404
+ style = new RStyle(p.style);
405
+ }
399
406
 
400
- protected void setStyle(String styleString) {
401
- style.setStyle(styleString);
402
- }
407
+ protected void setStyle(String styleString) {
408
+ style.setStyle(styleString);
409
+ }
403
410
 
404
- public void setName(String str) {
405
- this.name = str;
406
- }
411
+ public void setName(String str) {
412
+ this.name = str;
413
+ }
407
414
 
408
- protected void calculateCurveLengths() {
409
- PApplet.println("Feature not yet implemented for this class.");
410
- }
415
+ protected void calculateCurveLengths() {
416
+ PApplet.println("Feature not yet implemented for this class.");
417
+ }
411
418
 
412
- /**
413
- * Use this to return arclengths of each command on the curve.
414
- *
415
- * @eexample getCurveLength
416
- * @return float[], the arclengths of each command on the curve.
419
+ /**
420
+ * Use this to return arclengths of each command on the curve.
417
421
  *
418
- */
419
- public float[] getCurveLengths() {
420
- /* If the cache with the commands lengths is empty, we fill it up */
421
- if (lenCurves == null) {
422
- calculateCurveLengths();
423
- }
424
-
425
- return lenCurves;
426
- }
427
-
428
- /**
429
- * Use this to return the length of the curve.
430
- *
431
- * @eexample getCurveLength
432
- * @return float, the arclength of the path.
422
+ getCurveLength
423
+ * @return float[], the arclengths of each command on the curve.
433
424
  *
434
- */
435
- public float getCurveLength() {
436
- /* If the cache with the commands lengths is empty, we fill it up */
437
- if (lenCurve == -1F) {
438
- calculateCurveLengths();
439
- }
440
-
441
- return lenCurve;
442
- }
443
-
444
- public RPolygon toPolygon() {
445
- return toShape().toPolygon();
446
- }
447
-
448
- public RMesh toMesh() {
449
- return toShape().toPolygon().toMesh();
450
- }
451
-
452
- // Functions independent of the type of element
453
- // No need of being overrided
454
- public void transform(RMatrix m) {
455
- RPoint[] ps = getHandles();
456
-
457
- if (ps == null) {
458
- return;
459
- }
460
-
461
- for (RPoint p : ps) {
462
- p.transform(m);
463
- }
464
- }
465
-
466
- /**
467
- * Transform the geometric object to fit in a rectangle defined by the
468
- * parameters passed.
469
- *
470
- * @param x
471
- * @param y
472
- * @param w
473
- * @param h
474
- * @param keepAspectRatio
475
- * @eexample getBounds
476
- * @related getCenter ( )
477
- */
478
- public void transform(float x, float y, float w, float h, boolean keepAspectRatio) {
479
- RMatrix mtx = new RMatrix();
480
- RRectangle orig = this.getBounds();
481
- float orig_w = orig.getMaxX() - orig.getMinX();
482
- float orig_h = orig.getMaxY() - orig.getMinY();
483
-
484
- mtx.translate(-orig.getMinX(), -orig.getMinY());
485
- if (keepAspectRatio) {
486
- mtx.scale(Math.min(w / orig_w, h / orig_h));
487
- } else {
488
- mtx.scale(w / orig_w, h / orig_h);
489
- }
490
- mtx.translate(x, y);
491
-
492
- this.transform(mtx);
493
- }
494
-
495
- public void transform(float x, float y, float w, float h) {
496
- this.transform(x, y, w, h, true);
497
- }
498
-
499
- /**
500
- * Use this method to get the bounding box of the element.
501
- *
502
- * @eexample getBounds
503
- * @return RRectangle, the bounding box of the element in the form of a
504
- * four-point contour
505
- * @related getCenter ( )
506
- */
507
- public RRectangle getBounds() {
508
- float xmax = Float.NEGATIVE_INFINITY;
509
- float ymax = Float.NEGATIVE_INFINITY;
510
- float xmin = Float.POSITIVE_INFINITY;
511
- float ymin = Float.POSITIVE_INFINITY;
512
-
513
- RPoint[] points = getHandles();
514
-
515
- if (points != null) {
516
- for (RPoint point : points) {
517
- float tempx = point.x;
518
- float tempy = point.y;
519
- if (tempx < xmin) {
520
- xmin = tempx;
521
- }
522
- if (tempx > xmax) {
523
- xmax = tempx;
524
- }
525
- if (tempy < ymin) {
526
- ymin = tempy;
527
- }
528
- if (tempy > ymax) {
529
- ymax = tempy;
530
- }
531
- }
532
- }
533
-
534
- RRectangle c = new RRectangle(new RPoint(xmin, ymin), new RPoint(xmax, ymax));
535
- return c;
425
+ */
426
+ public float[] getCurveLengths() {
427
+ /* If the cache with the commands lengths is empty, we fill it up */
428
+ if (lenCurves == null) {
429
+ calculateCurveLengths();
536
430
  }
537
431
 
538
- /**
539
- * Use this method to get the points of the bounding box of the element.
540
- *
541
- * @eexample getBounds
542
- * @return RRectangle, the bounding box of the element in the form of a
543
- * four-point contour
544
- * @related getCenter ( )
545
- */
546
- public RPoint[] getBoundsPoints() {
547
- return getBounds().getPoints();
548
- }
549
-
550
- /**
551
- * Use this method to get the top left position of the element.
552
- *
553
- * @e
554
- * @return example getX
555
- * @related getTopRight ( )
556
- * @related getBottomLeft ( )
557
- * @related getBottomRight ( )
558
- * @related getWidth ( )
559
- * @related getHeight ( )
560
- * @related getCenter ( )
561
- */
562
- public RPoint getTopLeft() {
563
- RRectangle orig = this.getBounds();
564
- return new RPoint(orig.getMinX(), orig.getMinY());
565
- }
566
-
567
- /**
568
- * Use this method to get the top right position of the element.
569
- *
570
- * @return
571
- * @eexample getX
572
- * @related getTopRight ( )
573
- * @related getBottomLeft ( )
574
- * @related getBottomRight ( )
575
- * @related getWidth ( )
576
- * @related getHeight ( )
577
- * @related getCenter ( )
578
- */
579
- public RPoint getTopRight() {
580
- RRectangle orig = this.getBounds();
581
- return new RPoint(orig.getMaxX(), orig.getMinY());
582
- }
583
-
584
- /**
585
- * Use this method to get the bottom left position of the element.
586
- *
587
- * @return
588
- * @eexample getX
589
- * @related getTopRight ( )
590
- * @related getBottomLeft ( )
591
- * @related getBottomRight ( )
592
- * @related getWidth ( )
593
- * @related getHeight ( )
594
- * @related getCenter ( )
595
- */
596
- public RPoint getBottomLeft() {
597
- RRectangle orig = this.getBounds();
598
- return new RPoint(orig.getMinX(), orig.getMaxY());
599
- }
600
-
601
- /**
602
- * Use this method to get the bottom right position of the element.
603
- *
604
- * @return
605
- * @eexample getX
606
- * @related getTopRight ( )
607
- * @related getBottomLeft ( )
608
- * @related getBottomRight ( )
609
- * @related getWidth ( )
610
- * @related getHeight ( )
611
- * @related getCenter ( )
612
- */
613
- public RPoint getBottomRight() {
614
- RRectangle orig = this.getBounds();
615
- return new RPoint(orig.getMaxX(), orig.getMaxY());
616
- }
432
+ return lenCurves;
433
+ }
617
434
 
618
- /**
619
- * Use this method to get the x (left side) position of the element.
620
- *
621
- * @eexample getX
622
- * @return float, the x coordinate of the element
623
- * @related getY ( )
624
- * @related getWidth ( )
625
- * @related getHeight ( )
626
- * @related getCenter ( )
627
- */
628
- public float getX() {
629
- RRectangle orig = this.getBounds();
630
- return orig.getMinX();
631
- }
632
-
633
- /**
634
- * Use this method to get the y position of the element.
635
- *
636
- * @eexample getY
637
- * @return float, the y coordinate of the element
638
- * @related getY ( )
639
- * @related getWidth ( )
640
- * @related getHeight ( )
641
- * @related getCenter ( )
642
- */
643
- public float getY() {
644
- RRectangle orig = this.getBounds();
645
- return orig.getMinY();
435
+ /**
436
+ * Use this to return the length of the curve.
437
+ *
438
+ getCurveLength
439
+ * @return float, the arclength of the path.
440
+ *
441
+ */
442
+ public float getCurveLength() {
443
+ /* If the cache with the commands lengths is empty, we fill it up */
444
+ if (lenCurve == -1F) {
445
+ calculateCurveLengths();
646
446
  }
647
447
 
648
- /**
649
- * Use this method to get the original height of the element.
650
- *
651
- * @eexample getOrigHeight
652
- * @return float, the original height of the element before applying any
653
- * transformations
654
- * @related getCenter ( )
655
- */
656
- public float getOrigHeight() {
657
- return origHeight != 0.0 ? origHeight : getHeight();
658
- }
448
+ return lenCurve;
449
+ }
659
450
 
660
- /**
661
- * Use this method to get the original width of the element.
662
- *
663
- * @eexample getOrigWidth
664
- * @return float, the original width of the element before applying any
665
- * transformations
666
- * @related getCenter ( )
667
- */
668
- public float getOrigWidth() {
669
- return origWidth != 0.0 ? origWidth : getWidth();
670
- }
451
+ public RPolygon toPolygon() {
452
+ return toShape().toPolygon();
453
+ }
671
454
 
672
- protected void updateOrigParams() {
673
- this.origWidth = this.getWidth();
674
- this.origHeight = this.getHeight();
675
- }
455
+ public RMesh toMesh() {
456
+ return toShape().toPolygon().toMesh();
457
+ }
676
458
 
677
- /**
678
- * Use this method to get the width of the element.
679
- *
680
- * @eexample getWidth
681
- * @return float, the width of the element
682
- * @related getCenter ( )
683
- */
684
- public float getWidth() {
685
- RRectangle orig = this.getBounds();
686
- return orig.getMaxX() - orig.getMinX();
687
- }
459
+ // Functions independent of the type of element
460
+ // No need of being overrided
461
+ public void transform(RMatrix m) {
462
+ RPoint[] ps = getHandles();
688
463
 
689
- /**
690
- * Use this method to get the height of the element.
691
- *
692
- * @eexample getHeight
693
- * @return float, the height of the element
694
- * @related getCenter ( )
695
- */
696
- public float getHeight() {
697
- RRectangle orig = this.getBounds();
698
- return orig.getMaxY() - orig.getMinY();
464
+ if (ps == null) {
465
+ return;
699
466
  }
700
467
 
701
- /**
702
- * Use this method to get the center point of the element.
703
- *
704
- * @eexample RGroup_getCenter
705
- * @return RPoint, the center point of the element
706
- * @related getBounds ( )
707
- */
708
- public RPoint getCenter() {
709
- RRectangle c = getBounds();
710
- return new RPoint((c.getMaxX() + c.getMinX()) / 2, (c.getMaxY() + c.getMinY()) / 2);
468
+ for (RPoint p : ps) {
469
+ p.transform(m);
711
470
  }
471
+ }
712
472
 
713
- /**
714
- * Use this method to get the centroid of the element.
715
- *
716
- * @eexample RGroup_getCentroid
717
- * @return RPoint, the centroid point of the element
718
- * @related getBounds ( )
719
- * @related getCenter ( )
720
- */
721
- public RPoint getCentroid() {
722
- RPoint[] ps = getPoints();
723
-
724
- float areaAcc = 0.0f;
725
- float xAcc = 0.0f;
726
- float yAcc = 0.0f;
727
-
728
- for (int i = 0; i < ps.length - 1; i++) {
729
- areaAcc += ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y;
730
- xAcc += (ps[i].x + ps[i + 1].x) * (ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y);
731
- yAcc += (ps[i].y + ps[i + 1].y) * (ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y);
473
+ /**
474
+ * Transform the geometric object to fit in a rectangle defined by the
475
+ * parameters passed.
476
+ *
477
+ * @param x
478
+ * @param y
479
+ * @param w
480
+ * @param h
481
+ * @param keepAspectRatio
482
+ getBounds
483
+ * getCenter ( )
484
+ */
485
+ public void transform(float x, float y, float w, float h, boolean keepAspectRatio) {
486
+ RMatrix mtx = new RMatrix();
487
+ RRectangle orig = this.getBounds();
488
+ float orig_w = orig.getMaxX() - orig.getMinX();
489
+ float orig_h = orig.getMaxY() - orig.getMinY();
490
+
491
+ mtx.translate(-orig.getMinX(), -orig.getMinY());
492
+ if (keepAspectRatio) {
493
+ mtx.scale(Math.min(w / orig_w, h / orig_h));
494
+ } else {
495
+ mtx.scale(w / orig_w, h / orig_h);
496
+ }
497
+ mtx.translate(x, y);
498
+
499
+ this.transform(mtx);
500
+ }
501
+
502
+ public void transform(float x, float y, float w, float h) {
503
+ this.transform(x, y, w, h, true);
504
+ }
505
+
506
+ /**
507
+ * Use this method to get the bounding box of the element.
508
+ *
509
+ getBounds
510
+ * @return RRectangle, the bounding box of the element in the form of a
511
+ * four-point contour
512
+ * getCenter ( )
513
+ */
514
+ public RRectangle getBounds() {
515
+ float xmax = Float.NEGATIVE_INFINITY;
516
+ float ymax = Float.NEGATIVE_INFINITY;
517
+ float xmin = Float.POSITIVE_INFINITY;
518
+ float ymin = Float.POSITIVE_INFINITY;
519
+
520
+ RPoint[] points = getHandles();
521
+
522
+ if (points != null) {
523
+ for (RPoint point : points) {
524
+ float tempx = point.x;
525
+ float tempy = point.y;
526
+ if (tempx < xmin) {
527
+ xmin = tempx;
732
528
  }
733
- areaAcc /= 2.0f;
734
- RPoint p = new RPoint(xAcc / (6.0f * areaAcc), yAcc / (6.0f * areaAcc));
735
- return p;
736
- }
737
-
738
- /**
739
- * Use this method to get the area of an element.
740
- *
741
- * @eexample RGroup_getArea
742
- * @return float, the area point of the element
743
- * @related getBounds ( )
744
- * @related getCenter ( )
745
- * @related getCentroid ( )
746
- */
747
- public float getArea() {
748
- RPoint[] ps = getPoints();
749
-
750
- float areaAcc = 0.0f;
751
- for (int i = 0; i < ps.length - 1; i++) {
752
- areaAcc += ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y;
529
+ if (tempx > xmax) {
530
+ xmax = tempx;
753
531
  }
754
- areaAcc /= 2.0f;
755
- return Math.abs(areaAcc);
756
- }
757
-
758
- /**
759
- * Use this method to know if the shape is inside a graphics object. This
760
- * might be useful if we want to delete objects that go offscreen.
761
- *
762
- * @eexample RShape_isIn
763
- * @usage Geometry
764
- * @param g the graphics object
765
- * @return boolean, whether the shape is in or not the graphics object
766
- */
767
- public boolean isIn(PGraphics g) {
768
- RRectangle c = getBounds();
769
- float x0 = g.screenX(c.topLeft.x, c.topLeft.y);
770
- float y0 = g.screenY(c.topLeft.x, c.topLeft.y);
771
- float x1 = g.screenX(c.bottomRight.x, c.topLeft.y);
772
- float y1 = g.screenY(c.bottomRight.x, c.topLeft.y);
773
- float x2 = g.screenX(c.bottomRight.x, c.bottomRight.y);
774
- float y2 = g.screenY(c.bottomRight.x, c.bottomRight.y);
775
- float x3 = g.screenX(c.topLeft.x, c.bottomRight.y);
776
- float y3 = g.screenY(c.topLeft.x, c.bottomRight.y);
777
-
778
- float xmax = Math.max(Math.max(x0, x1), Math.max(x2, x3));
779
- float ymax = Math.max(Math.max(y0, y1), Math.max(y2, y3));
780
- float xmin = Math.min(Math.min(x0, x1), Math.min(x2, x3));
781
- float ymin = Math.min(Math.min(y0, y1), Math.min(y2, y3));
782
-
783
- return !((xmax < 0 || xmin > g.width) && (ymax < 0 || ymin > g.height));
784
- }
785
-
786
- public boolean isIn(PApplet g) {
787
- RRectangle c = getBounds();
788
- float x0 = g.screenX(c.topLeft.x, c.topLeft.y);
789
- float y0 = g.screenY(c.topLeft.x, c.topLeft.y);
790
- float x1 = g.screenX(c.bottomRight.x, c.topLeft.y);
791
- float y1 = g.screenY(c.bottomRight.x, c.topLeft.y);
792
- float x2 = g.screenX(c.bottomRight.x, c.bottomRight.y);
793
- float y2 = g.screenY(c.bottomRight.x, c.bottomRight.y);
794
- float x3 = g.screenX(c.topLeft.x, c.bottomRight.y);
795
- float y3 = g.screenY(c.topLeft.x, c.bottomRight.y);
796
-
797
- float xmax = Math.max(Math.max(x0, x1), Math.max(x2, x3));
798
- float ymax = Math.max(Math.max(y0, y1), Math.max(y2, y3));
799
- float xmin = Math.min(Math.min(x0, x1), Math.min(x2, x3));
800
- float ymin = Math.min(Math.min(y0, y1), Math.min(y2, y3));
801
-
802
- return !((xmax < 0 || xmin > g.width) && (ymax < 0 || ymin > g.height));
803
- }
804
-
805
- /**
806
- * Use this method to get the transformation matrix in order to fit and
807
- * center the element on the canvas. Scaling and translation damping
808
- * parameters are available, in order to create animations.
809
- *
810
- * @eexample RGeomElem_getCenteringTransf
811
- * @return RMatrix, the transformation matrix
812
- * @param g the canvas to which to fit and center the path
813
- * @param margin the margin to take into account when fitting
814
- * @param sclDamping a value from 0 to 1. The damping coefficient for the
815
- * scale, if the value is 0, then no scaling is applied.
816
- * @param trnsDamping a value from 0 to 1. The damping coefficient for the
817
- * translation, if the value is 0, then no translation is applied.
818
- * @related getBounds ( )
819
- */
820
- public RMatrix getCenteringTransf(PGraphics g, float margin, float sclDamping, float trnsDamping) throws RuntimeException {
821
- RMatrix transf;
822
-
823
- float mrgn = margin * 2;
824
- RRectangle c = getBounds();
825
- float scl = (float) Math.min((g.width - mrgn) / (float) Math.abs(c.getMinX() - c.getMaxX()), (g.height - mrgn) / (float) Math.abs(c.getMinY() - c.getMaxY()));
826
- RPoint trns = getCenter();
827
- transf = new RMatrix();
828
-
829
- if (sclDamping != 0) {
830
- transf.scale(1 + (scl - 1) * sclDamping);
532
+ if (tempy < ymin) {
533
+ ymin = tempy;
831
534
  }
832
-
833
- if (trnsDamping != 0) {
834
- transf.translate(-trns.x * trnsDamping, -trns.y * trnsDamping);
535
+ if (tempy > ymax) {
536
+ ymax = tempy;
835
537
  }
836
-
837
- return transf;
838
- }
839
-
840
- public RMatrix getCenteringTransf(PGraphics g) throws RuntimeException {
841
- return getCenteringTransf(g, 0, 1, 1);
842
- }
843
-
844
- public RMatrix getCenteringTransf(PGraphics g, float margin) throws RuntimeException {
845
- return getCenteringTransf(g, margin, 1, 1);
846
- }
847
-
848
- public void centerIn(PGraphics g) {
849
- transform(getCenteringTransf(g));
538
+ }
850
539
  }
851
540
 
852
- public void centerIn(PGraphics g, float margin) {
853
- transform(getCenteringTransf(g, margin, 1, 1));
854
- }
855
-
856
- public void centerIn(PGraphics g, float margin, float sclDamping, float trnsDamping) throws RuntimeException {
857
- transform(getCenteringTransf(g, margin, sclDamping, trnsDamping));
858
- }
859
-
860
- /**
861
- * Apply a translation to the element, given translation coordinates.
862
- *
863
- * @eexample RGeomElem_translate
864
- * @usage Geometry
865
- * @param tx the coefficient of x translation
866
- * @param ty the coefficient of y translation
867
- * @related transform ( )
868
- * @related rotate ( )
869
- * @related scale ( )
870
- */
871
- public void translate(float tx, float ty) {
872
- RMatrix transf = new RMatrix();
873
- transf.translate(tx, ty);
874
- transform(transf);
875
- }
876
-
877
- /**
878
- * Apply a translation to the element, given a point.
879
- *
880
- * @eexample RGeomElem_translate
881
- * @usage Geometry
882
- * @param t the translation vector to be applied
883
- * @related transform ( )
884
- * @related rotate ( )
885
- * @related scale ( )
886
- */
887
- public void translate(RPoint t) {
888
- RMatrix transf = new RMatrix();
889
- transf.translate(t);
890
- transform(transf);
891
- }
892
-
893
- /**
894
- * Apply a rotation to the element, given an angle and optionally a rotation
895
- * center.
896
- *
897
- * @eexample RPoint_rotate
898
- * @usage Geometry
899
- * @param angle the angle of rotation to be applied
900
- * @param vx the x coordinate of the center of rotation
901
- * @param vy the y coordinate of the center of rotation
902
- * @related transform ( )
903
- * @related translate ( )
904
- * @related scale ( )
905
- */
906
- public void rotate(float angle, float vx, float vy) {
907
- RMatrix transf = new RMatrix();
908
- transf.rotate(angle, vx, vy);
909
- transform(transf);
910
- }
911
-
912
- public void rotate(float angle) {
913
- RMatrix transf = new RMatrix();
914
- transf.rotate(angle);
915
- transform(transf);
916
- }
541
+ RRectangle c = new RRectangle(new RPoint(xmin, ymin), new RPoint(xmax, ymax));
542
+ return c;
543
+ }
917
544
 
918
- /**
919
- * Apply a rotation to the element, given an angle and optionally a rotation
920
- * center.
921
- *
922
- * @eexample RPoint_rotate
923
- * @usage Geometry
924
- * @param angle the angle of rotation to be applied
925
- * @param v the position vector of the center of rotation
926
- * @related transform ( )
927
- * @related translate ( )
928
- * @related scale ( )
929
- */
930
- public void rotate(float angle, RPoint v) {
931
- RMatrix transf = new RMatrix();
932
- transf.rotate(angle, v);
933
- transform(transf);
934
- }
935
-
936
- /**
937
- * Apply a scale to the element, given scaling factors and optionally a
938
- * scaling center.
939
- *
940
- * @eexample RPoint_scale
941
- * @usage Geometry
942
- * @param sx the scaling coefficient over the x axis
943
- * @param sy the scaling coefficient over the y axis
944
- * @param p the position vector of the center of the scaling
945
- * @related transform ( )
946
- * @related translate ( )
947
- * @related rotate ( )
948
- */
949
- public void scale(float sx, float sy, RPoint p) {
950
- RMatrix transf = new RMatrix();
951
- transf.scale(sx, sy, p);
952
- transform(transf);
953
- }
954
-
955
- public void scale(float sx, float sy) {
956
- RMatrix transf = new RMatrix();
957
- transf.scale(sx, sy);
958
- transform(transf);
959
- }
960
-
961
- /**
962
- * Apply a scale to the element, given scaling factors and optionally a
963
- * scaling center.
964
- *
965
- * @eexample RPoint_scale
966
- * @usage Geometry
967
- * @param sx the scaling coefficient over the x axis
968
- * @param sy the scaling coefficient over the y axis
969
- * @param x x coordinate of the position vector of the center of the scaling
970
- * @param y y coordinate of the position vector of the center of the scaling
971
- * @related transform ( )
972
- * @related translate ( )
973
- * @related rotate ( )
974
- */
975
- public void scale(float sx, float sy, float x, float y) {
976
- RMatrix transf = new RMatrix();
977
- transf.scale(sx, sy, x, y);
978
- transform(transf);
979
- }
980
-
981
- /**
982
- * Apply a scale to the element, given scaling factors and optionally a
983
- * scaling center.
984
- *
985
- * @eexample RPoint_scale
986
- * @usage Geometry
987
- * @param s the scaling coefficient for a uniform scaling
988
- * @param p the position vector of the center of the scaling
989
- * @related transform ( )
990
- * @related translate ( )
991
- * @related rotate ( )
992
- */
993
- public void scale(float s, RPoint p) {
994
- RMatrix transf = new RMatrix();
995
- transf.scale(s, p);
996
- transform(transf);
997
- }
998
-
999
- public void scale(float s) {
1000
- RMatrix transf = new RMatrix();
1001
- transf.scale(s);
1002
- transform(transf);
1003
- }
1004
-
1005
- /**
1006
- * Apply a scale to the element, given scaling factors and optionally a
1007
- * scaling center.
1008
- *
1009
- * @eexample RPoint_scale
1010
- * @usage Geometry
1011
- * @param s the scaling coefficient for a uniform scaling
1012
- * @param x x coordinate of the position vector of the center of the scaling
1013
- * @param y y coordinate of the position vector of the center of the scaling
1014
- * @related transform ( )
1015
- * @related translate ( )
1016
- * @related rotate ( )
1017
- */
1018
- public void scale(float s, float x, float y) {
1019
- RMatrix transf = new RMatrix();
1020
- transf.scale(s, x, y);
1021
- transform(transf);
1022
- }
1023
-
1024
- /**
1025
- * Apply a horizontal skew to the element, given skewing angle
1026
- *
1027
- * @eexample RMatrix_skewing
1028
- * @param angle skewing angle
1029
- * @usage Geometry
1030
- * @related rotate ( )
1031
- * @related scale ( )
1032
- * @related translate ( )
1033
- */
1034
- public void skewX(float angle) {
1035
- RMatrix transf = new RMatrix();
1036
- transf.skewY(angle);
1037
- transform(transf);
1038
- }
1039
-
1040
- /**
1041
- * Apply a vertical skew to the element, given skewing angle
1042
- *
1043
- * @eexample RMatrix_skewing
1044
- * @param angle skewing angle
1045
- * @usage Geometry
1046
- * @related rotate ( )
1047
- * @related scale ( )
1048
- * @related translate ( )
1049
- */
1050
- public void skewY(float angle) {
1051
- RMatrix transf = new RMatrix();
1052
- transf.skewY(angle);
1053
- transform(transf);
1054
- }
1055
-
1056
- /**
1057
- * Apply a shear to the element, given shearing factors
1058
- *
1059
- * @eexample RMatrix_translate
1060
- * @param shx x coordinate shearing
1061
- * @param shy y coordinate shearing
1062
- * @usage Geometry
1063
- * @related rotate ( )
1064
- * @related scale ( )
1065
- * @related translate ( )
1066
- */
1067
- public void shear(float shx, float shy) {
1068
- RMatrix transf = new RMatrix();
1069
- transf.shear(shx, shy);
1070
- transform(transf);
1071
- }
545
+ /**
546
+ * Use this method to get the points of the bounding box of the element.
547
+ *
548
+ getBounds
549
+ * @return RRectangle, the bounding box of the element in the form of a
550
+ * four-point contour
551
+ * getCenter ( )
552
+ */
553
+ public RPoint[] getBoundsPoints() {
554
+ return getBounds().getPoints();
555
+ }
556
+
557
+ /**
558
+ * Use this method to get the top left position of the element.
559
+ *
560
+ * @e
561
+ * @return example getX
562
+ * getTopRight ( )
563
+ * getBottomLeft ( )
564
+ * getBottomRight ( )
565
+ * getWidth ( )
566
+ * getHeight ( )
567
+ * getCenter ( )
568
+ */
569
+ public RPoint getTopLeft() {
570
+ RRectangle orig = this.getBounds();
571
+ return new RPoint(orig.getMinX(), orig.getMinY());
572
+ }
573
+
574
+ /**
575
+ * Use this method to get the top right position of the element.
576
+ *
577
+ * @return
578
+ getX
579
+ * getTopRight ( )
580
+ * getBottomLeft ( )
581
+ * getBottomRight ( )
582
+ * getWidth ( )
583
+ * getHeight ( )
584
+ * getCenter ( )
585
+ */
586
+ public RPoint getTopRight() {
587
+ RRectangle orig = this.getBounds();
588
+ return new RPoint(orig.getMaxX(), orig.getMinY());
589
+ }
590
+
591
+ /**
592
+ * Use this method to get the bottom left position of the element.
593
+ *
594
+ * @return
595
+ getX
596
+ * getTopRight ( )
597
+ * getBottomLeft ( )
598
+ * getBottomRight ( )
599
+ * getWidth ( )
600
+ * getHeight ( )
601
+ * getCenter ( )
602
+ */
603
+ public RPoint getBottomLeft() {
604
+ RRectangle orig = this.getBounds();
605
+ return new RPoint(orig.getMinX(), orig.getMaxY());
606
+ }
607
+
608
+ /**
609
+ * Use this method to get the bottom right position of the element.
610
+ *
611
+ * @return
612
+ getX
613
+ * getTopRight ( )
614
+ * getBottomLeft ( )
615
+ * getBottomRight ( )
616
+ * getWidth ( )
617
+ * getHeight ( )
618
+ * getCenter ( )
619
+ */
620
+ public RPoint getBottomRight() {
621
+ RRectangle orig = this.getBounds();
622
+ return new RPoint(orig.getMaxX(), orig.getMaxY());
623
+ }
624
+
625
+ /**
626
+ * Use this method to get the x (left side) position of the element.
627
+ *
628
+ getX
629
+ * @return float, the x coordinate of the element
630
+ * getY ( )
631
+ * getWidth ( )
632
+ * getHeight ( )
633
+ * getCenter ( )
634
+ */
635
+ public float getX() {
636
+ RRectangle orig = this.getBounds();
637
+ return orig.getMinX();
638
+ }
639
+
640
+ /**
641
+ * Use this method to get the y position of the element.
642
+ *
643
+ getY
644
+ * @return float, the y coordinate of the element
645
+ * getY ( )
646
+ * getWidth ( )
647
+ * getHeight ( )
648
+ * getCenter ( )
649
+ */
650
+ public float getY() {
651
+ RRectangle orig = this.getBounds();
652
+ return orig.getMinY();
653
+ }
654
+
655
+ /**
656
+ * Use this method to get the original height of the element.
657
+ *
658
+ getOrigHeight
659
+ * @return float, the original height of the element before applying any
660
+ * transformations
661
+ * getCenter ( )
662
+ */
663
+ public float getOrigHeight() {
664
+ return origHeight != 0.0 ? origHeight : getHeight();
665
+ }
666
+
667
+ /**
668
+ * Use this method to get the original width of the element.
669
+ *
670
+ getOrigWidth
671
+ * @return float, the original width of the element before applying any
672
+ * transformations
673
+ * getCenter ( )
674
+ */
675
+ public float getOrigWidth() {
676
+ return origWidth != 0.0 ? origWidth : getWidth();
677
+ }
678
+
679
+ protected void updateOrigParams() {
680
+ this.origWidth = this.getWidth();
681
+ this.origHeight = this.getHeight();
682
+ }
683
+
684
+ /**
685
+ * Use this method to get the width of the element.
686
+ *
687
+ getWidth
688
+ * @return float, the width of the element
689
+ * getCenter ( )
690
+ */
691
+ public float getWidth() {
692
+ RRectangle orig = this.getBounds();
693
+ return orig.getMaxX() - orig.getMinX();
694
+ }
695
+
696
+ /**
697
+ * Use this method to get the height of the element.
698
+ *
699
+ getHeight
700
+ * @return float, the height of the element
701
+ * getCenter ( )
702
+ */
703
+ public float getHeight() {
704
+ RRectangle orig = this.getBounds();
705
+ return orig.getMaxY() - orig.getMinY();
706
+ }
707
+
708
+ /**
709
+ * Use this method to get the center point of the element.
710
+ *
711
+ RGroup_getCenter
712
+ * @return RPoint, the center point of the element
713
+ * getBounds ( )
714
+ */
715
+ public RPoint getCenter() {
716
+ RRectangle c = getBounds();
717
+ return new RPoint((c.getMaxX() + c.getMinX()) / 2, (c.getMaxY() + c.getMinY()) / 2);
718
+ }
719
+
720
+ /**
721
+ * Use this method to get the centroid of the element.
722
+ *
723
+ RGroup_getCentroid
724
+ * @return RPoint, the centroid point of the element
725
+ * getBounds ( )
726
+ * getCenter ( )
727
+ */
728
+ public RPoint getCentroid() {
729
+ RPoint[] ps = getPoints();
730
+
731
+ float areaAcc = 0.0f;
732
+ float xAcc = 0.0f;
733
+ float yAcc = 0.0f;
734
+
735
+ for (int i = 0; i < ps.length - 1; i++) {
736
+ areaAcc += ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y;
737
+ xAcc += (ps[i].x + ps[i + 1].x) * (ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y);
738
+ yAcc += (ps[i].y + ps[i + 1].y) * (ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y);
739
+ }
740
+ areaAcc /= 2.0f;
741
+ RPoint p = new RPoint(xAcc / (6.0f * areaAcc), yAcc / (6.0f * areaAcc));
742
+ return p;
743
+ }
744
+
745
+ /**
746
+ * Use this method to get the area of an element.
747
+ *
748
+ RGroup_getArea
749
+ * @return float, the area point of the element
750
+ * getBounds ( )
751
+ * getCenter ( )
752
+ * getCentroid ( )
753
+ */
754
+ public float getArea() {
755
+ RPoint[] ps = getPoints();
756
+
757
+ float areaAcc = 0.0f;
758
+ for (int i = 0; i < ps.length - 1; i++) {
759
+ areaAcc += ps[i].x * ps[i + 1].y - ps[i + 1].x * ps[i].y;
760
+ }
761
+ areaAcc /= 2.0f;
762
+ return Math.abs(areaAcc);
763
+ }
764
+
765
+ /**
766
+ * Use this method to know if the shape is inside a graphics object. This
767
+ * might be useful if we want to delete objects that go offscreen.
768
+ *
769
+ RShape_isIn
770
+ * Geometry
771
+ * @param g the graphics object
772
+ * @return boolean, whether the shape is in or not the graphics object
773
+ */
774
+ public boolean isIn(PGraphics g) {
775
+ RRectangle c = getBounds();
776
+ float x0 = g.screenX(c.topLeft.x, c.topLeft.y);
777
+ float y0 = g.screenY(c.topLeft.x, c.topLeft.y);
778
+ float x1 = g.screenX(c.bottomRight.x, c.topLeft.y);
779
+ float y1 = g.screenY(c.bottomRight.x, c.topLeft.y);
780
+ float x2 = g.screenX(c.bottomRight.x, c.bottomRight.y);
781
+ float y2 = g.screenY(c.bottomRight.x, c.bottomRight.y);
782
+ float x3 = g.screenX(c.topLeft.x, c.bottomRight.y);
783
+ float y3 = g.screenY(c.topLeft.x, c.bottomRight.y);
784
+
785
+ float xmax = Math.max(Math.max(x0, x1), Math.max(x2, x3));
786
+ float ymax = Math.max(Math.max(y0, y1), Math.max(y2, y3));
787
+ float xmin = Math.min(Math.min(x0, x1), Math.min(x2, x3));
788
+ float ymin = Math.min(Math.min(y0, y1), Math.min(y2, y3));
789
+
790
+ return !((xmax < 0 || xmin > g.width) && (ymax < 0 || ymin > g.height));
791
+ }
792
+
793
+ public boolean isIn(PApplet g) {
794
+ RRectangle c = getBounds();
795
+ float x0 = g.screenX(c.topLeft.x, c.topLeft.y);
796
+ float y0 = g.screenY(c.topLeft.x, c.topLeft.y);
797
+ float x1 = g.screenX(c.bottomRight.x, c.topLeft.y);
798
+ float y1 = g.screenY(c.bottomRight.x, c.topLeft.y);
799
+ float x2 = g.screenX(c.bottomRight.x, c.bottomRight.y);
800
+ float y2 = g.screenY(c.bottomRight.x, c.bottomRight.y);
801
+ float x3 = g.screenX(c.topLeft.x, c.bottomRight.y);
802
+ float y3 = g.screenY(c.topLeft.x, c.bottomRight.y);
803
+
804
+ float xmax = Math.max(Math.max(x0, x1), Math.max(x2, x3));
805
+ float ymax = Math.max(Math.max(y0, y1), Math.max(y2, y3));
806
+ float xmin = Math.min(Math.min(x0, x1), Math.min(x2, x3));
807
+ float ymin = Math.min(Math.min(y0, y1), Math.min(y2, y3));
808
+
809
+ return !((xmax < 0 || xmin > g.width) && (ymax < 0 || ymin > g.height));
810
+ }
811
+
812
+ /**
813
+ * Use this method to get the transformation matrix in order to fit and center
814
+ * the element on the canvas. Scaling and translation damping parameters are
815
+ * available, in order to create animations.
816
+ *
817
+ RGeomElem_getCenteringTransf
818
+ * @return RMatrix, the transformation matrix
819
+ * @param g the canvas to which to fit and center the path
820
+ * @param margin the margin to take into account when fitting
821
+ * @param sclDamping a value from 0 to 1. The damping coefficient for the
822
+ * scale, if the value is 0, then no scaling is applied.
823
+ * @param trnsDamping a value from 0 to 1. The damping coefficient for the
824
+ * translation, if the value is 0, then no translation is applied.
825
+ * getBounds ( )
826
+ */
827
+ public RMatrix getCenteringTransf(PGraphics g, float margin, float sclDamping, float trnsDamping) throws RuntimeException {
828
+ RMatrix transf;
829
+
830
+ float mrgn = margin * 2;
831
+ RRectangle c = getBounds();
832
+ float scl = (float) Math.min((g.width - mrgn) / (float) Math.abs(c.getMinX() - c.getMaxX()), (g.height - mrgn) / (float) Math.abs(c.getMinY() - c.getMaxY()));
833
+ RPoint trns = getCenter();
834
+ transf = new RMatrix();
835
+
836
+ if (sclDamping != 0) {
837
+ transf.scale(1 + (scl - 1) * sclDamping);
838
+ }
839
+
840
+ if (trnsDamping != 0) {
841
+ transf.translate(-trns.x * trnsDamping, -trns.y * trnsDamping);
842
+ }
843
+
844
+ return transf;
845
+ }
846
+
847
+ public RMatrix getCenteringTransf(PGraphics g) throws RuntimeException {
848
+ return getCenteringTransf(g, 0, 1, 1);
849
+ }
850
+
851
+ public RMatrix getCenteringTransf(PGraphics g, float margin) throws RuntimeException {
852
+ return getCenteringTransf(g, margin, 1, 1);
853
+ }
854
+
855
+ public void centerIn(PGraphics g) {
856
+ transform(getCenteringTransf(g));
857
+ }
858
+
859
+ public void centerIn(PGraphics g, float margin) {
860
+ transform(getCenteringTransf(g, margin, 1, 1));
861
+ }
862
+
863
+ public void centerIn(PGraphics g, float margin, float sclDamping, float trnsDamping) throws RuntimeException {
864
+ transform(getCenteringTransf(g, margin, sclDamping, trnsDamping));
865
+ }
866
+
867
+ /**
868
+ * Apply a translation to the element, given translation coordinates.
869
+ *
870
+ RGeomElem_translate
871
+ * Geometry
872
+ * @param tx the coefficient of x translation
873
+ * @param ty the coefficient of y translation
874
+ * transform ( )
875
+ * rotate ( )
876
+ * scale ( )
877
+ */
878
+ public void translate(float tx, float ty) {
879
+ RMatrix transf = new RMatrix();
880
+ transf.translate(tx, ty);
881
+ transform(transf);
882
+ }
883
+
884
+ /**
885
+ * Apply a translation to the element, given a point.
886
+ *
887
+ RGeomElem_translate
888
+ * Geometry
889
+ * @param t the translation vector to be applied
890
+ * transform ( )
891
+ * rotate ( )
892
+ * scale ( )
893
+ */
894
+ public void translate(RPoint t) {
895
+ RMatrix transf = new RMatrix();
896
+ transf.translate(t);
897
+ transform(transf);
898
+ }
899
+
900
+ /**
901
+ * Apply a rotation to the element, given an angle and optionally a rotation
902
+ * center.
903
+ *
904
+ RPoint_rotate
905
+ * Geometry
906
+ * @param angle the angle of rotation to be applied
907
+ * @param vx the x coordinate of the center of rotation
908
+ * @param vy the y coordinate of the center of rotation
909
+ * transform ( )
910
+ * translate ( )
911
+ * scale ( )
912
+ */
913
+ public void rotate(float angle, float vx, float vy) {
914
+ RMatrix transf = new RMatrix();
915
+ transf.rotate(angle, vx, vy);
916
+ transform(transf);
917
+ }
918
+
919
+ public void rotate(float angle) {
920
+ RMatrix transf = new RMatrix();
921
+ transf.rotate(angle);
922
+ transform(transf);
923
+ }
924
+
925
+ /**
926
+ * Apply a rotation to the element, given an angle and optionally a rotation
927
+ * center.
928
+ *
929
+ RPoint_rotate
930
+ * Geometry
931
+ * @param angle the angle of rotation to be applied
932
+ * @param v the position vector of the center of rotation
933
+ * transform ( )
934
+ * translate ( )
935
+ * scale ( )
936
+ */
937
+ public void rotate(float angle, RPoint v) {
938
+ RMatrix transf = new RMatrix();
939
+ transf.rotate(angle, v);
940
+ transform(transf);
941
+ }
942
+
943
+ /**
944
+ * Apply a scale to the element, given scaling factors and optionally a
945
+ * scaling center.
946
+ *
947
+ RPoint_scale
948
+ * Geometry
949
+ * @param sx the scaling coefficient over the x axis
950
+ * @param sy the scaling coefficient over the y axis
951
+ * @param p the position vector of the center of the scaling
952
+ * transform ( )
953
+ * translate ( )
954
+ * rotate ( )
955
+ */
956
+ public void scale(float sx, float sy, RPoint p) {
957
+ RMatrix transf = new RMatrix();
958
+ transf.scale(sx, sy, p);
959
+ transform(transf);
960
+ }
961
+
962
+ public void scale(float sx, float sy) {
963
+ RMatrix transf = new RMatrix();
964
+ transf.scale(sx, sy);
965
+ transform(transf);
966
+ }
967
+
968
+ /**
969
+ * Apply a scale to the element, given scaling factors and optionally a
970
+ * scaling center.
971
+ *
972
+ RPoint_scale
973
+ * Geometry
974
+ * @param sx the scaling coefficient over the x axis
975
+ * @param sy the scaling coefficient over the y axis
976
+ * @param x x coordinate of the position vector of the center of the scaling
977
+ * @param y y coordinate of the position vector of the center of the scaling
978
+ * transform ( )
979
+ * translate ( )
980
+ * rotate ( )
981
+ */
982
+ public void scale(float sx, float sy, float x, float y) {
983
+ RMatrix transf = new RMatrix();
984
+ transf.scale(sx, sy, x, y);
985
+ transform(transf);
986
+ }
987
+
988
+ /**
989
+ * Apply a scale to the element, given scaling factors and optionally a
990
+ * scaling center.
991
+ *
992
+ RPoint_scale
993
+ * Geometry
994
+ * @param s the scaling coefficient for a uniform scaling
995
+ * @param p the position vector of the center of the scaling
996
+ * transform ( )
997
+ * translate ( )
998
+ * rotate ( )
999
+ */
1000
+ public void scale(float s, RPoint p) {
1001
+ RMatrix transf = new RMatrix();
1002
+ transf.scale(s, p);
1003
+ transform(transf);
1004
+ }
1005
+
1006
+ public void scale(float s) {
1007
+ RMatrix transf = new RMatrix();
1008
+ transf.scale(s);
1009
+ transform(transf);
1010
+ }
1011
+
1012
+ /**
1013
+ * Apply a scale to the element, given scaling factors and optionally a
1014
+ * scaling center.
1015
+ *
1016
+ RPoint_scale
1017
+ * Geometry
1018
+ * @param s the scaling coefficient for a uniform scaling
1019
+ * @param x x coordinate of the position vector of the center of the scaling
1020
+ * @param y y coordinate of the position vector of the center of the scaling
1021
+ * transform ( )
1022
+ * translate ( )
1023
+ * rotate ( )
1024
+ */
1025
+ public void scale(float s, float x, float y) {
1026
+ RMatrix transf = new RMatrix();
1027
+ transf.scale(s, x, y);
1028
+ transform(transf);
1029
+ }
1030
+
1031
+ /**
1032
+ * Apply a horizontal skew to the element, given skewing angle
1033
+ *
1034
+ RMatrix_skewing
1035
+ * @param angle skewing angle
1036
+ * Geometry
1037
+ * rotate ( )
1038
+ * scale ( )
1039
+ * translate ( )
1040
+ */
1041
+ public void skewX(float angle) {
1042
+ RMatrix transf = new RMatrix();
1043
+ transf.skewY(angle);
1044
+ transform(transf);
1045
+ }
1046
+
1047
+ /**
1048
+ * Apply a vertical skew to the element, given skewing angle
1049
+ *
1050
+ RMatrix_skewing
1051
+ * @param angle skewing angle
1052
+ * Geometry
1053
+ * rotate ( )
1054
+ * scale ( )
1055
+ * translate ( )
1056
+ */
1057
+ public void skewY(float angle) {
1058
+ RMatrix transf = new RMatrix();
1059
+ transf.skewY(angle);
1060
+ transform(transf);
1061
+ }
1062
+
1063
+ /**
1064
+ * Apply a shear to the element, given shearing factors
1065
+ *
1066
+ RMatrix_translate
1067
+ * @param shx x coordinate shearing
1068
+ * @param shy y coordinate shearing
1069
+ * Geometry
1070
+ * rotate ( )
1071
+ * scale ( )
1072
+ * translate ( )
1073
+ */
1074
+ public void shear(float shx, float shy) {
1075
+ RMatrix transf = new RMatrix();
1076
+ transf.shear(shx, shy);
1077
+ transform(transf);
1078
+ }
1072
1079
  }