-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPGraphics_class.html
More file actions
264 lines (249 loc) · 39.7 KB
/
Copy pathPGraphics_class.html
File metadata and controls
264 lines (249 loc) · 39.7 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PGraphics - Processing for C++ Reference</title>
<style>* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #111; background: #fff; } a { color: #111; text-decoration: none; } nav { border-bottom: 1px solid #e0e0e0; padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; height: 60px; position: sticky; top: 0; background: #fff; z-index: 100; } .nav-logo { display: flex; align-items: center; gap: 10px; color: #111; } .nav-logo img { width: 28px; height: 28px; } .hamburger { background: none; border: none; cursor: pointer; font-size: 22px; padding: 4px 8px; display: none; } .layout { display: flex; min-height: calc(100vh - 60px); } .sidebar-outer { width: 220px; min-width: 220px; border-right: 1px solid #e0e0e0; display: flex; flex-direction: column; position: sticky; top: 60px; height: calc(100vh - 60px); } #site-sidebar { padding: 1.5rem 1.5rem 1rem; border-bottom: 1px solid #e0e0e0; display: flex; flex-direction: column; } #site-sidebar a { font-size: 14px; color: #555; padding: 0.4rem 0; display: block; } #site-sidebar a:hover { color: #111; } #site-sidebar a.active { color: #111; font-weight: 500; } .ref-sidebar { flex: 1; overflow-y: auto; padding: 0.5rem 0; } .ref-cat-title { font-size: 11px; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.85rem 1.5rem 0.25rem; } .ref-subcat-title { font-size: 10px; font-weight: 600; color: #aaa; padding: 0.5rem 1.5rem 0.1rem; } .ref-sidebar a { display: block; font-size: 12px; color: #555; padding: 0.2rem 1.5rem; font-family: "SF Mono","Fira Code",monospace; } .ref-sidebar a.ref-sidebar-sub { padding-left: 2rem; } .ref-sidebar a:hover { color: #111; background: #f8f8f8; } .ref-sidebar a.active { color: #111 !important; font-weight: 600; background: #f4f4f4; } .content { flex: 1; padding: 3rem 4rem; max-width: 860px; } .content h1 { font-size: 1.8rem; font-weight: 600; margin-bottom: 0.25rem; font-family: "SF Mono","Fira Code",monospace; } .cat-tag { font-size: 12px; color: #aaa; margin-bottom: 2rem; display: block; } .content h2 { font-size: 11px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2rem; margin-bottom: 0.75rem; } .content p { color: #444; line-height: 1.8; margin-bottom: 1rem; font-size: 0.95rem; } .syntax-block { background: #f8f8f8; border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 0.5rem; font-family: "SF Mono","Fira Code",monospace; font-size: 13px; line-height: 1.8; white-space: pre; overflow-x: auto; } .params-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 13px; } .params-table th { text-align: left; font-size: 11px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.5rem 0.75rem; border-bottom: 1px solid #e0e0e0; } .params-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; } .params-table td:first-child { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; color: #333; width: 130px; } .params-table td:nth-child(2) { color: #888; font-family: "SF Mono","Fira Code",monospace; font-size: 12px; width: 90px; } .returns-badge { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; background: #f0f0f0; border-radius: 4px; padding: 3px 10px; color: #555; display: inline-block; margin-bottom: 1rem; } .related-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; } .related-links a { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; background: #f4f4f4; border-radius: 4px; padding: 3px 10px; color: #555; } .related-links a:hover { background: #e0e0e0; color: #111; } .methods-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 13px; } .methods-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid #f0f0f0; } .methods-table td:first-child { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; color: #333; width: 280px; } .impl-block { background: #0d0d0d; border-radius: 6px; padding: 1rem 1.25rem; font-family: "SF Mono","Fira Code",monospace; font-size: 12px; line-height: 1.7; color: #ccc; white-space: pre; overflow-x: auto; max-height: 400px; overflow-y: auto; } .topic-block { margin-bottom: 3rem; } .topic-title { font-size: 1.1rem; font-weight: 700; color: #111; margin-bottom: 1.25rem; padding-bottom: 0.5rem; border-bottom: 2px solid #111; } .subtopic { margin-bottom: 1.5rem; } .subtopic-title { font-size: 11px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5rem; } .fn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.2rem 1.5rem; } .fn-list a { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; color: #555; padding: 0.15rem 0; display: block; } .fn-list a:hover { color: #111; } footer { border-top: 1px solid #e0e0e0; padding: 2rem; text-align: center; font-size: 13px; color: #888; } @media (max-width: 768px) { .hamburger { display: block; } .sidebar-outer { position: fixed; top: 60px; left: -240px; width: 240px; height: calc(100vh - 60px); background: #fff; z-index: 200; transition: left 0.25s ease; box-shadow: 2px 0 12px rgba(0,0,0,0.08); } .sidebar-outer.open { left: 0; } .content { padding: 2rem 1.25rem; } }</style>
</head>
<body>
<nav id="site-nav"></nav>
<div class="layout">
<div class="sidebar-outer">
<div id="site-sidebar"></div>
<div class="ref-sidebar"><div class="ref-cat-title">Data</div><div class="ref-subcat-title">Composite</div><a href="BufferedReader_class.html" class="ref-sidebar-sub">BufferedReader</a><a href="HashMap_class.html" class="ref-sidebar-sub">HashMap</a><a href="PFont_class.html" class="ref-sidebar-sub">PFont</a><a href="PGraphics_class.html" class="active ref-sidebar-sub">PGraphics</a><a href="PImage_class.html" class="ref-sidebar-sub">PImage</a><a href="PShader_class.html" class="ref-sidebar-sub">PShader</a><a href="PShape_class.html" class="ref-sidebar-sub">PShape</a><a href="PVector.html" class="ref-sidebar-sub">PVector</a><a href="PrintWriter_class.html" class="ref-sidebar-sub">PrintWriter</a><a href="TableRow_class.html" class="ref-sidebar-sub">TableRow</a><a href="Table_class.html" class="ref-sidebar-sub">Table</a><a href="XML_class.html" class="ref-sidebar-sub">XML</a><div class="ref-subcat-title">Array Functions</div><a href="append.html" class="ref-sidebar-sub">append()</a><a href="arrayCopy.html" class="ref-sidebar-sub">arrayCopy()</a><a href="concat.html" class="ref-sidebar-sub">concat()</a><a href="expand.html" class="ref-sidebar-sub">expand()</a><a href="reverse_arr.html" class="ref-sidebar-sub">reverse()</a><a href="shorten.html" class="ref-sidebar-sub">shorten()</a><a href="sort_arr.html" class="ref-sidebar-sub">sort()</a><a href="splice.html" class="ref-sidebar-sub">splice()</a><a href="subset.html" class="ref-sidebar-sub">subset()</a><div class="ref-subcat-title">Conversion</div><a href="binary.html" class="ref-sidebar-sub">binary()</a><a href="hex.html" class="ref-sidebar-sub">hex()</a><a href="str.html" class="ref-sidebar-sub">str()</a><a href="unbinary.html" class="ref-sidebar-sub">unbinary()</a><a href="unhex.html" class="ref-sidebar-sub">unhex()</a><div class="ref-subcat-title">Primitive</div><a href="color_type.html" class="ref-sidebar-sub">color</a><div class="ref-subcat-title">String Functions</div><a href="join.html" class="ref-sidebar-sub">join()</a><a href="matchAll.html" class="ref-sidebar-sub">matchAll()</a><a href="match.html" class="ref-sidebar-sub">match()</a><a href="nf.html" class="ref-sidebar-sub">nf()</a><a href="split.html" class="ref-sidebar-sub">split()</a><a href="splitTokens.html" class="ref-sidebar-sub">splitTokens()</a><a href="trim.html" class="ref-sidebar-sub">trim()</a><div class="ref-cat-title">Input</div><div class="ref-subcat-title">Files</div><a href="createInput.html" class="ref-sidebar-sub">createInput()</a><a href="createReader.html" class="ref-sidebar-sub">createReader()</a><a href="launch.html" class="ref-sidebar-sub">launch()</a><a href="loadBytes.html" class="ref-sidebar-sub">loadBytes()</a><a href="loadJSONArray.html" class="ref-sidebar-sub">loadJSONArray()</a><a href="loadJSONObject.html" class="ref-sidebar-sub">loadJSONObject()</a><a href="loadStrings.html" class="ref-sidebar-sub">loadStrings()</a><a href="loadTable.html" class="ref-sidebar-sub">loadTable()</a><a href="loadXML.html" class="ref-sidebar-sub">loadXML()</a><a href="parseJSONArray.html" class="ref-sidebar-sub">parseJSONArray()</a><a href="parseJSONObject.html" class="ref-sidebar-sub">parseJSONObject()</a><a href="parseXML.html" class="ref-sidebar-sub">parseXML()</a><a href="selectFolder.html" class="ref-sidebar-sub">selectFolder()</a><a href="selectInput.html" class="ref-sidebar-sub">selectInput()</a><div class="ref-subcat-title">Time & Date</div><a href="day.html" class="ref-sidebar-sub">day()</a><a href="hour.html" class="ref-sidebar-sub">hour()</a><a href="millis.html" class="ref-sidebar-sub">millis()</a><a href="minute.html" class="ref-sidebar-sub">minute()</a><a href="month.html" class="ref-sidebar-sub">month()</a><a href="second.html" class="ref-sidebar-sub">second()</a><a href="year.html" class="ref-sidebar-sub">year()</a><div class="ref-subcat-title">Keyboard</div><a href="key.html" class="ref-sidebar-sub">key</a><a href="keyPressed_var.html" class="ref-sidebar-sub">_keyPressed</a><a href="keyCode.html" class="ref-sidebar-sub">keyCode</a><a href="keyReleased.html" class="ref-sidebar-sub">keyReleased()</a><a href="keyPressed_fn.html" class="ref-sidebar-sub">keyPressed()</a><a href="keyTyped.html" class="ref-sidebar-sub">keyTyped()</a><div class="ref-subcat-title">Mouse</div><a href="mouseButton.html" class="ref-sidebar-sub">mouseButton</a><a href="mouseClicked.html" class="ref-sidebar-sub">mouseClicked()</a><a href="mouseDragged.html" class="ref-sidebar-sub">mouseDragged()</a><a href="mouseMoved.html" class="ref-sidebar-sub">mouseMoved()</a><a href="mousePressed_var.html" class="ref-sidebar-sub">_mousePressed</a><a href="mousePressed_fn.html" class="ref-sidebar-sub">mousePressed()</a><a href="mouseWheel.html" class="ref-sidebar-sub">mouseWheel()</a><a href="mouseReleased.html" class="ref-sidebar-sub">mouseReleased()</a><a href="mouseX.html" class="ref-sidebar-sub">mouseX</a><a href="mouseY.html" class="ref-sidebar-sub">mouseY</a><a href="pmouseX.html" class="ref-sidebar-sub">pmouseX</a><a href="pmouseY.html" class="ref-sidebar-sub">pmouseY</a><a href="mouseDX.html" class="ref-sidebar-sub">mouseDX</a><a href="mouseDY.html" class="ref-sidebar-sub">mouseDY</a><div class="ref-cat-title">Constants</div><a href="HALF_PI.html" class="ref-sidebar-item">HALF_PI</a><a href="PI.html" class="ref-sidebar-item">PI</a><a href="QUARTER_PI.html" class="ref-sidebar-item">QUARTER_PI</a><a href="TAU.html" class="ref-sidebar-item">TAU</a><a href="TWO_PI.html" class="ref-sidebar-item">TWO_PI</a><div class="ref-cat-title">Typography</div><div class="ref-subcat-title">Loading & Displaying</div><a href="PFont_class.html" class="ref-sidebar-sub">PFont</a><a href="createFont.html" class="ref-sidebar-sub">createFont()</a><a href="loadFont.html" class="ref-sidebar-sub">loadFont()</a><a href="textFont.html" class="ref-sidebar-sub">textFont()</a><a href="text.html" class="ref-sidebar-sub">text()</a><div class="ref-subcat-title">Attributes</div><a href="textAlign.html" class="ref-sidebar-sub">textAlign()</a><a href="textLeading.html" class="ref-sidebar-sub">textLeading()</a><a href="textMode.html" class="ref-sidebar-sub">textMode()</a><a href="textSize.html" class="ref-sidebar-sub">textSize()</a><a href="textWidth.html" class="ref-sidebar-sub">textWidth()</a><div class="ref-subcat-title">Metrics</div><a href="textAscent.html" class="ref-sidebar-sub">textAscent()</a><a href="textDescent.html" class="ref-sidebar-sub">textDescent()</a><div class="ref-cat-title">Rendering</div><a href="PGraphics_class.html" class="active ref-sidebar-item">PGraphics</a><a href="blendMode.html" class="ref-sidebar-item">blendMode()</a><a href="clip.html" class="ref-sidebar-item">clip()</a><a href="createGraphics.html" class="ref-sidebar-item">createGraphics()</a><a href="hint.html" class="ref-sidebar-item">hint()</a><a href="noClip.html" class="ref-sidebar-item">noClip()</a><div class="ref-subcat-title">Shaders</div><a href="PShader_class.html" class="ref-sidebar-sub">PShader</a><a href="loadShader.html" class="ref-sidebar-sub">loadShader()</a><a href="resetShader.html" class="ref-sidebar-sub">resetShader()</a><a href="shader_fn.html" class="ref-sidebar-sub">shader()</a><div class="ref-cat-title">Image</div><a href="PImage_class.html" class="ref-sidebar-item">PImage</a><a href="createImage.html" class="ref-sidebar-item">createImage()</a><div class="ref-subcat-title">Pixels</div><a href="blend_fn.html" class="ref-sidebar-sub">blend()</a><a href="copy_fn.html" class="ref-sidebar-sub">copy()</a><a href="filter.html" class="ref-sidebar-sub">filter()</a><a href="get_pixel.html" class="ref-sidebar-sub">get()</a><a href="loadPixels.html" class="ref-sidebar-sub">loadPixels()</a><a href="mask_fn.html" class="ref-sidebar-sub">mask()</a><a href="pixels_arr.html" class="ref-sidebar-sub">pixels[]</a><a href="set_pixel.html" class="ref-sidebar-sub">set()</a><a href="updatePixels.html" class="ref-sidebar-sub">updatePixels()</a><div class="ref-subcat-title">Loading & Displaying</div><a href="image.html" class="ref-sidebar-sub">image()</a><a href="imageMode.html" class="ref-sidebar-sub">imageMode()</a><a href="loadImage.html" class="ref-sidebar-sub">loadImage()</a><a href="noTint.html" class="ref-sidebar-sub">noTint()</a><a href="tint.html" class="ref-sidebar-sub">tint()</a><div class="ref-subcat-title">Textures</div><a href="texture.html" class="ref-sidebar-sub">texture()</a><a href="textureMode.html" class="ref-sidebar-sub">textureMode()</a><a href="textureWrap.html" class="ref-sidebar-sub">textureWrap()</a><div class="ref-cat-title">Shape</div><a href="PShape_class.html" class="ref-sidebar-item">PShape</a><a href="createShape.html" class="ref-sidebar-item">createShape()</a><a href="loadShape.html" class="ref-sidebar-item">loadShape()</a><div class="ref-subcat-title">2D Primitives</div><a href="arc.html" class="ref-sidebar-sub">arc()</a><a href="circle.html" class="ref-sidebar-sub">circle()</a><a href="ellipse.html" class="ref-sidebar-sub">ellipse()</a><a href="line.html" class="ref-sidebar-sub">line()</a><a href="point.html" class="ref-sidebar-sub">point()</a><a href="quad.html" class="ref-sidebar-sub">quad()</a><a href="rect.html" class="ref-sidebar-sub">rect()</a><a href="square.html" class="ref-sidebar-sub">square()</a><a href="triangle.html" class="ref-sidebar-sub">triangle()</a><div class="ref-subcat-title">Vertex</div><a href="beginContour.html" class="ref-sidebar-sub">beginContour()</a><a href="beginShape.html" class="ref-sidebar-sub">beginShape()</a><a href="bezierVertex.html" class="ref-sidebar-sub">bezierVertex()</a><a href="curveVertex.html" class="ref-sidebar-sub">curveVertex()</a><a href="endContour.html" class="ref-sidebar-sub">endContour()</a><a href="endShape.html" class="ref-sidebar-sub">endShape()</a><a href="quadraticVertex.html" class="ref-sidebar-sub">quadraticVertex()</a><a href="vertex.html" class="ref-sidebar-sub">vertex()</a><div class="ref-subcat-title">Curves</div><a href="bezierDetail.html" class="ref-sidebar-sub">bezierDetail()</a><a href="bezierPoint.html" class="ref-sidebar-sub">bezierPoint()</a><a href="bezierTangent.html" class="ref-sidebar-sub">bezierTangent()</a><a href="bezier.html" class="ref-sidebar-sub">bezier()</a><a href="curveDetail.html" class="ref-sidebar-sub">curveDetail()</a><a href="curvePoint.html" class="ref-sidebar-sub">curvePoint()</a><a href="curveTangent.html" class="ref-sidebar-sub">curveTangent()</a><a href="curveTightness.html" class="ref-sidebar-sub">curveTightness()</a><a href="curve.html" class="ref-sidebar-sub">curve()</a><div class="ref-subcat-title">3D Primitives</div><a href="box.html" class="ref-sidebar-sub">box()</a><a href="sphere.html" class="ref-sidebar-sub">sphere()</a><a href="sphereDetail.html" class="ref-sidebar-sub">sphereDetail()</a><div class="ref-subcat-title">Attributes</div><a href="ellipseMode.html" class="ref-sidebar-sub">ellipseMode()</a><a href="rectMode.html" class="ref-sidebar-sub">rectMode()</a><a href="strokeCap.html" class="ref-sidebar-sub">strokeCap()</a><a href="strokeJoin.html" class="ref-sidebar-sub">strokeJoin()</a><a href="strokeWeight.html" class="ref-sidebar-sub">strokeWeight()</a><div class="ref-subcat-title">Loading & Displaying</div><a href="shape.html" class="ref-sidebar-sub">shape()</a><a href="shapeMode.html" class="ref-sidebar-sub">shapeMode()</a><div class="ref-cat-title">Math</div><a href="PVector.html" class="ref-sidebar-item">PVector</a><div class="ref-subcat-title">Calculation</div><a href="abs.html" class="ref-sidebar-sub">abs()</a><a href="ceil.html" class="ref-sidebar-sub">ceil()</a><a href="constrain.html" class="ref-sidebar-sub">constrain()</a><a href="dist.html" class="ref-sidebar-sub">dist()</a><a href="exp.html" class="ref-sidebar-sub">exp()</a><a href="floor.html" class="ref-sidebar-sub">floor()</a><a href="lerp.html" class="ref-sidebar-sub">lerp()</a><a href="log.html" class="ref-sidebar-sub">log()</a><a href="mag.html" class="ref-sidebar-sub">mag()</a><a href="map.html" class="ref-sidebar-sub">map()</a><a href="max.html" class="ref-sidebar-sub">max()</a><a href="min.html" class="ref-sidebar-sub">min()</a><a href="norm.html" class="ref-sidebar-sub">norm()</a><a href="pow.html" class="ref-sidebar-sub">pow()</a><a href="round.html" class="ref-sidebar-sub">round()</a><a href="sq.html" class="ref-sidebar-sub">sq()</a><a href="sqrt.html" class="ref-sidebar-sub">sqrt()</a><div class="ref-subcat-title">Trigonometry</div><a href="acos.html" class="ref-sidebar-sub">acos()</a><a href="asin.html" class="ref-sidebar-sub">asin()</a><a href="atan2.html" class="ref-sidebar-sub">atan2()</a><a href="atan.html" class="ref-sidebar-sub">atan()</a><a href="cos.html" class="ref-sidebar-sub">cos()</a><a href="degrees.html" class="ref-sidebar-sub">degrees()</a><a href="radians.html" class="ref-sidebar-sub">radians()</a><a href="sin.html" class="ref-sidebar-sub">sin()</a><a href="tan.html" class="ref-sidebar-sub">tan()</a><div class="ref-subcat-title">Random</div><a href="noise.html" class="ref-sidebar-sub">noise()</a><a href="noiseDetail.html" class="ref-sidebar-sub">noiseDetail()</a><a href="noiseSeed.html" class="ref-sidebar-sub">noiseSeed()</a><a href="randomGaussian.html" class="ref-sidebar-sub">randomGaussian()</a><a href="randomSeed.html" class="ref-sidebar-sub">randomSeed()</a><a href="random.html" class="ref-sidebar-sub">random()</a><div class="ref-cat-title">Output</div><div class="ref-subcat-title">Files</div><a href="PrintWriter_class.html" class="ref-sidebar-sub">PrintWriter</a><a href="createOutput.html" class="ref-sidebar-sub">createOutput()</a><a href="createWriter.html" class="ref-sidebar-sub">createWriter()</a><a href="saveBytes.html" class="ref-sidebar-sub">saveBytes()</a><a href="saveJSONArray.html" class="ref-sidebar-sub">saveJSONArray()</a><a href="saveJSONObject.html" class="ref-sidebar-sub">saveJSONObject()</a><a href="saveStrings.html" class="ref-sidebar-sub">saveStrings()</a><a href="saveTable.html" class="ref-sidebar-sub">saveTable()</a><a href="saveXML.html" class="ref-sidebar-sub">saveXML()</a><a href="selectOutput.html" class="ref-sidebar-sub">selectOutput()</a><div class="ref-subcat-title">Text Area</div><a href="print.html" class="ref-sidebar-sub">print()</a><a href="printArray.html" class="ref-sidebar-sub">printArray()</a><a href="println.html" class="ref-sidebar-sub">println()</a><div class="ref-subcat-title">Image</div><a href="save.html" class="ref-sidebar-sub">save()</a><a href="saveFrame.html" class="ref-sidebar-sub">saveFrame()</a><div class="ref-cat-title">Color</div><div class="ref-subcat-title">Creating & Reading</div><a href="alpha.html" class="ref-sidebar-sub">alpha()</a><a href="blue.html" class="ref-sidebar-sub">blue()</a><a href="brightness.html" class="ref-sidebar-sub">brightness()</a><a href="color_fn.html" class="ref-sidebar-sub">color()</a><a href="green.html" class="ref-sidebar-sub">green()</a><a href="hue.html" class="ref-sidebar-sub">hue()</a><a href="lerpColor.html" class="ref-sidebar-sub">lerpColor()</a><a href="red.html" class="ref-sidebar-sub">red()</a><a href="saturation.html" class="ref-sidebar-sub">saturation()</a><div class="ref-subcat-title">Setting</div><a href="background.html" class="ref-sidebar-sub">background()</a><a href="clear.html" class="ref-sidebar-sub">clear()</a><a href="colorMode.html" class="ref-sidebar-sub">colorMode()</a><a href="fill.html" class="ref-sidebar-sub">fill()</a><a href="noFill.html" class="ref-sidebar-sub">noFill()</a><a href="noStroke.html" class="ref-sidebar-sub">noStroke()</a><a href="stroke.html" class="ref-sidebar-sub">stroke()</a><div class="ref-cat-title">Lights Camera</div><div class="ref-subcat-title">Lights</div><a href="ambientLight.html" class="ref-sidebar-sub">ambientLight()</a><a href="directionalLight.html" class="ref-sidebar-sub">directionalLight()</a><a href="lightFalloff.html" class="ref-sidebar-sub">lightFalloff()</a><a href="lightSpecular.html" class="ref-sidebar-sub">lightSpecular()</a><a href="lights.html" class="ref-sidebar-sub">lights()</a><a href="noLights.html" class="ref-sidebar-sub">noLights()</a><a href="normal.html" class="ref-sidebar-sub">normal()</a><a href="pointLight.html" class="ref-sidebar-sub">pointLight()</a><a href="spotLight.html" class="ref-sidebar-sub">spotLight()</a><div class="ref-subcat-title">Material Properties</div><a href="ambient.html" class="ref-sidebar-sub">ambient()</a><a href="emissive.html" class="ref-sidebar-sub">emissive()</a><a href="shininess.html" class="ref-sidebar-sub">shininess()</a><a href="specular.html" class="ref-sidebar-sub">specular()</a><div class="ref-subcat-title">Camera</div><a href="beginCamera.html" class="ref-sidebar-sub">beginCamera()</a><a href="camera.html" class="ref-sidebar-sub">camera()</a><a href="endCamera.html" class="ref-sidebar-sub">endCamera()</a><a href="frustum.html" class="ref-sidebar-sub">frustum()</a><a href="ortho.html" class="ref-sidebar-sub">ortho()</a><a href="perspective.html" class="ref-sidebar-sub">perspective()</a><a href="printCamera.html" class="ref-sidebar-sub">printCamera()</a><a href="printProjection.html" class="ref-sidebar-sub">printProjection()</a><div class="ref-subcat-title">Coordinates</div><a href="modelX.html" class="ref-sidebar-sub">modelX()</a><a href="modelY.html" class="ref-sidebar-sub">modelY()</a><a href="modelZ.html" class="ref-sidebar-sub">modelZ()</a><a href="screenX.html" class="ref-sidebar-sub">screenX()</a><a href="screenY.html" class="ref-sidebar-sub">screenY()</a><a href="screenZ.html" class="ref-sidebar-sub">screenZ()</a><div class="ref-cat-title">Transform</div><a href="applyMatrix.html" class="ref-sidebar-item">applyMatrix()</a><a href="popMatrix.html" class="ref-sidebar-item">popMatrix()</a><a href="printMatrix.html" class="ref-sidebar-item">printMatrix()</a><a href="pushMatrix.html" class="ref-sidebar-item">pushMatrix()</a><a href="resetMatrix.html" class="ref-sidebar-item">resetMatrix()</a><a href="rotateX.html" class="ref-sidebar-item">rotateX()</a><a href="rotateY.html" class="ref-sidebar-item">rotateY()</a><a href="rotateZ.html" class="ref-sidebar-item">rotateZ()</a><a href="rotate.html" class="ref-sidebar-item">rotate()</a><a href="scale.html" class="ref-sidebar-item">scale()</a><a href="shearX.html" class="ref-sidebar-item">shearX()</a><a href="shearY.html" class="ref-sidebar-item">shearY()</a><a href="translate.html" class="ref-sidebar-item">translate()</a><div class="ref-cat-title">Structure</div><a href="draw.html" class="ref-sidebar-item">draw()</a><a href="exit.html" class="ref-sidebar-item">exit()</a><a href="loop.html" class="ref-sidebar-item">loop()</a><a href="noLoop.html" class="ref-sidebar-item">noLoop()</a><a href="pop.html" class="ref-sidebar-item">pop()</a><a href="popMatrix.html" class="ref-sidebar-item">popMatrix()</a><a href="popStyle.html" class="ref-sidebar-item">popStyle()</a><a href="push.html" class="ref-sidebar-item">push()</a><a href="pushMatrix.html" class="ref-sidebar-item">pushMatrix()</a><a href="pushStyle.html" class="ref-sidebar-item">pushStyle()</a><a href="redraw.html" class="ref-sidebar-item">redraw()</a><a href="setup.html" class="ref-sidebar-item">setup()</a><a href="thread.html" class="ref-sidebar-item">thread()</a><a href="delay.html" class="ref-sidebar-item">delay()</a><div class="ref-cat-title">Environment</div><a href="captureMouse.html" class="ref-sidebar-item">captureMouse()</a><a href="cursor.html" class="ref-sidebar-item">cursor()</a><a href="deltaTime.html" class="ref-sidebar-item">deltaTime</a><a href="displayHeight.html" class="ref-sidebar-item">displayHeight</a><a href="displayWidth.html" class="ref-sidebar-item">displayWidth</a><a href="focused.html" class="ref-sidebar-item">focused</a><a href="frameCount.html" class="ref-sidebar-item">frameCount</a><a href="frameRate_var.html" class="ref-sidebar-item">_frameRate</a><a href="frameRate_fn.html" class="ref-sidebar-item">frameRate()</a><a href="fullScreen.html" class="ref-sidebar-item">fullScreen()</a><a href="height.html" class="ref-sidebar-item">height</a><a href="hint.html" class="ref-sidebar-item">hint()</a><a href="noCursor.html" class="ref-sidebar-item">noCursor()</a><a href="noSmooth.html" class="ref-sidebar-item">noSmooth()</a><a href="pixelDensity.html" class="ref-sidebar-item">pixelDensity()</a><a href="pixelHeight.html" class="ref-sidebar-item">pixelHeight</a><a href="pixelWidth.html" class="ref-sidebar-item">pixelWidth</a><a href="releaseMouse.html" class="ref-sidebar-item">releaseMouse()</a><a href="size.html" class="ref-sidebar-item">size()</a><a href="smooth.html" class="ref-sidebar-item">smooth()</a><a href="width.html" class="ref-sidebar-item">width</a><a href="windowMoved.html" class="ref-sidebar-item">windowMoved()</a><a href="windowResizable.html" class="ref-sidebar-item">windowResizable()</a><a href="windowResize.html" class="ref-sidebar-item">windowResize()</a><a href="windowResized.html" class="ref-sidebar-item">windowResized()</a><a href="windowTitle.html" class="ref-sidebar-item">windowTitle()</a></div>
</div>
<div class="content">
<h1>PGraphics</h1>
<span class="cat-tag">Data / Composite</span>
<h2>Description</h2>
<p>An off-screen graphics buffer. Create with createGraphics(). Draw into it with beginDraw()/endDraw(), then display with image().</p>
<h2>Syntax</h2>
<div class="syntax-block">PGraphics* pg = createGraphics(w, h)</div>
<h2>Parameters</h2>
<p style="color:#aaa;font-size:13px;">None</p>
<h2>Returns</h2>
<span class="returns-badge">PGraphics</span>
<h2>Methods</h2><table class="methods-table"><tr><td>beginDraw()</td><td>Start drawing to the buffer</td></tr><tr><td>endDraw()</td><td>Stop drawing to the buffer</td></tr><tr><td>background(r,g,b)</td><td>Clear the buffer</td></tr><tr><td>fill(r,g,b)</td><td>Set fill color</td></tr><tr><td>stroke(r,g,b)</td><td>Set stroke color</td></tr><tr><td>ellipse(x,y,w,h)</td><td>Draw ellipse</td></tr><tr><td>rect(x,y,w,h)</td><td>Draw rectangle</td></tr></table>
<h2>Related</h2><div class="related-links"><a href="createGraphics.html">createGraphics</a><a href="image.html">image</a></div>
<h2>Under the Hood</h2><p style="font-size:13px;color:#888;margin-bottom:0.75rem;">From Processing.h:</p><div class="impl-block">class PGraphics : public PImage {
public:
GLuint fbo = 0; // framebuffer object
GLuint rbo = 0; // renderbuffer (depth+stencil)
bool active = false;
// Independent per-buffer style state. Real Processing's PGraphics has
// its OWN fill/stroke/text/etc. settings, completely separate from the
// main canvas's -- setting fill() on the main canvas must never affect
// a PGraphics buffer, and vice versa. Previously every PGraphics method
// forwarded directly to the single global PApplet::g_papplet singleton,
// meaning style state silently bled between the main canvas and every
// buffer (e.g. a thick green main-canvas stroke would incorrectly show
// up on an ellipse drawn inside a buffer that never set its own
// stroke). beginDraw()/endDraw() now swap PApplet's current style out
// for this buffer's OWN remembered style, and swap it back after,
// exactly mirroring how Java's PGraphics keeps independent state.
struct StyleSnapshot {
// Defaults match PApplet's own real defaults (white fill, black
// stroke) -- these are also real Processing's documented
// beginDraw() defaults ("Sets the default properties"), NOT an
// arbitrary choice. The earlier version of this struct had
// fillR=0 (black fill), which is backwards -- every fresh
// PGraphics buffer with no explicit fill()/stroke() calls should
// look exactly like a freshly created Processing sketch: white
// fill, black stroke, weight 1.
float fillR=1, fillG=1, fillB=1, fillA=1;
float strokeR=0, strokeG=0, strokeB=0, strokeA=1;
float strokeW=1;
bool doFill=true, doStroke=true, smoothing=true;
// BUG FIX: these were raw 0/0/0 literals, which silently meant
// CORNER mode (CORNER=0) for ellipseMode specifically, when real
// Processing's actual default is CENTER (=3). That made every
// fresh PGraphics buffer's ellipse() calls interpret their first
// two arguments as the bounding box's top-left corner instead of
// its center, shifting every default-mode ellipse by half its
// width/height toward the bottom-right. rectMode's and
// imageMode's real defaults ARE actually CORNER (=0), so those
// two were correct by coincidence -- only currentEllipseMode
// needed the real CENTER constant.
// Using literal values, not the CORNER/CENTER named constants:
// those constants are declared later in this file, after
// PGraphics's own definition, so they're not in scope yet here.
// CORNER=0, CENTER=3 (see the static constexpr declarations
// further down in this file).
int currentRectMode=0 /*CORNER*/, currentEllipseMode=3 /*CENTER*/, currentImageMode=0 /*CORNER*/;
float tintR=1, tintG=1, tintB=1, tintA=1;
bool doTint=false;
int colorModeVal=0;
float colorMaxH=255.f, colorMaxS=255.f, colorMaxB=255.f, colorMaxA=255.f;
float g_textSize=14.0f;
int g_textAlignX=0, g_textAlignY=0;
float g_textLeading=0.0f;
bool initialized=false; // false until beginDraw() runs once and sets real Processing defaults
};
StyleSnapshot myStyle; // this buffer's OWN persistent style
StyleSnapshot _savedMainStyle; // main canvas's style, stashed during beginDraw()..endDraw()
// Multisampled render target: PGraphics now matches real Processing's
// default antialiasing (smooth(2) on P2D/P3D) by rendering into a
// multisample renderbuffer-backed FBO, then resolving (blitting) down
// into the plain texture-backed FBO that drawPGraphicsRect samples
// from. Without this, the main canvas's window-level MSAA never
// applied to off-screen buffers at all.
GLuint msaaFbo = 0;
GLuint msaaColorRbo = 0;
GLuint msaaDepthRbo = 0;
int samples = 0; // 0 = no multisampling
bool is3D = false; // true if created via createGraphics(w,h,P3D)
PGraphics() = default;
PGraphics(int w, int h) : PImage(w, h) {
// Can't reach PApplet::g_papplet here -- PApplet's complete type
// isn't available yet at this point in the header (PGraphics is
// defined before it). Default directly to real Processing's own
// P2D/P3D default (smooth(2)) rather than reaching across that
// forward-reference gap. A sketch wanting a different level for
// its buffers can extend this later if needed.
samples = 0; // TEMPORARY: forced off to test if MSAA itself is the bug
// Resolve target: plain, non-multisampled FBO + texture --
// unchanged from before, just filled via a blit-resolve now.
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
if (texID == 0) glGenTextures(1, &texID);
glBindTexture(GL_TEXTURE_2D, texID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID, 0);
glGenRenderbuffers(1, &rbo);
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, w, h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Multisample render target: only created if antialiasing was
// actually requested. beginDraw() binds THIS one; endDraw() blits
// it down into the resolve target above.
if (samples > 0) {
glGenFramebuffers(1, &msaaFbo);
glBindFramebuffer(GL_FRAMEBUFFER, msaaFbo);
glGenRenderbuffers(1, &msaaColorRbo);
glBindRenderbuffer(GL_RENDERBUFFER, msaaColorRbo);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGBA8, w, h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaColorRbo);
glGenRenderbuffers(1, &msaaDepthRbo);
glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthRbo);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, w, h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, msaaDepthRbo);
GLenum msaaStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (msaaStatus != GL_FRAMEBUFFER_COMPLETE) {
glDeleteFramebuffers(1, &msaaFbo); msaaFbo = 0;
glDeleteRenderbuffers(1, &msaaColorRbo); msaaColorRbo = 0;
glDeleteRenderbuffers(1, &msaaDepthRbo); msaaDepthRbo = 0;
samples = 0;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
PGraphics(int w, int h, bool threeD) : PGraphics(w, h) {
is3D = threeD;
}
GLint savedViewport[4] = {};
void beginDraw(); // defined after PApplet (needs its complete type for style swap)
void _endDrawImpl(); // body of endDraw(), out-of-line for the same reason
void endDraw() { _endDrawImpl(); }
// Drawing methods forwarded to Processing -- implemented after full decls
void background(float g); void background(float r, float g, float b); void background(float r, float g, float b, float a);
void fill(float g); void fill(float r, float g, float b); void fill(float r, float g, float b, float a);
void noFill(); void stroke(float g); void stroke(float r, float g, float b); void noStroke();
void strokeWeight(float w);
void ellipse(float x, float y, float w, float h);
void rect(float x, float y, float w, float h);
void line(float x1, float y1, float x2, float y2);
void point(float x, float y);
void triangle(float x1,float y1,float x2,float y2,float x3,float y3);
void text(const std::string& s, float x, float y);
void textSize(float size);
void textAlign(int alignX);
void textAlign(int alignX, int alignY);
void translate(float x, float y, float z);
void rotateX(float angle);
void rotateY(float angle);
void rotateZ(float angle);
void box(float size);
void box(float w, float h, float d);
void sphere(float r);
void lights();
void noLights();
void ambientLight(float r, float g, float b);
void ambientLight(float r, float g, float b, float x, float y, float z);
void directionalLight(float r, float g, float b, float nx, float ny, float nz);
void pointLight(float r, float g, float b, float x, float y, float z);
void spotLight(float r, float g, float b, float x, float y, float z,
float nx, float ny, float nz, float angle, float conc);
void lightFalloff(float c, float l, float q);
void lightSpecular(float r, float g, float b);
void translate(float x, float y); void rotate(float a); void scale(float s);
void pushMatrix(); void popMatrix();
void beginShape(); void endShape(int mode=0); void vertex(float x, float y);
void clear();
~PGraphics() {
// Defensive cleanup: a PGraphics can be destroyed (via delete, or
// by going out of scope) while its beginDraw() was never matched
// with an endDraw() -- e.g. "pg = createGraphics(...)" reassigns
// a pointer, leaking the OLD PGraphics it pointed to if nothing
// explicitly deleted it first; if something DOES eventually
// delete it (or CppBuild auto-inserts a delete for exactly this
// case), the destructor running mid-beginDraw() needs to
// gracefully unwind that state rather than leaving the matrix
// stack unbalanced or GL bindings dangling on whatever context
// outlives this object.
if (active) {
PDEBUG("PGraphics::~PGraphics: destroying while still active "
"(beginDraw() never matched with endDraw()) -- "
"auto-closing now. this=%p\n", (void*)this);
_endDrawImpl();
}
if (msaaFbo) glDeleteFramebuffers(1, &msaaFbo);
if (msaaColorRbo) glDeleteRenderbuffers(1, &msaaColorRbo);
if (msaaDepthRbo) glDeleteRenderbuffers(1, &msaaDepthRbo);
if (fbo) glDeleteFramebuffers(1, &fbo);
if (rbo) glDeleteRenderbuffers(1, &rbo);
}
PGraphics(const PGraphics&) __attribute__((error(
"E0001: PGraphics value-style copying is not supported. "
"Declare PGraphics* instead of PGraphics. "
"See https://processing-cpp.github.io/error/E0001.html"
)));
PGraphics& operator=(const PGraphics&) __attribute__((error(
"E0001: PGraphics value-style assignment is not supported. "
"Declare PGraphics* instead of PGraphics. "
"See https://processing-cpp.github.io/error/E0001.html"
)));
// Allow assignment from pointer (PGraphics pg; pg = createGraphics(w,h))
// [E0001] REMOVED: the legacy "PGraphics pg; pg = createGraphics(...);"
// value-style assignment is no longer supported. PGraphics owns
// unique GPU resources (FBO, renderbuffers, texture) -- unlike
// PShape/PFont, which hold only plain CPU-side data and are safely
// copyable, copying or reassigning a PGraphics VALUE has no safe
// meaning. Declare it as a pointer instead:
//
// PGraphics* pg;
// pg = createGraphics(w, h);
// pg->beginDraw();
// ...
// pg->endDraw();
//
// This explicit compile error is intentional: it tells you exactly
// what to fix, rather than silently compiling against a value-style
// declaration that would behave incorrectly or unsafely.
// See: https://processing-cpp.github.io/error/E0001
PGraphics& operator=(PGraphics* p) __attribute__((error(
"E0001: PGraphics value-style assignment is not supported. "
"Declare PGraphics* instead of PGraphics. "
"See https://processing-cpp.github.io/error/E0001"
)));
};</div><h2>Under the Hood</h2><p style="font-size:13px;color:#888;margin-bottom:0.75rem;">From Processing.cpp:</p><div class="impl-block">PGraphics* PApplet::createGraphics(int w,int h){return new PGraphics(w,h);
return new PGraphics(w, h, renderer == P3D);</div>
</div>
</div>
<footer><p>C++ Mode for Processing</p><p class="footer-contact"><a href="mailto:[email protected]">[email protected]</a> · <a href="https://discord.gg/vShSrPegJT">Discord</a></p></footer>
<script src="../assets/nav.js"></script>
</body>
</html>