@gitborlando/geo 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @gitborlando/geo
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2b4693c: 更新xy类
8
+ - 0ee9da2: XY类小幅更新
9
+
3
10
  ## 3.0.0
4
11
 
5
12
  ### Major Changes
package/dist/index.d.ts CHANGED
@@ -221,6 +221,14 @@ declare class XY {
221
221
  getDot(another: IXY): number;
222
222
  getDistance(another: IXY): number;
223
223
  getAngle(another: IXY, origin: IXY): number;
224
+ primitive(): {
225
+ x: number;
226
+ y: number;
227
+ };
228
+ static _(x?: number, y?: number): {
229
+ x: number;
230
+ y: number;
231
+ };
224
232
  static of(x: number, y: number): XY;
225
233
  static from(xy: IXY): XY;
226
234
  static center(xy: {
package/dist/index.js CHANGED
@@ -185,10 +185,17 @@ var XY = class _XY {
185
185
  Math.atan2(this.y - origin.y, this.x - origin.x) - Math.atan2(another.y - origin.y, another.x - origin.x)
186
186
  );
187
187
  }
188
+ primitive() {
189
+ return { x: this.x, y: this.y };
190
+ }
191
+ static _(x = 0, y = 0) {
192
+ return { x, y };
193
+ }
188
194
  static of(x, y) {
189
195
  return new _XY(x, y);
190
196
  }
191
197
  static from(xy) {
198
+ if (xy instanceof _XY) return xy;
192
199
  return _XY.of(xy.x, xy.y);
193
200
  }
194
201
  static center(xy) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitborlando/geo",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
package/src/xy.ts CHANGED
@@ -148,11 +148,20 @@ export class XY {
148
148
  )
149
149
  }
150
150
 
151
+ primitive() {
152
+ return { x: this.x, y: this.y }
153
+ }
154
+
155
+ static _(x: number = 0, y: number = 0) {
156
+ return { x, y }
157
+ }
158
+
151
159
  static of(x: number, y: number) {
152
160
  return new XY(x, y)
153
161
  }
154
162
 
155
163
  static from(xy: IXY) {
164
+ if (xy instanceof XY) return xy
156
165
  return XY.of(xy.x, xy.y)
157
166
  }
158
167