Skip to content

Commit b78818b

Browse files
committed
updated-createGraphics
1 parent c6c96f6 commit b78818b

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lib/empty-example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
background-color: #1b1b1b;
1313
}
1414
</style>
15-
<script src="../p5.rollup.min.js"></script>
15+
<script src="../p5.min.js"></script>
1616
<!-- <script src="../addons/p5.sound.js"></script> -->
1717
<script src="sketch.js"></script>
1818
</head>

src/core/p5.Graphics.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Graphics {
3030
const r = renderer || constants.P2D;
3131

3232
this._pInst = pInst;
33-
this._renderer = new renderers[r](this._pInst, w, h, false, canvas);
33+
this._renderer = new renderers[r](this, w, h, false, canvas);
3434

3535
this._initializeInstanceVariables(this);
3636

@@ -696,3 +696,6 @@ function graphics(p5, fn){
696696

697697
export default graphics;
698698
export { Graphics };
699+
if (typeof p5 !== 'undefined') {
700+
graphics(p5, p5.prototype);
701+
}

src/core/p5.Renderer2D.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ class Renderer2D extends Renderer {
179179
const color = this._pInst.color(...args);
180180

181181
//accessible Outputs
182-
if (this._pInst._addAccsOutput()) {
183-
this._pInst._accsBackground(color._getRGBA([255, 255, 255, 255]));
182+
if (this._pInst._addAccsOutput?.()) {
183+
this._pInst._accsBackground?.(color._getRGBA([255, 255, 255, 255]));
184184
}
185185

186186
const newFill = color.toString();
@@ -212,8 +212,8 @@ class Renderer2D extends Renderer {
212212
this._setFill(color.toString());
213213

214214
//accessible Outputs
215-
if (this._pInst._addAccsOutput()) {
216-
this._pInst._accsCanvasColors('fill', color._getRGBA([255, 255, 255, 255]));
215+
if (this._pInst._addAccsOutput?.()) {
216+
this._pInst._accsCanvasColors?.('fill', color._getRGBA([255, 255, 255, 255]));
217217
}
218218
}
219219

@@ -223,8 +223,8 @@ class Renderer2D extends Renderer {
223223
this._setStroke(color.toString());
224224

225225
//accessible Outputs
226-
if (this._pInst._addAccsOutput()) {
227-
this._pInst._accsCanvasColors('stroke', color._getRGBA([255, 255, 255, 255]));
226+
if (this._pInst._addAccsOutput?.()) {
227+
this._pInst._accsCanvasColors?.('stroke', color._getRGBA([255, 255, 255, 255]));
228228
}
229229
}
230230

0 commit comments

Comments
 (0)