-
-
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 6 commits
b78818b
178d2cb
50d6530
78cb39d
3d7d1c5
c91eb44
3933911
63cc5a0
4fe8021
1f61661
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -75,7 +75,6 @@ class Renderer2D extends Renderer { | |||
| } | ||||
| // Set and return p5.Element | ||||
| this.wrappedElt = new Element(this.elt, this._pInst); | ||||
|
|
||||
| this.clipPath = null; | ||||
| } | ||||
|
|
||||
|
|
@@ -179,8 +178,8 @@ class Renderer2D extends Renderer { | |||
| const color = this._pInst.color(...args); | ||||
|
|
||||
| //accessible Outputs | ||||
| if (this._pInst._addAccsOutput()) { | ||||
| this._pInst._accsBackground(color._getRGBA([255, 255, 255, 255])); | ||||
| if (this._pInst._addAccsOutput?.()) { | ||||
|
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. Also minor: I don't think I've seen the
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, I think here in dev-2.0 branch, we uses chaining as well. Line 711 in d51184b
I think, if I choose optional chaining operator that will keep our code a bit cleaner than repeating the property name with
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. Minor: No worries, my oversight! Please keep the chaining use but please add a more descriptive incline comment to explain? To make it more easy to understand for new contributors. Rather than "accessible Outputs" something more like "add accessible outputs if possible; on success...", what do you think?
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. Yes, sure. I'll do it now. |
||||
| this._pInst._accsBackground?.(color._getRGBA([255, 255, 255, 255])); | ||||
| } | ||||
|
|
||||
| const newFill = color.toString(); | ||||
|
|
@@ -212,8 +211,8 @@ class Renderer2D extends Renderer { | |||
| this._setFill(color.toString()); | ||||
|
|
||||
| //accessible Outputs | ||||
| if (this._pInst._addAccsOutput()) { | ||||
| this._pInst._accsCanvasColors('fill', color._getRGBA([255, 255, 255, 255])); | ||||
| if (this._pInst._addAccsOutput?.()) { | ||||
| this._pInst._accsCanvasColors?.('fill', color._getRGBA([255, 255, 255, 255])); | ||||
| } | ||||
| } | ||||
|
|
||||
|
|
@@ -223,8 +222,8 @@ class Renderer2D extends Renderer { | |||
| this._setStroke(color.toString()); | ||||
|
|
||||
| //accessible Outputs | ||||
| if (this._pInst._addAccsOutput()) { | ||||
| this._pInst._accsCanvasColors('stroke', color._getRGBA([255, 255, 255, 255])); | ||||
| if (this._pInst._addAccsOutput?.()) { | ||||
| this._pInst._accsCanvasColors?.('stroke', color._getRGBA([255, 255, 255, 255])); | ||||
| } | ||||
| } | ||||
|
|
||||
|
|
||||
| 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) { | ||
|
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. I think a little more inline docs could be useful here to explain the logic |
||
| 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.
Very minor: trailing slash / accidental line change here