-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Create Graphics fixing in dev-2.0 branch. #7829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b78818b
178d2cb
50d6530
78cb39d
3d7d1c5
c91eb44
3933911
63cc5a0
4fe8021
1f61661
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,17 @@ | ||
| let g; | ||
|
|
||
| function setup() { | ||
| // put setup code here | ||
| } | ||
|
|
||
| function draw() { | ||
| // put drawing code here | ||
| } | ||
| createCanvas(400, 400); | ||
|
|
||
| g = createGraphics(200, 200); | ||
| } | ||
|
|
||
| function draw() { | ||
| g.background(0); | ||
| g.stroke(255, 0, 0); | ||
| g.strokeWeight(5); | ||
| g.noFill(); | ||
| g.bezier(0, 0, 100, 0, 0, 100, 200, 200); | ||
| //Comment out this line and for some reason the bezier gets drawn (to the canvas instead of the graphics object) | ||
| image(g, 0, 0, 400, 400); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,10 +64,16 @@ class Element { | |
| } | ||
|
|
||
| // delete the reference in this._pInst._elements | ||
| const index = this._pInst._elements.indexOf(this); | ||
| if (index !== -1) { | ||
| this._pInst._elements.splice(index, 1); | ||
| let sketch = this._pInst; | ||
| if (sketch && !sketch._elements && sketch._pInst) { | ||
| sketch = sketch._pInst; // climb one level up | ||
| } | ||
|
|
||
| if (sketch && sketch._elements) { // only if the array exists | ||
| const i = sketch._elements.indexOf(this); | ||
| if (i !== -1) sketch._elements.splice(i, 1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When is this not true / should that path also be handled?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi kit,
In both sutiotions there is no list we can remove ourselves from, so the safest action is to do nothing and just reutrn. Trying to touch a list that isn’t there would crash, so skipping the code is exactly what we want. |
||
| } | ||
|
|
||
|
|
||
| // deregister events | ||
| for (let ev in this._events) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a little more inline docs could be useful here to explain the logic