Skip to content

Commit 76f4b03

Browse files
committed
feat: remove setPoints and change fromPoints signature
- match pex-math - update tests
1 parent 57b149f commit 76f4b03

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

README.md

+2-15
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ A ray defined by a starting 3D point origin and a 3D direction vector.
392392
- [.copy(b)](#module_rect.copy)[<code>rect</code>](#module_rect..rect)
393393
- [.set(a, b)](#module_rect.set)[<code>rect</code>](#module_rect..rect)
394394
- [.isEmpty(a)](#module_rect.isEmpty) ⇒ <code>boolean</code>
395-
- [.fromPoints(points)](#module_rect.fromPoints)[<code>rect</code>](#module_rect..rect)
396-
- [.setPoints(a, points)](#module_rect.setPoints)[<code>rect</code>](#module_rect..rect)
395+
- [.fromPoints(a, points)](#module_rect.fromPoints)[<code>rect</code>](#module_rect..rect)
397396
- [.getPoints(a, points)](#module_rect.getPoints) ⇒ <code>Array.&lt;module:pex-math~vec2&gt;</code>
398397
- [.scale(a, n)](#module_rect.scale)[<code>rect</code>](#module_rect..rect)
399398
- [.setSize(a, size)](#module_rect.setSize)[<code>rect</code>](#module_rect..rect)
@@ -470,19 +469,7 @@ Checks if a rectangle is empty.
470469

471470
<a name="module_rect.fromPoints"></a>
472471

473-
### rect.fromPoints(points) ⇒ [<code>rect</code>](#module_rect..rect)
474-
475-
Creates a rectangle from a list of points.
476-
477-
**Kind**: static method of [<code>rect</code>](#module_rect)
478-
479-
| Param | Type |
480-
| ------ | ----------------------------------------------- |
481-
| points | <code>Array.&lt;module:pex-math~vec2&gt;</code> |
482-
483-
<a name="module_rect.setPoints"></a>
484-
485-
### rect.setPoints(a, points) ⇒ [<code>rect</code>](#module_rect..rect)
472+
### rect.fromPoints(a, points) ⇒ [<code>rect</code>](#module_rect..rect)
486473

487474
Updates a rectangle from a list of points.
488475

rect.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,13 @@ export function isEmpty(a) {
5959
return a[0][0] > a[1][0] || a[0][1] > a[1][1];
6060
}
6161

62-
/**
63-
* Creates a rectangle from a list of points.
64-
* @param {import("pex-math").vec2[]} points
65-
* @returns {rect}
66-
*/
67-
export function fromPoints(points) {
68-
return setPoints(create(), points);
69-
}
70-
7162
/**
7263
* Updates a rectangle from a list of points.
7364
* @param {rect} a
7465
* @param {import("pex-math").vec2[]} points
7566
* @returns {rect}
7667
*/
77-
export function setPoints(a, points) {
68+
export function fromPoints(a, points) {
7869
for (let i = 0; i < points.length; i++) {
7970
includePoint(a, points[i]);
8071
}

test/rect.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ describe("rect", () => {
5252
strictEqual(rect.isEmpty(NORM_RECT), false);
5353
});
5454

55-
it("fromPoints() should create a rectangle from a list of points", () => {
56-
deepEqual(rect.fromPoints(NORM_POINTS), NORM_RECT);
57-
});
58-
it("setPoints() should update a rectangle from a list of points", () => {
59-
deepEqual(rect.setPoints(rect.copy(DEFAULT_RECT), NORM_POINTS), NORM_RECT);
55+
it("fromPoints() should update a rectangle from a list of points", () => {
56+
deepEqual(rect.fromPoints(rect.copy(DEFAULT_RECT), NORM_POINTS), NORM_RECT);
6057
});
6158
it("getPoints() should return a list of 4 points from a rectangle", () => {
6259
deepEqual(rect.getPoints(rect.copy(NORM_RECT)), NORM_POINTS);

0 commit comments

Comments
 (0)