Skip to content

Commit

Permalink
Merge pull request #713 from jonobr1/710-no-commands
Browse files Browse the repository at this point in the history
710 noFill & noStroke yield "none"
  • Loading branch information
jonobr1 authored Oct 16, 2023
2 parents 7f6d95d + 63a805d commit cccc66b
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 45 deletions.
18 changes: 9 additions & 9 deletions build/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ var Two = (() => {
canvas: "CanvasRenderer"
},
Version: "v0.8.12",
PublishDate: "2023-08-11T22:30:04.119Z",
PublishDate: "2023-10-16T17:55:26.551Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -4188,11 +4188,11 @@ var Two = (() => {
return result;
}
noFill() {
this.fill = "transparent";
this.fill = "none";
return this;
}
noStroke() {
this.stroke = void 0;
this.stroke = "none";
return this;
}
corner() {
Expand Down Expand Up @@ -4238,7 +4238,7 @@ var Two = (() => {
matrix = shallow ? this.matrix : this.worldMatrix;
border = (this.linewidth || 0) / 2;
l = this._renderer.vertices.length;
if (this.linewidth > 0 || this.stroke && this.stroke !== "transparent") {
if (this.linewidth > 0 || this.stroke && !/(transparent|none)/i.test(this.stroke)) {
if (this.matrix.manual) {
const { scaleX, scaleY } = decomposeMatrix(
matrix.elements[0],
Expand Down Expand Up @@ -5725,7 +5725,7 @@ var Two = (() => {
_weight = 500;
_decoration = "none";
_fill = "#000";
_stroke = "transparent";
_stroke = "none";
_linewidth = 1;
_opacity = 1;
_visible = true;
Expand Down Expand Up @@ -5817,12 +5817,12 @@ var Two = (() => {
return result;
}
noFill() {
this.fill = "transparent";
this.fill = "none";
return this;
}
noStroke() {
this.stroke = void 0;
this.linewidth = void 0;
this.stroke = "none";
this.linewidth = 0;
return this;
}
getBoundingClientRect(shallow) {
Expand Down Expand Up @@ -6379,7 +6379,7 @@ var Two = (() => {
}
elem[prop] = ref;
} else {
elem[prop] = /none/i.test(value) ? "transparent" : value;
elem[prop] = value;
}
break;
case "id":
Expand Down
2 changes: 1 addition & 1 deletion build/two.min.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions build/two.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ var Constants = {
canvas: "CanvasRenderer"
},
Version: "v0.8.12",
PublishDate: "2023-08-11T22:30:04.119Z",
PublishDate: "2023-10-16T17:55:26.551Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -4169,11 +4169,11 @@ var _Path = class extends Shape {
return result;
}
noFill() {
this.fill = "transparent";
this.fill = "none";
return this;
}
noStroke() {
this.stroke = void 0;
this.stroke = "none";
return this;
}
corner() {
Expand Down Expand Up @@ -4219,7 +4219,7 @@ var _Path = class extends Shape {
matrix = shallow ? this.matrix : this.worldMatrix;
border = (this.linewidth || 0) / 2;
l = this._renderer.vertices.length;
if (this.linewidth > 0 || this.stroke && this.stroke !== "transparent") {
if (this.linewidth > 0 || this.stroke && !/(transparent|none)/i.test(this.stroke)) {
if (this.matrix.manual) {
const { scaleX, scaleY } = decomposeMatrix(
matrix.elements[0],
Expand Down Expand Up @@ -5708,7 +5708,7 @@ var _Text = class extends Shape {
__publicField(this, "_weight", 500);
__publicField(this, "_decoration", "none");
__publicField(this, "_fill", "#000");
__publicField(this, "_stroke", "transparent");
__publicField(this, "_stroke", "none");
__publicField(this, "_linewidth", 1);
__publicField(this, "_opacity", 1);
__publicField(this, "_visible", true);
Expand Down Expand Up @@ -5798,12 +5798,12 @@ var _Text = class extends Shape {
return result;
}
noFill() {
this.fill = "transparent";
this.fill = "none";
return this;
}
noStroke() {
this.stroke = void 0;
this.linewidth = void 0;
this.stroke = "none";
this.linewidth = 0;
return this;
}
getBoundingClientRect(shallow) {
Expand Down Expand Up @@ -6360,7 +6360,7 @@ function applySvgAttributes(node, elem, parentStyles) {
}
elem[prop] = ref;
} else {
elem[prop] = /none/i.test(value) ? "transparent" : value;
elem[prop] = value;
}
break;
case "id":
Expand Down
10 changes: 5 additions & 5 deletions src/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,20 +487,20 @@ export class Path extends Shape {
/**
* @name Two.Path#noFill
* @function
* @description Short hand method to set fill to `transparent`.
* @description Short hand method to set fill to `none`.
*/
noFill() {
this.fill = 'transparent';
this.fill = 'none';
return this;
}

/**
* @name Two.Path#noStroke
* @function
* @description Short hand method to set stroke to `transparent`.
* @description Short hand method to set stroke to `none`.
*/
noStroke() {
this.stroke = undefined;
this.stroke = 'none';
return this;
}

Expand Down Expand Up @@ -585,7 +585,7 @@ export class Path extends Shape {
border = (this.linewidth || 0) / 2;
l = this._renderer.vertices.length;

if (this.linewidth > 0 || (this.stroke && this.stroke !== 'transparent')) {
if (this.linewidth > 0 || (this.stroke && !(/(transparent|none)/i.test(this.stroke)))) {
if (this.matrix.manual) {
const { scaleX, scaleY } = decomposeMatrix(
matrix.elements[0], matrix.elements[3], matrix.elements[1],
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ export class Points extends Shape {
/**
* @name Two.Points#noFill
* @function
* @description Short hand method to set fill to `transparent`.
* @description Short hand method to set fill to `none`.
*/
noFill = Path.prototype.noFill;

/**
* @name Two.Points#noStroke
* @function
* @description Short hand method to set stroke to `transparent`.
* @description Short hand method to set stroke to `none`.
*/
noStroke = Path.prototype.noStroke;

Expand Down
12 changes: 6 additions & 6 deletions src/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class Text extends Shape {
* @property {(String|Two.Gradient|Two.Texture)} - The value of what the text object should be filled in with.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/color_value} for more information on CSS's colors as `String`.
*/
_stroke = 'transparent';
_stroke = 'none';

/**
* @name Two.Text#linewidth
Expand Down Expand Up @@ -406,21 +406,21 @@ export class Text extends Shape {
/**
* @name Two.Text#noFill
* @function
* @description Short hand method to set fill to `transparent`.
* @description Short hand method to set fill to `none`.
*/
noFill() {
this.fill = 'transparent';
this.fill = 'none';
return this;
}

/**
* @name Two.Text#noStroke
* @function
* @description Short hand method to set stroke to `transparent`.
* @description Short hand method to set stroke to `none`.
*/
noStroke() {
this.stroke = undefined;
this.linewidth = undefined;
this.stroke = 'none';
this.linewidth = 0;
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/interpret-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function applySvgAttributes(node, elem, parentStyles) {
}
elem[prop] = ref;
} else {
elem[prop] = (/none/i.test(value)) ? 'transparent' : value;
elem[prop] = value;
}
break;
case 'id':
Expand Down
Loading

0 comments on commit cccc66b

Please sign in to comment.