geomerative 0.4.3-java → 2.1.0-java

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