Skip to content

Commit

Permalink
chore: commit changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Aug 4, 2023
1 parent 801cc96 commit 3856560
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .changeset/five-rules-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@antv/g-plugin-device-renderer': patch
'@antv/g-plugin-annotation': patch
'@antv/g-shader-components': patch
'@antv/g-plugin-box2d': patch
'@antv/g-lite': patch
---

Fix points type in Polyline & Polygon.
4 changes: 2 additions & 2 deletions packages/g-lite/src/css/properties/CSSPropertyPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export class CSSPropertyPoints
Partial<
CSSProperty<
{
points: [number, number, number?][];
points: [number, number][];
totalLength: number;
segments: [number, number][];
},
{
points: [number, number, number?][];
points: [number, number][];
totalLength: number;
segments: [number, number][];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/g-lite/src/display-objects/Polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Shape } from '../types';
import { DisplayObject, isDisplayObject } from './DisplayObject';

export interface PolygonStyleProps extends BaseStyleProps {
points: [number, number, number?][];
points: ([number, number] | [number, number, number])[];
/**
* marker will be positioned at the first point
*/
Expand All @@ -31,7 +31,7 @@ export interface PolygonStyleProps extends BaseStyleProps {
}
export interface ParsedPolygonStyleProps extends ParsedBaseStyleProps {
points: {
points: [number, number, number?][];
points: ([number, number] | [number, number, number])[];
segments: [number, number][];
totalLength: number;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/g-lite/src/display-objects/Polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { DisplayObject } from './DisplayObject';
import { Polygon } from './Polygon';

export interface PolylineStyleProps extends BaseStyleProps {
points: [number, number, number?][];
points: ([number, number] | [number, number, number])[];
/**
* marker will be positioned at the first point
*/
Expand All @@ -34,7 +34,7 @@ export interface PolylineStyleProps extends BaseStyleProps {
}
export interface ParsedPolylineStyleProps extends ParsedBaseStyleProps {
points: {
points: [number, number, number?][];
points: ([number, number] | [number, number, number])[];
segments: [number, number][];
totalLength: number;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/g-lite/src/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ function ellipseToCommands(
}

function polygonToCommands(
points: [number, number, number?][],
points: ([number, number] | [number, number, number])[],
closed: boolean,
): AbsoluteArray {
const result = points.map((point, i) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ export class SelectableRectPolygon extends AbstractSelectable<Polygon> {
];
const handleVec = vec2.normalize(
vec2.create(),
vec2.sub(vec2.create(), points.points[0], points.points[3]),
vec2.sub(
vec2.create(),
points.points[0] as [number, number],
points.points[3] as [number, number],
),
);
this.rotateAnchor.setPosition(
handleVec[0] * rotateAnchorDistance + midPoint[0],
Expand Down
4 changes: 3 additions & 1 deletion packages/g-plugin-box2d/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/**
* @see https://stackoverflow.com/questions/45660743/sort-points-in-counter-clockwise-in-javascript
*/
export function sortPointsInCCW(pts: [number, number][]): [number, number][] {
export function sortPointsInCCW(
pts: ([number, number] | [number, number, number])[],
): [number, number][] {
const points = pts.map(([x, y]) => ({
x,
y,
Expand Down

0 comments on commit 3856560

Please sign in to comment.