Skip to content

Commit

Permalink
Merge pull request #763 from jonobr1/types-improvement
Browse files Browse the repository at this point in the history
Types Improvement
  • Loading branch information
jonobr1 authored Feb 13, 2025
2 parents 1d0c63b + 1e470e8 commit 1a523ee
Show file tree
Hide file tree
Showing 11 changed files with 531 additions and 156 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012 - 2024 @jonobr1 / http://jono.fyi
Copyright (c) 2012 - 2025 @jonobr1 / http://jono.fyi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 21 additions & 7 deletions build/two.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
MIT License
Copyright (c) 2012 - 2024 @jonobr1 / http://jono.fyi
Copyright (c) 2012 - 2025 @jonobr1 / http://jono.fyi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -767,7 +767,7 @@ var Two = (() => {
canvas: "CanvasRenderer"
},
Version: "v0.8.16",
PublishDate: "2025-02-13T20:00:23.550Z",
PublishDate: "2025-02-13T20:00:59.976Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -1407,7 +1407,7 @@ var Two = (() => {
};

// src/element.js
var Element = class extends Events {
var _Element = class extends Events {
_flagId = false;
_flagClassName = false;
_renderer = {};
Expand All @@ -1421,14 +1421,15 @@ var Two = (() => {
}
}
static fromObject(obj) {
const elem = new Element().copy(obj);
const elem = new _Element().copy(obj);
if ("id" in obj) {
elem.id = obj.id;
}
return elem;
}
flagReset() {
this._flagId = this._flagClassName = false;
return this;
}
copy(element) {
this.renderer.type = element.renderer.type;
Expand All @@ -1443,6 +1444,8 @@ var Two = (() => {
};
}
};
var Element = _Element;
__publicField(Element, "Properties", ["renderer", "id", "className"]);
var proto3 = {
renderer: {
enumerable: false,
Expand Down Expand Up @@ -2748,7 +2751,7 @@ var Two = (() => {
setMatrix(Matrix2);

// src/shape.js
var Shape = class extends Element {
var _Shape = class extends Element {
_flagMatrix = true;
_flagScale = false;
_matrix = null;
Expand All @@ -2774,7 +2777,7 @@ var Two = (() => {
this.skewY = 0;
}
static fromObject(obj) {
const shape = new Shape().copy(obj);
const shape = new _Shape().copy(obj);
if ("id" in obj) {
shape.id = obj.id;
}
Expand Down Expand Up @@ -2831,7 +2834,7 @@ var Two = (() => {
return this;
}
clone(parent) {
const clone = new Shape();
const clone = new _Shape();
clone.position.copy(this.position);
clone.rotation = this.rotation;
clone.scale = this.scale;
Expand Down Expand Up @@ -2882,6 +2885,16 @@ var Two = (() => {
return this;
}
};
var Shape = _Shape;
__publicField(Shape, "Properties", [
"position",
"rotation",
"scale",
"skewX",
"skewY",
"matrix",
"worldMatrix"
]);
var proto9 = {
position: {
enumerable: true,
Expand Down Expand Up @@ -11526,6 +11539,7 @@ var Two = (() => {
__publicField(Two, "Matrix", Matrix2);
__publicField(Two, "Path", Path);
__publicField(Two, "Registry", Registry);
__publicField(Two, "Element", Element);
__publicField(Two, "Shape", Shape);
__publicField(Two, "Text", Text);
__publicField(Two, "Vector", Vector);
Expand Down
6 changes: 3 additions & 3 deletions build/two.min.js

Large diffs are not rendered by default.

28 changes: 21 additions & 7 deletions build/two.module.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
MIT License
Copyright (c) 2012 - 2024 @jonobr1 / http://jono.fyi
Copyright (c) 2012 - 2025 @jonobr1 / http://jono.fyi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -783,7 +783,7 @@ var Constants = {
canvas: "CanvasRenderer"
},
Version: "v0.8.16",
PublishDate: "2025-02-13T20:00:23.550Z",
PublishDate: "2025-02-13T20:00:59.976Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -1425,7 +1425,7 @@ var Collection = class extends Array {
_events = new WeakMap();

// src/element.js
var Element = class extends Events {
var _Element = class extends Events {
constructor() {
super();
__publicField(this, "_flagId", false);
Expand All @@ -1439,14 +1439,15 @@ var Element = class extends Events {
}
}
static fromObject(obj) {
const elem = new Element().copy(obj);
const elem = new _Element().copy(obj);
if ("id" in obj) {
elem.id = obj.id;
}
return elem;
}
flagReset() {
this._flagId = this._flagClassName = false;
return this;
}
copy(element) {
this.renderer.type = element.renderer.type;
Expand All @@ -1461,6 +1462,8 @@ var Element = class extends Events {
};
}
};
var Element = _Element;
__publicField(Element, "Properties", ["renderer", "id", "className"]);
var proto3 = {
renderer: {
enumerable: false,
Expand Down Expand Up @@ -2766,7 +2769,7 @@ __publicField(Matrix2, "Identity", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
setMatrix(Matrix2);

// src/shape.js
var Shape = class extends Element {
var _Shape = class extends Element {
constructor() {
super();
__publicField(this, "_flagMatrix", true);
Expand All @@ -2792,7 +2795,7 @@ var Shape = class extends Element {
this.skewY = 0;
}
static fromObject(obj) {
const shape = new Shape().copy(obj);
const shape = new _Shape().copy(obj);
if ("id" in obj) {
shape.id = obj.id;
}
Expand Down Expand Up @@ -2849,7 +2852,7 @@ var Shape = class extends Element {
return this;
}
clone(parent) {
const clone = new Shape();
const clone = new _Shape();
clone.position.copy(this.position);
clone.rotation = this.rotation;
clone.scale = this.scale;
Expand Down Expand Up @@ -2900,6 +2903,16 @@ var Shape = class extends Element {
return this;
}
};
var Shape = _Shape;
__publicField(Shape, "Properties", [
"position",
"rotation",
"scale",
"skewX",
"skewY",
"matrix",
"worldMatrix"
]);
var proto9 = {
position: {
enumerable: true,
Expand Down Expand Up @@ -11546,6 +11559,7 @@ __publicField(Two, "Group", Group);
__publicField(Two, "Matrix", Matrix2);
__publicField(Two, "Path", Path);
__publicField(Two, "Registry", Registry);
__publicField(Two, "Element", Element);
__publicField(Two, "Shape", Shape);
__publicField(Two, "Text", Text);
__publicField(Two, "Vector", Vector);
Expand Down
2 changes: 1 addition & 1 deletion src/effects/radial-gradient.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class RadialGradient extends Gradient {
* @name Two.RadialGradient#clone
* @function
* @param {Two.Group} [parent] - The parent group or scene to add the clone to.
* @returns {Two.Gradient}
* @returns {Two.RadialGradient}
* @description Create a new instance of {@link Two.RadialGradient} with the same properties of the current path.
*/
clone(parent) {
Expand Down
2 changes: 1 addition & 1 deletion src/effects/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class Texture extends Element {
}

/**
* @name Two.Text.Register
* @name Two.Texture.Register
* @interface
* @description A collection of functions to register different types of textures. Used internally by a {@link Two.Texture}.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class Element extends Events {
}
}

static Properties = ['renderer', 'id', 'className'];

/**
* @name Two.Element.fromObject
* @function
Expand All @@ -81,6 +83,7 @@ export class Element extends Events {
*/
flagReset() {
this._flagId = this._flagClassName = false;
return this;
}

copy(element) {
Expand Down
10 changes: 10 additions & 0 deletions src/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ export class Shape extends Element {
this.skewY = 0;
}

static Properties = [
'position',
'rotation',
'scale',
'skewX',
'skewY',
'matrix',
'worldMatrix',
];

/**
* @name Two.Shape.fromObject
* @function
Expand Down
2 changes: 2 additions & 0 deletions src/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Group } from './group.js';
import { Matrix } from './matrix.js';
import { Path } from './path.js';
import { Registry } from './registry.js';
import { Element } from 'element.js';
import { Shape } from './shape.js';
import { Text } from './text.js';
import { Vector } from './vector.js';
Expand Down Expand Up @@ -330,6 +331,7 @@ export default class Two {
static Matrix = Matrix;
static Path = Path;
static Registry = Registry;
static Element = Element;
static Shape = Shape;
static Text = Text;
static Vector = Vector;
Expand Down
Loading

0 comments on commit 1a523ee

Please sign in to comment.