geomerative 1.1.0-java → 2.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +3 -0
- data/COPYING.md +1 -1
- data/README.md +0 -1
- data/Rakefile +2 -15
- data/docs/_includes/header.html +6 -6
- data/docs/_includes/icon-github.svg +3 -1
- data/docs/_includes/icon-twitter.svg +3 -1
- data/docs/_includes/navigation.html +18 -18
- data/docs/_sass/_base.scss +79 -79
- data/docs/_sass/_layout.scss +137 -137
- data/docs/_sass/_syntax-highlighting.scss +64 -64
- data/docs/index.html +18 -18
- data/examples/data/bot1.svg +1 -1
- data/examples/data/lion.svg +156 -156
- data/examples/data/ruby.svg +1 -1
- data/geomerative.gemspec +1 -2
- data/lib/geomerative/version.rb +1 -1
- data/mvnw +234 -0
- data/mvnw.cmd +145 -0
- data/pom.rb +14 -13
- data/pom.xml +14 -13
- data/src/geomerative/FastRClip.java +2149 -2156
- data/src/geomerative/RClip.java +2237 -2539
- data/src/geomerative/RClosest.java +33 -31
- data/src/geomerative/RCommand.java +1750 -1758
- data/src/geomerative/RContour.java +290 -292
- data/src/geomerative/RFont.java +277 -246
- data/src/geomerative/RG.java +722 -727
- data/src/geomerative/RGeomElem.java +967 -960
- data/src/geomerative/RGroup.java +508 -467
- data/src/geomerative/RMatrix.java +304 -289
- data/src/geomerative/RMesh.java +241 -229
- data/src/geomerative/RPath.java +924 -925
- data/src/geomerative/RPoint.java +391 -391
- data/src/geomerative/RPolygon.java +998 -988
- data/src/geomerative/RRectangle.java +43 -52
- data/src/geomerative/RSVG.java +480 -516
- data/src/geomerative/RShape.java +1767 -1777
- data/src/geomerative/RStrip.java +173 -176
- data/src/geomerative/RStyle.java +197 -194
- data/src/org/apache/batik/svggen/font/Font.java +141 -142
- data/src/org/apache/batik/svggen/font/Glyph.java +102 -71
- data/src/org/apache/batik/svggen/font/Point.java +12 -12
- data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +14 -12
- data/src/org/apache/batik/svggen/font/table/ClassDef.java +12 -12
- data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +27 -24
- data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +20 -17
- data/src/org/apache/batik/svggen/font/table/CmapFormat.java +43 -43
- data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +33 -26
- data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +25 -20
- data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +106 -96
- data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +36 -32
- data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +69 -49
- data/src/org/apache/batik/svggen/font/table/CmapTable.java +50 -50
- data/src/org/apache/batik/svggen/font/table/Coverage.java +19 -19
- data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +30 -27
- data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +26 -24
- data/src/org/apache/batik/svggen/font/table/CvtTable.java +16 -16
- data/src/org/apache/batik/svggen/font/table/Device.java +32 -32
- data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +39 -39
- data/src/org/apache/batik/svggen/font/table/Feature.java +26 -23
- data/src/org/apache/batik/svggen/font/table/FeatureList.java +37 -35
- data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +22 -22
- data/src/org/apache/batik/svggen/font/table/FeatureTags.java +4 -3
- data/src/org/apache/batik/svggen/font/table/FpgmTable.java +9 -9
- data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +134 -132
- data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +123 -122
- data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +44 -44
- data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +110 -109
- data/src/org/apache/batik/svggen/font/table/GlyfTable.java +46 -46
- data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +25 -13
- data/src/org/apache/batik/svggen/font/table/GposTable.java +26 -23
- data/src/org/apache/batik/svggen/font/table/GsubTable.java +85 -82
- data/src/org/apache/batik/svggen/font/table/HeadTable.java +131 -131
- data/src/org/apache/batik/svggen/font/table/HheaTable.java +80 -80
- data/src/org/apache/batik/svggen/font/table/HmtxTable.java +50 -49
- data/src/org/apache/batik/svggen/font/table/KernSubtable.java +29 -27
- data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +35 -32
- data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +28 -26
- data/src/org/apache/batik/svggen/font/table/KernTable.java +36 -31
- data/src/org/apache/batik/svggen/font/table/KerningPair.java +27 -23
- data/src/org/apache/batik/svggen/font/table/LangSys.java +28 -26
- data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +22 -22
- data/src/org/apache/batik/svggen/font/table/Ligature.java +24 -24
- data/src/org/apache/batik/svggen/font/table/LigatureSet.java +24 -24
- data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +9 -9
- data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +30 -30
- data/src/org/apache/batik/svggen/font/table/LocaTable.java +37 -37
- data/src/org/apache/batik/svggen/font/table/Lookup.java +41 -40
- data/src/org/apache/batik/svggen/font/table/LookupList.java +34 -34
- data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +7 -5
- data/src/org/apache/batik/svggen/font/table/MaxpTable.java +96 -96
- data/src/org/apache/batik/svggen/font/table/NameRecord.java +64 -65
- data/src/org/apache/batik/svggen/font/table/NameTable.java +33 -33
- data/src/org/apache/batik/svggen/font/table/Os2Table.java +196 -196
- data/src/org/apache/batik/svggen/font/table/Panose.java +14 -12
- data/src/org/apache/batik/svggen/font/table/PostTable.java +338 -338
- data/src/org/apache/batik/svggen/font/table/PrepTable.java +9 -9
- data/src/org/apache/batik/svggen/font/table/Program.java +15 -15
- data/src/org/apache/batik/svggen/font/table/RangeRecord.java +26 -25
- data/src/org/apache/batik/svggen/font/table/Script.java +38 -38
- data/src/org/apache/batik/svggen/font/table/ScriptList.java +42 -42
- data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +22 -22
- data/src/org/apache/batik/svggen/font/table/ScriptTags.java +2 -1
- data/src/org/apache/batik/svggen/font/table/SingleSubst.java +15 -16
- data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +33 -33
- data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +32 -32
- data/src/org/apache/batik/svggen/font/table/Table.java +171 -170
- data/src/org/apache/batik/svggen/font/table/TableDirectory.java +55 -55
- data/src/org/apache/batik/svggen/font/table/TableFactory.java +92 -93
- metadata +10 -11
- data/.travis.yml +0 -9
data/src/geomerative/RStrip.java
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
|
3
3
|
*
|
4
|
-
|
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
|
@@ -18,208 +18,205 @@
|
|
18
18
|
*/
|
19
19
|
package geomerative;
|
20
20
|
|
21
|
-
|
22
|
-
|
23
21
|
import processing.core.PConstants;
|
24
22
|
import processing.core.PGraphics;
|
25
23
|
|
26
|
-
|
27
24
|
/**
|
28
25
|
* RStrip is a reduced interface for creating, holding and drawing triangle
|
29
26
|
* strips. Triangle strips are ordered lists of points (RPoint) which define the
|
30
27
|
* vertices of a mesh.
|
31
28
|
*
|
32
|
-
|
33
|
-
*
|
34
|
-
*
|
35
|
-
*
|
36
|
-
|
29
|
+
RStrip
|
30
|
+
* Geometry
|
31
|
+
* RPoint
|
32
|
+
* RMesh
|
33
|
+
|
37
34
|
*/
|
38
35
|
public class RStrip {
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
/**
|
46
|
-
* Array of RPoint objects holding the vertices of the strip.
|
47
|
-
*
|
48
|
-
* @eexample vertices
|
49
|
-
* @related RPoint
|
50
|
-
* @related countVertices ( )
|
51
|
-
* @related addVertex ( )
|
52
|
-
*/
|
53
|
-
public RPoint vertices[];
|
54
|
-
|
55
|
-
// ----------------------
|
56
|
-
// --- Public Methods ---
|
57
|
-
// ----------------------
|
58
|
-
/**
|
59
|
-
* Use this method to create a new strip.
|
60
|
-
*
|
61
|
-
* @eexample RStrip ( )
|
62
|
-
* @related addVertex ( )
|
63
|
-
* @param s the object of which to make a copy
|
64
|
-
*/
|
65
|
-
public RStrip(RStrip s) {
|
66
|
-
for (int i = 0; i < s.countVertices(); i++) {
|
67
|
-
this.append(new RPoint(s.vertices[i]));
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
public RStrip() {
|
72
|
-
vertices = null;
|
73
|
-
}
|
37
|
+
/**
|
38
|
+
*
|
39
|
+
*/
|
40
|
+
public int type = RGeomElem.TRISTRIP;
|
74
41
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
-
|
86
|
-
return this.vertices.length;
|
87
|
-
}
|
42
|
+
/**
|
43
|
+
* Array of RPoint objects holding the vertices of the strip.
|
44
|
+
*
|
45
|
+
vertices
|
46
|
+
* RPoint
|
47
|
+
* countVertices ( )
|
48
|
+
* addVertex ( )
|
49
|
+
*/
|
50
|
+
public RPoint vertices[];
|
88
51
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
52
|
+
// ----------------------
|
53
|
+
// --- Public Methods ---
|
54
|
+
// ----------------------
|
55
|
+
/**
|
56
|
+
* Use this method to create a new strip.
|
57
|
+
*
|
58
|
+
RStrip ( )
|
59
|
+
* addVertex ( )
|
60
|
+
* @param s the object of which to make a copy
|
61
|
+
*/
|
62
|
+
public RStrip(RStrip s) {
|
63
|
+
for (int i = 0; i < s.countVertices(); i++) {
|
64
|
+
this.append(new RPoint(s.vertices[i]));
|
102
65
|
}
|
66
|
+
}
|
103
67
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
* @param p
|
108
|
-
* @eexample addVertex ( )
|
109
|
-
*/
|
110
|
-
public void addVertex(RPoint p) {
|
111
|
-
this.append(p);
|
112
|
-
}
|
68
|
+
public RStrip() {
|
69
|
+
vertices = null;
|
70
|
+
}
|
113
71
|
|
114
|
-
|
115
|
-
|
72
|
+
/**
|
73
|
+
* Use this method to count the number of vertices in the strip.
|
74
|
+
*
|
75
|
+
countVertices
|
76
|
+
* @return int, the number vertices in the strip
|
77
|
+
*/
|
78
|
+
public int countVertices() {
|
79
|
+
if (this.vertices == null) {
|
80
|
+
return 0;
|
116
81
|
}
|
117
82
|
|
118
|
-
|
119
|
-
|
120
|
-
*
|
121
|
-
* @eexample getBounds
|
122
|
-
* @return RContour, the bounding box of the strip in the form of a
|
123
|
-
* four-point contour
|
124
|
-
* @related draw ( )
|
125
|
-
*/
|
126
|
-
public RContour getBounds() {
|
127
|
-
float xmin = Float.MAX_VALUE;
|
128
|
-
float ymin = Float.MAX_VALUE;
|
129
|
-
float xmax = -Float.MAX_VALUE;
|
130
|
-
float ymax = -Float.MAX_VALUE;
|
131
|
-
|
132
|
-
for (int i = 0; i < this.countVertices(); i++) {
|
133
|
-
float x = this.vertices[i].x;
|
134
|
-
float y = this.vertices[i].y;
|
135
|
-
if (x < xmin) {
|
136
|
-
xmin = x;
|
137
|
-
}
|
138
|
-
if (x > xmax) {
|
139
|
-
xmax = x;
|
140
|
-
}
|
141
|
-
if (y < ymin) {
|
142
|
-
ymin = y;
|
143
|
-
}
|
144
|
-
if (y > ymax) {
|
145
|
-
ymax = y;
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
|
-
RContour c = new RContour();
|
150
|
-
c.addPoint(xmin, ymin);
|
151
|
-
c.addPoint(xmin, ymax);
|
152
|
-
c.addPoint(xmax, ymax);
|
153
|
-
c.addPoint(xmax, ymin);
|
154
|
-
return c;
|
155
|
-
}
|
83
|
+
return this.vertices.length;
|
84
|
+
}
|
156
85
|
|
157
|
-
|
158
|
-
|
159
|
-
* array of RPoint.
|
160
|
-
*
|
161
|
-
* @eexample RStrip_getHandles
|
162
|
-
* @return RPoint[], the vertices returned in an array.
|
86
|
+
/**
|
87
|
+
* Use this method to draw the strip.
|
163
88
|
*
|
164
|
-
|
165
|
-
|
166
|
-
|
89
|
+
drawStrip
|
90
|
+
* @param g PGraphics, the graphics object on which to draw the strip
|
91
|
+
*/
|
92
|
+
public void draw(PGraphics g) {
|
93
|
+
int numVertices = countVertices();
|
94
|
+
g.beginShape(PConstants.TRIANGLE_STRIP);
|
95
|
+
for (int i = 0; i < numVertices; i++) {
|
96
|
+
g.vertex(vertices[i].x, vertices[i].y);
|
167
97
|
}
|
98
|
+
g.endShape();
|
99
|
+
}
|
168
100
|
|
169
|
-
|
170
|
-
|
171
|
-
* array of RPoint.
|
172
|
-
*
|
173
|
-
* @eexample RStrip_getPoints
|
174
|
-
* @return RPoint[], the vertices returned in an array.
|
101
|
+
/**
|
102
|
+
* Use this method to add new vertices to the strip.
|
175
103
|
*
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
104
|
+
* @param p
|
105
|
+
addVertex ( )
|
106
|
+
*/
|
107
|
+
public void addVertex(RPoint p) {
|
108
|
+
this.append(p);
|
109
|
+
}
|
110
|
+
|
111
|
+
public void addVertex(float x, float y) {
|
112
|
+
this.append(new RPoint(x, y));
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Use this method to get the bounding box of the strip.
|
117
|
+
*
|
118
|
+
getBounds
|
119
|
+
* @return RContour, the bounding box of the strip in the form of a four-point
|
120
|
+
* contour
|
121
|
+
* draw ( )
|
122
|
+
*/
|
123
|
+
public RContour getBounds() {
|
124
|
+
float xmin = Float.MAX_VALUE;
|
125
|
+
float ymin = Float.MAX_VALUE;
|
126
|
+
float xmax = -Float.MAX_VALUE;
|
127
|
+
float ymax = -Float.MAX_VALUE;
|
128
|
+
|
129
|
+
for (int i = 0; i < this.countVertices(); i++) {
|
130
|
+
float x = this.vertices[i].x;
|
131
|
+
float y = this.vertices[i].y;
|
132
|
+
if (x < xmin) {
|
133
|
+
xmin = x;
|
134
|
+
}
|
135
|
+
if (x > xmax) {
|
136
|
+
xmax = x;
|
137
|
+
}
|
138
|
+
if (y < ymin) {
|
139
|
+
ymin = y;
|
140
|
+
}
|
141
|
+
if (y > ymax) {
|
142
|
+
ymax = y;
|
143
|
+
}
|
199
144
|
}
|
200
145
|
|
201
|
-
|
202
|
-
|
203
|
-
|
146
|
+
RContour c = new RContour();
|
147
|
+
c.addPoint(xmin, ymin);
|
148
|
+
c.addPoint(xmin, ymax);
|
149
|
+
c.addPoint(xmax, ymax);
|
150
|
+
c.addPoint(xmax, ymin);
|
151
|
+
return c;
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Use this to get the vertices of the strip. It returns the points as an
|
156
|
+
* array of RPoint.
|
157
|
+
*
|
158
|
+
RStrip_getHandles
|
159
|
+
* @return RPoint[], the vertices returned in an array.
|
160
|
+
*
|
161
|
+
*/
|
162
|
+
public RPoint[] getHandles() {
|
163
|
+
return vertices;
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Use this to get the vertices of the strip. It returns the points as an
|
168
|
+
* array of RPoint.
|
169
|
+
*
|
170
|
+
RStrip_getPoints
|
171
|
+
* @return RPoint[], the vertices returned in an array.
|
172
|
+
*
|
173
|
+
*/
|
174
|
+
public RPoint[] getPoints() {
|
175
|
+
return vertices;
|
176
|
+
}
|
204
177
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
178
|
+
/**
|
179
|
+
* Use this method to transform the strip.
|
180
|
+
*
|
181
|
+
transformStrip
|
182
|
+
* @param m RMatrix, the matrix of the affine transformation to apply to the
|
183
|
+
* strip
|
184
|
+
*/
|
185
|
+
public void transform(RMatrix m) {
|
186
|
+
int numVertices = countVertices();
|
187
|
+
if (numVertices != 0) {
|
188
|
+
for (int i = 0; i < numVertices; i++) {
|
189
|
+
vertices[i].transform(m);
|
190
|
+
}
|
210
191
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
192
|
+
}
|
193
|
+
|
194
|
+
void add(RPoint p) {
|
195
|
+
this.append(p);
|
196
|
+
}
|
197
|
+
|
198
|
+
void add(float x, float y) {
|
199
|
+
this.append(new RPoint(x, y));
|
200
|
+
}
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Remove all of the points. Creates an empty polygon.
|
204
|
+
*/
|
205
|
+
void clear() {
|
206
|
+
this.vertices = null;
|
207
|
+
}
|
208
|
+
|
209
|
+
final void append(RPoint nextvertex) {
|
210
|
+
RPoint[] newvertices;
|
211
|
+
if (vertices == null) {
|
212
|
+
newvertices = new RPoint[1];
|
213
|
+
newvertices[0] = nextvertex;
|
214
|
+
} else {
|
215
|
+
newvertices = new RPoint[this.vertices.length + 1];
|
216
|
+
System.arraycopy(this.vertices, 0, newvertices, 0, this.vertices.length);
|
217
|
+
newvertices[this.vertices.length] = nextvertex;
|
223
218
|
}
|
219
|
+
this.vertices = newvertices;
|
220
|
+
}
|
224
221
|
|
225
222
|
}
|
data/src/geomerative/RStyle.java
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
/**
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
*/
|
19
|
-
|
20
|
-
package geomerative ;
|
2
|
+
* Copyright 2004-2008 Ricard Marxer <email@ricardmarxer.com>
|
3
|
+
*
|
4
|
+
* This file is part of Geomerative.
|
5
|
+
*
|
6
|
+
* Geomerative is free software: you can redistribute it and/or modify it under
|
7
|
+
* the terms of the GNU General Public License as published by the Free Software
|
8
|
+
* Foundation, either version 3 of the License, or (at your option) any later
|
9
|
+
* version.
|
10
|
+
*
|
11
|
+
* Geomerative is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14
|
+
* details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU General Public License along with
|
17
|
+
* Geomerative. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
*/
|
19
|
+
package geomerative;
|
21
20
|
|
22
21
|
import processing.core.PApplet;
|
23
22
|
import processing.core.PConstants;
|
@@ -25,11 +24,12 @@ import processing.core.PGraphics;
|
|
25
24
|
import processing.core.PImage;
|
26
25
|
|
27
26
|
/**
|
28
|
-
|
29
|
-
*/
|
30
|
-
public class RStyle{
|
27
|
+
|
28
|
+
*/
|
29
|
+
public class RStyle {
|
30
|
+
|
31
31
|
public PImage texture = null;
|
32
|
-
|
32
|
+
|
33
33
|
public boolean fillDef = false;
|
34
34
|
public boolean fill = false;
|
35
35
|
public int fillColor = 0xff000000;
|
@@ -43,7 +43,7 @@ public class RStyle{
|
|
43
43
|
|
44
44
|
public boolean strokeAlphaDef = false;
|
45
45
|
public int strokeAlpha = 0xff000000;
|
46
|
-
|
46
|
+
|
47
47
|
public boolean strokeWeightDef = false;
|
48
48
|
public float strokeWeight = 1F;
|
49
49
|
|
@@ -55,24 +55,25 @@ public class RStyle{
|
|
55
55
|
|
56
56
|
private boolean oldFill = false;
|
57
57
|
private int oldFillColor = 0;
|
58
|
-
|
58
|
+
|
59
59
|
private boolean oldStroke = false;
|
60
60
|
private int oldStrokeColor = 0;
|
61
61
|
private float oldStrokeWeight = 1F;
|
62
62
|
private int oldStrokeCap = PConstants.PROJECT;
|
63
63
|
private int oldStrokeJoin = PConstants.MITER;
|
64
64
|
|
65
|
-
public RStyle(){
|
65
|
+
public RStyle() {
|
66
|
+
}
|
66
67
|
|
67
|
-
public RStyle(RStyle p){
|
68
|
+
public RStyle(RStyle p) {
|
68
69
|
texture = p.texture;
|
69
|
-
|
70
|
+
|
70
71
|
fillDef = p.fillDef;
|
71
72
|
fill = p.fill;
|
72
73
|
fillColor = p.fillColor;
|
73
74
|
fillAlphaDef = p.fillAlphaDef;
|
74
75
|
fillAlpha = p.fillAlpha;
|
75
|
-
|
76
|
+
|
76
77
|
strokeDef = p.strokeDef;
|
77
78
|
stroke = p.stroke;
|
78
79
|
strokeColor = p.strokeColor;
|
@@ -89,173 +90,172 @@ public class RStyle{
|
|
89
90
|
strokeJoin = p.strokeJoin;
|
90
91
|
}
|
91
92
|
|
92
|
-
protected void setStyle(String styleString){
|
93
|
+
protected void setStyle(String styleString) {
|
93
94
|
//RG.parent().println("Style parsing: " + styleString);
|
94
95
|
String[] styleTokens = PApplet.splitTokens(styleString, ";");
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
96
|
+
|
97
|
+
for (String styleToken : styleTokens) {
|
98
|
+
String[] tokens = PApplet.splitTokens(styleToken, ":");
|
99
|
+
tokens[0] = PApplet.trim(tokens[0]);
|
100
|
+
switch (tokens[0]) {
|
101
|
+
case "fill":
|
102
|
+
setFill(tokens[1]);
|
103
|
+
break;
|
104
|
+
case "fill-opacity":
|
105
|
+
setFillAlpha(tokens[1]);
|
106
|
+
break;
|
107
|
+
case "stroke":
|
108
|
+
setStroke(tokens[1]);
|
109
|
+
break;
|
110
|
+
case "stroke-width":
|
111
|
+
setStrokeWeight(tokens[1]);
|
112
|
+
break;
|
113
|
+
case "stroke-linecap":
|
114
|
+
setStrokeCap(tokens[1]);
|
115
|
+
break;
|
116
|
+
case "stroke-linejoin":
|
117
|
+
setStrokeJoin(tokens[1]);
|
118
|
+
break;
|
119
|
+
case "stroke-opacity":
|
120
|
+
setStrokeAlpha(tokens[1]);
|
121
|
+
break;
|
122
|
+
case "opacity":
|
123
|
+
setAlpha(tokens[1]);
|
124
|
+
break;
|
125
|
+
default:
|
126
|
+
PApplet.println("Attribute '" + tokens[0] + "' not known. Ignoring it.");
|
127
|
+
break;
|
128
128
|
}
|
129
|
+
}
|
129
130
|
}
|
130
131
|
|
131
|
-
public void setFill(boolean _fill){
|
132
|
+
public void setFill(boolean _fill) {
|
132
133
|
fillDef = true;
|
133
134
|
fill = _fill;
|
134
135
|
}
|
135
136
|
|
136
|
-
public void setFill(int _fillColor){
|
137
|
+
public void setFill(int _fillColor) {
|
137
138
|
//RG.parent().println("Setting fill by int: " + RG.parent().hex(_fillColor));
|
138
139
|
setFill(true);
|
139
140
|
fillColor = (fillColor & 0xff000000) | (_fillColor & 0x00ffffff);
|
140
141
|
}
|
141
142
|
|
142
|
-
public void setFill(String str){
|
143
|
+
public void setFill(String str) {
|
143
144
|
//RG.parent().println("id: " + id);
|
144
145
|
//RG.parent().println(" set fill: " + str);
|
145
|
-
if(str.equals("none")){
|
146
|
+
if (str.equals("none")) {
|
146
147
|
setFill(false);
|
147
148
|
|
148
|
-
}else{
|
149
|
+
} else {
|
149
150
|
setFill(getColor(str));
|
150
151
|
|
151
152
|
}
|
152
153
|
//RG.parent().println(" fillColor after: " + RG.parent().hex(fillColor));
|
153
154
|
}
|
154
155
|
|
155
|
-
public void setStroke(boolean _stroke){
|
156
|
+
public void setStroke(boolean _stroke) {
|
156
157
|
strokeDef = true;
|
157
158
|
stroke = _stroke;
|
158
159
|
}
|
159
160
|
|
160
|
-
public void setStroke(int _strokeColor){
|
161
|
+
public void setStroke(int _strokeColor) {
|
161
162
|
setStroke(true);
|
162
163
|
strokeColor = (strokeColor & 0xff000000) | (_strokeColor & 0x00ffffff);
|
163
164
|
}
|
164
165
|
|
165
|
-
public void setStroke(String str){
|
166
|
+
public void setStroke(String str) {
|
166
167
|
//RG.parent().println(" set stroke: " + str);
|
167
|
-
if(str.equals("none")){
|
168
|
+
if (str.equals("none")) {
|
168
169
|
setStroke(false);
|
169
170
|
|
170
|
-
}else{
|
171
|
+
} else {
|
171
172
|
setStroke(getColor(str));
|
172
|
-
|
173
|
+
|
173
174
|
}
|
174
175
|
}
|
175
176
|
|
176
|
-
public void setStrokeWeight(float value){
|
177
|
+
public void setStrokeWeight(float value) {
|
177
178
|
//RG.parent().println(" set strokeWeight by float: " + value);
|
178
179
|
strokeWeightDef = true;
|
179
180
|
strokeWeight = value;
|
180
181
|
}
|
181
182
|
|
182
|
-
public void setStrokeWeight(String str){
|
183
|
+
public void setStrokeWeight(String str) {
|
183
184
|
//RG.parent().println(" set strokeWeight by String: " + str);
|
184
|
-
if(str.endsWith("px")){
|
185
|
+
if (str.endsWith("px")) {
|
185
186
|
setStrokeWeight(PApplet.parseFloat(str.substring(0, str.length() - 2)));
|
186
|
-
}else{
|
187
|
+
} else {
|
187
188
|
setStrokeWeight(PApplet.parseFloat(str));
|
188
189
|
}
|
189
190
|
|
190
|
-
|
191
191
|
}
|
192
192
|
|
193
|
-
public void setStrokeCap(String str){
|
193
|
+
public void setStrokeCap(String str) {
|
194
194
|
//RG.parent().println(" set stroke-cap: " + str);
|
195
195
|
strokeCapDef = true;
|
196
196
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
197
|
+
switch (str) {
|
198
|
+
case "butt":
|
199
|
+
strokeCap = PConstants.PROJECT;
|
200
|
+
break;
|
201
|
+
case "round":
|
202
|
+
strokeCap = PConstants.ROUND;
|
203
|
+
break;
|
204
|
+
case "square":
|
205
|
+
strokeCap = PConstants.SQUARE;
|
206
|
+
break;
|
207
|
+
}
|
208
208
|
}
|
209
209
|
|
210
|
-
public void setStrokeJoin(String str){
|
210
|
+
public void setStrokeJoin(String str) {
|
211
211
|
//RG.parent().println(" set stroke-cap: " + str);
|
212
212
|
strokeJoinDef = true;
|
213
213
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
214
|
+
switch (str) {
|
215
|
+
case "miter":
|
216
|
+
strokeJoin = PConstants.MITER;
|
217
|
+
break;
|
218
|
+
case "round":
|
219
|
+
strokeJoin = PConstants.ROUND;
|
220
|
+
break;
|
221
|
+
case "bevel":
|
222
|
+
strokeJoin = PConstants.BEVEL;
|
223
|
+
break;
|
224
|
+
}
|
225
225
|
}
|
226
226
|
|
227
|
-
public void setStrokeAlpha(int opacity){
|
227
|
+
public void setStrokeAlpha(int opacity) {
|
228
228
|
strokeAlphaDef = true;
|
229
229
|
strokeAlpha = opacity;
|
230
230
|
}
|
231
231
|
|
232
|
-
public void setStrokeAlpha(String str){
|
233
|
-
setStrokeAlpha((int)(PApplet.parseFloat(str) * 255F));
|
232
|
+
public void setStrokeAlpha(String str) {
|
233
|
+
setStrokeAlpha((int) (PApplet.parseFloat(str) * 255F));
|
234
234
|
}
|
235
235
|
|
236
|
-
public void setFillAlpha(int opacity){
|
236
|
+
public void setFillAlpha(int opacity) {
|
237
237
|
fillAlphaDef = true;
|
238
238
|
fillAlpha = opacity;
|
239
239
|
}
|
240
240
|
|
241
|
-
public void setFillAlpha(String str){
|
241
|
+
public void setFillAlpha(String str) {
|
242
242
|
//RG.parent().println(" set fillOpacity: " + str);
|
243
|
-
setFillAlpha((int)(PApplet.parseFloat(str) * 255F));
|
243
|
+
setFillAlpha((int) (PApplet.parseFloat(str) * 255F));
|
244
244
|
//RG.parent().println(" fillColor after: " + RG.parent().hex(fillColor));
|
245
|
-
}
|
245
|
+
}
|
246
246
|
|
247
|
-
public void setAlpha(float opacity){
|
247
|
+
public void setAlpha(float opacity) {
|
248
248
|
//RG.parent().println("Setting float opacity: " + opacity);
|
249
|
-
setAlpha((int)(opacity * 100F));
|
249
|
+
setAlpha((int) (opacity * 100F));
|
250
250
|
}
|
251
251
|
|
252
|
-
public void setAlpha(int opacity){
|
252
|
+
public void setAlpha(int opacity) {
|
253
253
|
/*
|
254
254
|
RG.parent().println("setting opacity: " + RG.parent().hex(opacity));
|
255
255
|
|
256
256
|
RG.parent().println(" fillColor before: " + RG.parent().hex(fillColor));
|
257
257
|
RG.parent().println(" strokeColor before: " + RG.parent().hex(fillColor));
|
258
|
-
|
258
|
+
*/
|
259
259
|
|
260
260
|
setFillAlpha(opacity);
|
261
261
|
setStrokeAlpha(opacity);
|
@@ -266,15 +266,15 @@ public class RStyle{
|
|
266
266
|
/*
|
267
267
|
RG.parent().println(" fillColor now: " + RG.parent().hex(fillColor));
|
268
268
|
RG.parent().println(" strokeColor now: " + RG.parent().hex(fillColor));
|
269
|
-
|
269
|
+
*/
|
270
270
|
}
|
271
271
|
|
272
|
-
public void setAlpha(String str){
|
272
|
+
public void setAlpha(String str) {
|
273
273
|
//RG.parent().println("Setting string opacity: " + str);
|
274
274
|
setAlpha(PApplet.parseFloat(str));
|
275
275
|
}
|
276
276
|
|
277
|
-
protected void saveContext(PGraphics g){
|
277
|
+
protected void saveContext(PGraphics g) {
|
278
278
|
oldFill = g.fill;
|
279
279
|
oldFillColor = g.fillColor;
|
280
280
|
oldStroke = g.stroke;
|
@@ -284,189 +284,192 @@ public class RStyle{
|
|
284
284
|
oldStrokeJoin = g.strokeJoin;
|
285
285
|
}
|
286
286
|
|
287
|
-
protected void saveContext(PApplet p){
|
287
|
+
protected void saveContext(PApplet p) {
|
288
288
|
oldFill = p.g.fill;
|
289
289
|
oldFillColor = p.g.fillColor;
|
290
290
|
oldStroke = p.g.stroke;
|
291
291
|
oldStrokeColor = p.g.strokeColor;
|
292
|
-
oldStrokeWeight = p.g.strokeWeight;
|
292
|
+
oldStrokeWeight = p.g.strokeWeight;
|
293
293
|
oldStrokeCap = p.g.strokeCap;
|
294
294
|
oldStrokeJoin = p.g.strokeJoin;
|
295
295
|
}
|
296
296
|
|
297
|
-
protected void saveContext(){
|
297
|
+
protected void saveContext() {
|
298
298
|
saveContext(RG.parent());
|
299
299
|
}
|
300
300
|
|
301
|
-
protected void restoreContext(PGraphics g){
|
301
|
+
protected void restoreContext(PGraphics g) {
|
302
302
|
g.fill(oldFillColor);
|
303
|
-
if(!oldFill){
|
303
|
+
if (!oldFill) {
|
304
304
|
g.noFill();
|
305
305
|
}
|
306
306
|
|
307
307
|
g.stroke(oldStrokeColor);
|
308
308
|
g.strokeWeight(oldStrokeWeight);
|
309
309
|
|
310
|
-
try{
|
310
|
+
try {
|
311
311
|
g.strokeCap(oldStrokeCap);
|
312
312
|
g.strokeJoin(oldStrokeJoin);
|
313
|
-
}catch(RuntimeException e){
|
313
|
+
} catch (RuntimeException e) {
|
314
|
+
}
|
314
315
|
|
315
|
-
if(!oldStroke){
|
316
|
+
if (!oldStroke) {
|
316
317
|
g.noStroke();
|
317
318
|
}
|
318
319
|
}
|
319
320
|
|
320
|
-
protected void restoreContext(PApplet p){
|
321
|
+
protected void restoreContext(PApplet p) {
|
321
322
|
p.fill(oldFillColor);
|
322
|
-
if(!oldFill){
|
323
|
+
if (!oldFill) {
|
323
324
|
p.noFill();
|
324
325
|
}
|
325
326
|
|
326
327
|
p.stroke(oldStrokeColor);
|
327
328
|
p.strokeWeight(oldStrokeWeight);
|
328
329
|
|
329
|
-
try{
|
330
|
+
try {
|
330
331
|
p.strokeCap(oldStrokeCap);
|
331
332
|
p.strokeJoin(oldStrokeJoin);
|
332
|
-
}catch(RuntimeException e){
|
333
|
+
} catch (RuntimeException e) {
|
334
|
+
}
|
333
335
|
|
334
|
-
if(!oldStroke){
|
336
|
+
if (!oldStroke) {
|
335
337
|
p.noStroke();
|
336
|
-
}
|
338
|
+
}
|
337
339
|
}
|
338
340
|
|
339
|
-
protected void restoreContext(){
|
341
|
+
protected void restoreContext() {
|
340
342
|
restoreContext(RG.parent());
|
341
343
|
}
|
342
344
|
|
343
|
-
protected void setContext(PGraphics g){
|
344
|
-
if(fillAlphaDef){
|
345
|
-
if(fillDef){
|
345
|
+
protected void setContext(PGraphics g) {
|
346
|
+
if (fillAlphaDef) {
|
347
|
+
if (fillDef) {
|
346
348
|
fillColor = ((fillAlpha << 24) & 0xff000000) | (fillColor & 0x00ffffff);
|
347
|
-
}else{
|
348
|
-
if(g.fill){
|
349
|
+
} else {
|
350
|
+
if (g.fill) {
|
349
351
|
g.fill(((fillAlpha << 24) & 0xff000000) | (g.fillColor & 0x00ffffff));
|
350
352
|
}
|
351
353
|
}
|
352
354
|
}
|
353
355
|
|
354
|
-
if(fillDef){
|
356
|
+
if (fillDef) {
|
355
357
|
g.fill(fillColor);
|
356
|
-
if(!fill){
|
358
|
+
if (!fill) {
|
357
359
|
g.noFill();
|
358
360
|
}
|
359
361
|
}
|
360
362
|
|
361
|
-
if(strokeWeightDef){
|
363
|
+
if (strokeWeightDef) {
|
362
364
|
g.strokeWeight(strokeWeight);
|
363
365
|
}
|
364
366
|
|
365
|
-
try{
|
366
|
-
if(strokeCapDef){
|
367
|
+
try {
|
368
|
+
if (strokeCapDef) {
|
367
369
|
g.strokeCap(strokeCap);
|
368
370
|
}
|
369
|
-
|
370
|
-
if(strokeJoinDef){
|
371
|
+
|
372
|
+
if (strokeJoinDef) {
|
371
373
|
g.strokeJoin(strokeJoin);
|
372
374
|
}
|
373
|
-
}catch(RuntimeException e){
|
375
|
+
} catch (RuntimeException e) {
|
376
|
+
}
|
374
377
|
|
375
|
-
if(strokeAlphaDef){
|
376
|
-
if(strokeDef){
|
378
|
+
if (strokeAlphaDef) {
|
379
|
+
if (strokeDef) {
|
377
380
|
strokeColor = ((strokeAlpha << 24) & 0xff000000) | (strokeColor & 0x00ffffff);
|
378
|
-
}else{
|
379
|
-
if(g.stroke){
|
381
|
+
} else {
|
382
|
+
if (g.stroke) {
|
380
383
|
g.stroke(((strokeAlpha << 24) & 0xff000000) | (g.strokeColor & 0x00ffffff));
|
381
384
|
}
|
382
385
|
}
|
383
386
|
}
|
384
|
-
|
385
|
-
if(strokeDef){
|
387
|
+
|
388
|
+
if (strokeDef) {
|
386
389
|
g.stroke(strokeColor);
|
387
|
-
if(!stroke){
|
390
|
+
if (!stroke) {
|
388
391
|
g.noStroke();
|
389
392
|
}
|
390
393
|
}
|
391
394
|
}
|
392
395
|
|
393
|
-
protected void setContext(PApplet p){
|
394
|
-
|
395
|
-
if(fillAlphaDef){
|
396
|
-
if(fillDef){
|
396
|
+
protected void setContext(PApplet p) {
|
397
|
+
|
398
|
+
if (fillAlphaDef) {
|
399
|
+
if (fillDef) {
|
397
400
|
fillColor = ((fillAlpha << 24) & 0xff000000) | (fillColor & 0x00ffffff);
|
398
|
-
}else{
|
399
|
-
if(p.g.fill){
|
401
|
+
} else {
|
402
|
+
if (p.g.fill) {
|
400
403
|
p.fill(((fillAlpha << 24) & 0xff000000) | (p.g.fillColor & 0x00ffffff));
|
401
404
|
}
|
402
405
|
}
|
403
406
|
}
|
404
|
-
|
405
|
-
if(fillDef){
|
407
|
+
|
408
|
+
if (fillDef) {
|
406
409
|
p.fill(fillColor);
|
407
|
-
if(!fill){
|
410
|
+
if (!fill) {
|
408
411
|
p.noFill();
|
409
412
|
}
|
410
413
|
}
|
411
414
|
|
412
|
-
if(strokeWeightDef){
|
415
|
+
if (strokeWeightDef) {
|
413
416
|
p.strokeWeight(strokeWeight);
|
414
417
|
}
|
415
418
|
|
416
|
-
try{
|
417
|
-
if(strokeCapDef){
|
419
|
+
try {
|
420
|
+
if (strokeCapDef) {
|
418
421
|
p.strokeCap(strokeCap);
|
419
422
|
}
|
420
|
-
|
421
|
-
if(strokeJoinDef){
|
423
|
+
|
424
|
+
if (strokeJoinDef) {
|
422
425
|
p.strokeJoin(strokeJoin);
|
423
426
|
}
|
424
|
-
}catch(RuntimeException e){
|
427
|
+
} catch (RuntimeException e) {
|
428
|
+
}
|
425
429
|
|
426
|
-
if(strokeAlphaDef){
|
427
|
-
if(strokeDef){
|
430
|
+
if (strokeAlphaDef) {
|
431
|
+
if (strokeDef) {
|
428
432
|
strokeColor = ((strokeAlpha << 24) & 0xff000000) | (strokeColor & 0x00ffffff);
|
429
|
-
}else{
|
430
|
-
if(p.g.stroke){
|
433
|
+
} else {
|
434
|
+
if (p.g.stroke) {
|
431
435
|
p.stroke(((strokeAlpha << 24) & 0xff000000) | (p.g.strokeColor & 0x00ffffff));
|
432
436
|
}
|
433
437
|
}
|
434
438
|
}
|
435
439
|
|
436
|
-
if(strokeDef){
|
440
|
+
if (strokeDef) {
|
437
441
|
p.stroke(strokeColor);
|
438
|
-
if(!stroke){
|
442
|
+
if (!stroke) {
|
439
443
|
p.noStroke();
|
440
444
|
}
|
441
445
|
}
|
442
446
|
}
|
443
447
|
|
444
|
-
protected void setContext(){
|
448
|
+
protected void setContext() {
|
445
449
|
setContext(RG.parent());
|
446
450
|
}
|
447
451
|
|
448
|
-
|
449
|
-
private int getColor(String colorString){
|
452
|
+
private int getColor(String colorString) {
|
450
453
|
colorString = PApplet.trim(colorString);
|
451
|
-
|
452
|
-
if(colorString.startsWith("#")){
|
453
|
-
return PApplet.unhex("FF"+colorString.substring(1));
|
454
|
-
}else if(colorString.startsWith("rgb")){
|
454
|
+
|
455
|
+
if (colorString.startsWith("#")) {
|
456
|
+
return PApplet.unhex("FF" + colorString.substring(1));
|
457
|
+
} else if (colorString.startsWith("rgb")) {
|
455
458
|
String[] rgb = PApplet.splitTokens(colorString, "rgb( , )");
|
456
|
-
return (int)RG.parent().color(PApplet.parseInt(rgb[0]), PApplet.parseInt(rgb[1]), PApplet.parseInt(rgb[2]));
|
457
|
-
}else{
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
459
|
+
return (int) RG.parent().color(PApplet.parseInt(rgb[0]), PApplet.parseInt(rgb[1]), PApplet.parseInt(rgb[2]));
|
460
|
+
} else {
|
461
|
+
switch (colorString) {
|
462
|
+
case "black":
|
463
|
+
return 0;
|
464
|
+
case "red":
|
465
|
+
return RG.parent().color(255, 0, 0);
|
466
|
+
case "green":
|
467
|
+
return RG.parent().color(0, 255, 0);
|
468
|
+
case "blue":
|
469
|
+
return RG.parent().color(0, 0, 255);
|
470
|
+
case "yellow":
|
471
|
+
return RG.parent().color(0, 255, 255);
|
472
|
+
}
|
470
473
|
}
|
471
474
|
return 0;
|
472
475
|
}
|