FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/core/src/processing/core/PShape.java at master · 2php/processing · GitHub
2php
processing
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
core
/
src
/
processing
/
core
/
PShape.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
3445 lines (2720 loc) · 86.5 KB
Breadcrumbs
processing
/
core
/
src
/
processing
/
core
/
PShape.java
Copy path
File metadata and controls
3445 lines (2720 loc) · 86.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2006-10 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package
processing
.
core
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Map
;
import
processing
.
core
.
PApplet
;
/**
* ( begin auto-generated from PShape.xml )
*
* Datatype for storing shapes. Processing can currently load and display
* SVG (Scalable Vector Graphics) shapes. Before a shape is used, it must
* be loaded with the <b>loadShape()</b> function. The <b>shape()</b>
* function is used to draw the shape to the display window. The
* <b>PShape</b> object contain a group of methods, linked below, that can
* operate on the shape data.
* <br /><br />
* The <b>loadShape()</b> function supports SVG files created with Inkscape
* and Adobe Illustrator. It is not a full SVG implementation, but offers
* some straightforward support for handling vector data.
*
* ( end auto-generated )
* <h3>Advanced</h3>
*
* In-progress class to handle shape data, currently to be considered of
* alpha or beta quality. Major structural work may be performed on this class
* after the release of Processing 1.0. Such changes may include:
*
* <ul>
* <li> addition of proper accessors to read shape vertex and coloring data
* (this is the second most important part of having a PShape class after all).
* <li> a means of creating PShape objects ala beginShape() and endShape().
* <li> load(), update(), and cache methods ala PImage, so that shapes can
* have renderer-specific optimizations, such as vertex arrays in OpenGL.
* <li> splitting this class into multiple classes to handle different
* varieties of shape data (primitives vs collections of vertices vs paths)
* <li> change of package declaration, for instance moving the code into
* package processing.shape (if the code grows too much).
* </ul>
*
* <p>For the time being, this class and its shape() and loadShape() friends in
* PApplet exist as placeholders for more exciting things to come. If you'd
* like to work with this class, make a subclass (see how PShapeSVG works)
* and you can play with its internal methods all you like.</p>
*
* <p>Library developers are encouraged to create PShape objects when loading
* shape data, so that they can eventually hook into the bounty that will be
* the PShape interface, and the ease of loadShape() and shape().</p>
*
* @webref shape
* @usage Web & Application
* @see PApplet#loadShape(String)
* @see PApplet#createShape()
* @see PApplet#shapeMode(int)
* @instanceName sh any variable of type PShape
*/
public
class
PShape
implements
PConstants
{
protected
String
name
;
protected
Map
<
String
,
PShape
>
nameTable
;
// /** Generic, only draws its child objects. */
// static public final int GROUP = 0;
// GROUP now inherited from PConstants, and is still zero
// These constants were updated in 3.0b6 so that they could be distinguished
// from others in PConstants and improve how some typos were handled.
// https://github.com/processing/processing/issues/3776
/** A line, ellipse, arc, image, etc. */
static
public
final
int
PRIMITIVE
=
101
;
/** A series of vertex, curveVertex, and bezierVertex calls. */
static
public
final
int
PATH
=
102
;
/** Collections of vertices created with beginShape(). */
static
public
final
int
GEOMETRY
=
103
;
/** The shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY. */
protected
int
family
;
/** ELLIPSE, LINE, QUAD; TRIANGLE_FAN, QUAD_STRIP; etc. */
protected
int
kind
;
protected
PMatrix
matrix
;
protected
int
textureMode
;
/** Texture or image data associated with this shape. */
protected
PImage
image
;
public
static
final
String
OUTSIDE_BEGIN_END_ERROR
=
"%1$s can only be called between beginShape() and endShape()"
;
public
static
final
String
INSIDE_BEGIN_END_ERROR
=
"%1$s can only be called outside beginShape() and endShape()"
;
public
static
final
String
NO_SUCH_VERTEX_ERROR
=
"%1$s vertex index does not exist"
;
static
public
final
String
NO_VERTICES_ERROR
=
"getVertexCount() only works with PATH or GEOMETRY shapes"
;
public
static
final
String
NOT_A_SIMPLE_VERTEX
=
"%1$s can not be called on quadratic or bezier vertices"
;
static
public
final
String
PER_VERTEX_UNSUPPORTED
=
"This renderer does not support %1$s for individual vertices"
;
/**
* ( begin auto-generated from PShape_width.xml )
*
* The width of the PShape document.
*
* ( end auto-generated )
* @webref pshape:field
* @usage web_application
* @brief Shape document width
* @see PShape#height
*/
public
float
width
;
/**
* ( begin auto-generated from PShape_height.xml )
*
* The height of the PShape document.
*
* ( end auto-generated )
* @webref pshape:field
* @usage web_application
* @brief Shape document height
* @see PShape#width
*/
public
float
height
;
public
float
depth
;
PGraphics
g
;
// set to false if the object is hidden in the layers palette
protected
boolean
visible
=
true
;
/** Retained shape being created with beginShape/endShape */
protected
boolean
openShape
=
false
;
protected
boolean
openContour
=
false
;
protected
boolean
stroke
;
protected
int
strokeColor
;
protected
float
strokeWeight
;
// default is 1
protected
int
strokeCap
;
protected
int
strokeJoin
;
protected
boolean
fill
;
protected
int
fillColor
;
protected
boolean
tint
;
protected
int
tintColor
;
protected
int
ambientColor
;
protected
boolean
setAmbient
;
protected
int
specularColor
;
protected
int
emissiveColor
;
protected
float
shininess
;
protected
int
sphereDetailU
,
sphereDetailV
;
protected
int
rectMode
;
protected
int
ellipseMode
;
/** Temporary toggle for whether styles should be honored. */
protected
boolean
style
=
true
;
/** For primitive shapes in particular, params like x/y/w/h or x1/y1/x2/y2. */
protected
float
[]
params
;
protected
int
vertexCount
;
/**
* When drawing POLYGON shapes, the second param is an array of length
* VERTEX_FIELD_COUNT. When drawing PATH shapes, the second param has only
* two variables.
*/
protected
float
[][]
vertices
;
protected
PShape
parent
;
protected
int
childCount
;
protected
PShape
[]
children
;
/** Array of VERTEX, BEZIER_VERTEX, and CURVE_VERTEX calls. */
protected
int
vertexCodeCount
;
protected
int
[]
vertexCodes
;
/** True if this is a closed path. */
protected
boolean
close
;
// ........................................................
// internal color for setting/calculating
protected
float
calcR
,
calcG
,
calcB
,
calcA
;
protected
int
calcRi
,
calcGi
,
calcBi
,
calcAi
;
protected
int
calcColor
;
protected
boolean
calcAlpha
;
/** The current colorMode */
public
int
colorMode
;
// = RGB;
/** Max value for red (or hue) set by colorMode */
public
float
colorModeX
;
// = 255;
/** Max value for green (or saturation) set by colorMode */
public
float
colorModeY
;
// = 255;
/** Max value for blue (or value) set by colorMode */
public
float
colorModeZ
;
// = 255;
/** Max value for alpha set by colorMode */
public
float
colorModeA
;
// = 255;
/** True if colors are not in the range 0..1 */
boolean
colorModeScale
;
// = true;
/** True if colorMode(RGB, 255) */
boolean
colorModeDefault
;
// = true;
/** True if contains 3D data */
protected
boolean
is3D
=
false
;
protected
boolean
perVertexStyles
=
false
;
// should this be called vertices (consistent with PGraphics internals)
// or does that hurt flexibility?
// POINTS, LINES, xLINE_STRIP, xLINE_LOOP
// TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN
// QUADS, QUAD_STRIP
// xPOLYGON
// static final int PATH = 1; // POLYGON, LINE_LOOP, LINE_STRIP
// static final int GROUP = 2;
// how to handle rectmode/ellipsemode?
// are they bitshifted into the constant?
// CORNER, CORNERS, CENTER, (CENTER_RADIUS?)
// static final int RECT = 3; // could just be QUAD, but would be x1/y1/x2/y2
// static final int ELLIPSE = 4;
//
// static final int VERTEX = 7;
// static final int CURVE = 5;
// static final int BEZIER = 6;
// fill and stroke functions will need a pointer to the parent
// PGraphics object.. may need some kind of createShape() fxn
// or maybe the values are stored until draw() is called?
// attaching images is very tricky.. it's a different type of data
// material parameters will be thrown out,
// except those currently supported (kinds of lights)
// pivot point for transformations
// public float px;
// public float py;
/**
* @nowebref
*/
public
PShape
() {
this
.
family
=
GROUP
;
}
/**
* @nowebref
*/
public
PShape
(
int
family
) {
this
.
family
=
family
;
}
/**
* @nowebref
*/
public
PShape
(
PGraphics
g
,
int
family
) {
this
.
g
=
g
;
this
.
family
=
family
;
// Style parameters are retrieved from the current values in the renderer.
textureMode
=
g
.
textureMode
;
colorMode
(
g
.
colorMode
,
g
.
colorModeX
,
g
.
colorModeY
,
g
.
colorModeZ
,
g
.
colorModeA
);
// Initial values for fill, stroke and tint colors are also imported from
// the renderer. This is particular relevant for primitive shapes, since is
// not possible to set their color separately when creating them, and their
// input vertices are actually generated at rendering time, by which the
// color configuration of the renderer might have changed.
fill
=
g
.
fill
;
fillColor
=
g
.
fillColor
;
stroke
=
g
.
stroke
;
strokeColor
=
g
.
strokeColor
;
strokeWeight
=
g
.
strokeWeight
;
strokeCap
=
g
.
strokeCap
;
strokeJoin
=
g
.
strokeJoin
;
tint
=
g
.
tint
;
tintColor
=
g
.
tintColor
;
setAmbient
=
g
.
setAmbient
;
ambientColor
=
g
.
ambientColor
;
specularColor
=
g
.
specularColor
;
emissiveColor
=
g
.
emissiveColor
;
shininess
=
g
.
shininess
;
sphereDetailU
=
g
.
sphereDetailU
;
sphereDetailV
=
g
.
sphereDetailV
;
// bezierDetail = pg.bezierDetail;
// curveDetail = pg.curveDetail;
// curveTightness = pg.curveTightness;
rectMode
=
g
.
rectMode
;
ellipseMode
=
g
.
ellipseMode
;
// normalX = normalY = 0;
// normalZ = 1;
//
// normalMode = NORMAL_MODE_AUTO;
// To make sure that the first vertex is marked as a break.
// Same behavior as in the immediate mode.
// breakShape = false;
if
(
family
==
GROUP
) {
// GROUP shapes are always marked as ended.
// shapeCreated = true;
// TODO why was this commented out?
}
}
public
PShape
(
PGraphics
g
,
int
kind
,
float
...
params
) {
this
(
g
,
PRIMITIVE
);
setKind
(
kind
);
setParams
(
params
);
}
public
void
setFamily
(
int
family
) {
this
.
family
=
family
;
}
public
void
setKind
(
int
kind
) {
this
.
kind
=
kind
;
}
public
void
setName
(
String
name
) {
this
.
name
=
name
;
}
public
String
getName
() {
return
name
;
}
/**
* ( begin auto-generated from PShape_isVisible.xml )
*
* Returns a boolean value "true" if the image is set to be visible,
* "false" if not. This is modified with the <b>setVisible()</b> parameter.
* <br/> <br/>
* The visibility of a shape is usually controlled by whatever program
* created the SVG file. For instance, this parameter is controlled by
* showing or hiding the shape in the layers palette in Adobe Illustrator.
*
* ( end auto-generated )
* @webref pshape:method
* @usage web_application
* @brief Returns a boolean value "true" if the image is set to be visible, "false" if not
* @see PShape#setVisible(boolean)
*/
public
boolean
isVisible
() {
return
visible
;
}
/**
* ( begin auto-generated from PShape_setVisible.xml )
*
* Sets the shape to be visible or invisible. This is determined by the
* value of the <b>visible</b> parameter.
* <br/> <br/>
* The visibility of a shape is usually controlled by whatever program
* created the SVG file. For instance, this parameter is controlled by
* showing or hiding the shape in the layers palette in Adobe Illustrator.
*
* ( end auto-generated )
* @webref pshape:mathod
* @usage web_application
* @brief Sets the shape to be visible or invisible
* @param visible "false" makes the shape invisible and "true" makes it visible
* @see PShape#isVisible()
*/
public
void
setVisible
(
boolean
visible
) {
this
.
visible
=
visible
;
}
/**
* ( begin auto-generated from PShape_disableStyle.xml )
*
* Disables the shape's style data and uses Processing's current styles.
* Styles include attributes such as colors, stroke weight, and stroke
* joints.
*
* ( end auto-generated )
* <h3>Advanced</h3>
* Overrides this shape's style information and uses PGraphics styles and
* colors. Identical to ignoreStyles(true). Also disables styles for all
* child shapes.
* @webref pshape:method
* @usage web_application
* @brief Disables the shape's style data and uses Processing styles
* @see PShape#enableStyle()
*/
public
void
disableStyle
() {
style
=
false
;
for
(
int
i
=
0
;
i
<
childCount
;
i
++) {
children
[
i
].
disableStyle
();
}
}
/**
* ( begin auto-generated from PShape_enableStyle.xml )
*
* Enables the shape's style data and ignores Processing's current styles.
* Styles include attributes such as colors, stroke weight, and stroke
* joints.
*
* ( end auto-generated )
*
* @webref pshape:method
* @usage web_application
* @brief Enables the shape's style data and ignores the Processing styles
* @see PShape#disableStyle()
*/
public
void
enableStyle
() {
style
=
true
;
for
(
int
i
=
0
;
i
<
childCount
;
i
++) {
children
[
i
].
enableStyle
();
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// protected void checkBounds() {
// if (width == 0 || height == 0) {
// // calculate bounds here (also take kids into account)
// width = 1;
// height = 1;
// }
// }
/**
* Get the width of the drawing area (not necessarily the shape boundary).
*/
public
float
getWidth
() {
//checkBounds();
return
width
;
}
/**
* Get the height of the drawing area (not necessarily the shape boundary).
*/
public
float
getHeight
() {
//checkBounds();
return
height
;
}
/**
* Get the depth of the shape area (not necessarily the shape boundary). Only makes sense for 3D PShape subclasses,
* such as PShape3D.
*/
public
float
getDepth
() {
//checkBounds();
return
depth
;
}
/*
// TODO unapproved
protected PVector getTop() {
return getTop(null);
}
protected PVector getTop(PVector top) {
if (top == null) {
top = new PVector();
}
return top;
}
protected PVector getBottom() {
return getBottom(null);
}
protected PVector getBottom(PVector bottom) {
if (bottom == null) {
bottom = new PVector();
}
return bottom;
}
*/
/**
* Return true if this shape is 2D. Defaults to true.
*/
public
boolean
is2D
() {
return
!
is3D
;
}
/**
* Return true if this shape is 3D. Defaults to false.
*/
public
boolean
is3D
() {
return
is3D
;
}
public
void
set3D
(
boolean
val
) {
is3D
=
val
;
}
// /**
// * Return true if this shape requires rendering through OpenGL. Defaults to false.
// */
// // TODO unapproved
// public boolean isGL() {
// return false;
// }
///////////////////////////////////////////////////////////
//
// Drawing methods
public
void
textureMode
(
int
mode
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"textureMode()"
);
return
;
}
textureMode
=
mode
;
}
public
void
texture
(
PImage
tex
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"texture()"
);
return
;
}
image
=
tex
;
}
public
void
noTexture
() {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"noTexture()"
);
return
;
}
image
=
null
;
}
// TODO unapproved
protected
void
solid
(
boolean
solid
) {
}
/**
* @webref shape:vertex
* @brief Starts a new contour
* @see PShape#endContour()
*/
public
void
beginContour
() {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"beginContour()"
);
return
;
}
if
(
family
==
GROUP
) {
PGraphics
.
showWarning
(
"Cannot begin contour in GROUP shapes"
);
return
;
}
if
(
openContour
) {
PGraphics
.
showWarning
(
"Already called beginContour()."
);
return
;
}
openContour
=
true
;
beginContourImpl
();
}
protected
void
beginContourImpl
() {
if
(
vertexCodes
==
null
) {
vertexCodes
=
new
int
[
10
];
}
else
if
(
vertexCodes
.
length
==
vertexCodeCount
) {
vertexCodes
=
PApplet
.
expand
(
vertexCodes
);
}
vertexCodes
[
vertexCodeCount
++] =
BREAK
;
}
/**
* @webref shape:vertex
* @brief Ends a contour
* @see PShape#beginContour()
*/
public
void
endContour
() {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"endContour()"
);
return
;
}
if
(
family
==
GROUP
) {
PGraphics
.
showWarning
(
"Cannot end contour in GROUP shapes"
);
return
;
}
if
(!
openContour
) {
PGraphics
.
showWarning
(
"Need to call beginContour() first."
);
return
;
}
endContourImpl
();
openContour
=
false
;
}
protected
void
endContourImpl
() {
}
public
void
vertex
(
float
x
,
float
y
) {
if
(
vertices
==
null
) {
vertices
=
new
float
[
10
][
2
];
}
else
if
(
vertices
.
length
==
vertexCount
) {
vertices
= (
float
[][])
PApplet
.
expand
(
vertices
);
}
vertices
[
vertexCount
++] =
new
float
[] {
x
,
y
};
if
(
vertexCodes
==
null
) {
vertexCodes
=
new
int
[
10
];
}
else
if
(
vertexCodes
.
length
==
vertexCodeCount
) {
vertexCodes
=
PApplet
.
expand
(
vertexCodes
);
}
vertexCodes
[
vertexCodeCount
++] =
VERTEX
;
if
(
x
>
width
) {
width
=
x
;
}
if
(
y
>
height
) {
height
=
y
;
}
}
public
void
vertex
(
float
x
,
float
y
,
float
u
,
float
v
) {
}
public
void
vertex
(
float
x
,
float
y
,
float
z
) {
vertex
(
x
,
y
);
// maybe? maybe not?
}
public
void
vertex
(
float
x
,
float
y
,
float
z
,
float
u
,
float
v
) {
}
public
void
normal
(
float
nx
,
float
ny
,
float
nz
) {
}
public
void
attribPosition
(
String
name
,
float
x
,
float
y
,
float
z
) {
}
public
void
attribNormal
(
String
name
,
float
nx
,
float
ny
,
float
nz
) {
}
public
void
attribColor
(
String
name
,
int
color
) {
}
public
void
attrib
(
String
name
,
float
...
values
) {
}
public
void
attrib
(
String
name
,
int
...
values
) {
}
public
void
attrib
(
String
name
,
boolean
...
values
) {
}
/**
* @webref pshape:method
* @brief Starts the creation of a new PShape
* @see PApplet#endShape()
*/
public
void
beginShape
() {
beginShape
(
POLYGON
);
}
public
void
beginShape
(
int
kind
) {
this
.
kind
=
kind
;
openShape
=
true
;
}
/**
* @webref pshape:method
* @brief Finishes the creation of a new PShape
* @see PApplet#beginShape()
*/
public
void
endShape
() {
endShape
(
OPEN
);
}
public
void
endShape
(
int
mode
) {
if
(
family
==
GROUP
) {
PGraphics
.
showWarning
(
"Cannot end GROUP shape"
);
return
;
}
if
(!
openShape
) {
PGraphics
.
showWarning
(
"Need to call beginShape() first"
);
return
;
}
close
= (
mode
==
CLOSE
);
// this is the state of the shape
openShape
=
false
;
}
//////////////////////////////////////////////////////////////
// STROKE CAP/JOIN/WEIGHT
public
void
strokeWeight
(
float
weight
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"strokeWeight()"
);
return
;
}
strokeWeight
=
weight
;
}
public
void
strokeJoin
(
int
join
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"strokeJoin()"
);
return
;
}
strokeJoin
=
join
;
}
public
void
strokeCap
(
int
cap
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"strokeCap()"
);
return
;
}
strokeCap
=
cap
;
}
//////////////////////////////////////////////////////////////
// FILL COLOR
public
void
noFill
() {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"noFill()"
);
return
;
}
fill
=
false
;
fillColor
=
0x0
;
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
public
void
fill
(
int
rgb
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"fill()"
);
return
;
}
fill
=
true
;
colorCalc
(
rgb
);
fillColor
=
calcColor
;
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
public
void
fill
(
int
rgb
,
float
alpha
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"fill()"
);
return
;
}
fill
=
true
;
colorCalc
(
rgb
,
alpha
);
fillColor
=
calcColor
;
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
public
void
fill
(
float
gray
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"fill()"
);
return
;
}
fill
=
true
;
colorCalc
(
gray
);
fillColor
=
calcColor
;
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
public
void
fill
(
float
gray
,
float
alpha
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"fill()"
);
return
;
}
fill
=
true
;
colorCalc
(
gray
,
alpha
);
fillColor
=
calcColor
;
if
(!
setAmbient
) {
ambient
(
fillColor
);
setAmbient
=
false
;
}
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
public
void
fill
(
float
x
,
float
y
,
float
z
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"fill()"
);
return
;
}
fill
=
true
;
colorCalc
(
x
,
y
,
z
);
fillColor
=
calcColor
;
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
public
void
fill
(
float
x
,
float
y
,
float
z
,
float
a
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"fill()"
);
return
;
}
fill
=
true
;
colorCalc
(
x
,
y
,
z
,
a
);
fillColor
=
calcColor
;
if
(!
setAmbient
) {
ambientColor
=
fillColor
;
}
}
//////////////////////////////////////////////////////////////
// STROKE COLOR
public
void
noStroke
() {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"noStroke()"
);
return
;
}
stroke
=
false
;
}
public
void
stroke
(
int
rgb
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"stroke()"
);
return
;
}
stroke
=
true
;
colorCalc
(
rgb
);
strokeColor
=
calcColor
;
}
public
void
stroke
(
int
rgb
,
float
alpha
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"stroke()"
);
return
;
}
stroke
=
true
;
colorCalc
(
rgb
,
alpha
);
strokeColor
=
calcColor
;
}
public
void
stroke
(
float
gray
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"stroke()"
);
return
;
}
stroke
=
true
;
colorCalc
(
gray
);
strokeColor
=
calcColor
;
}
public
void
stroke
(
float
gray
,
float
alpha
) {
if
(!
openShape
) {
PGraphics
.
showWarning
(
OUTSIDE_BEGIN_END_ERROR
,
"stroke()"
);
return
;
}
stroke
=
true
;
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL