@remotion/shapes 4.0.59 → 4.0.60
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/README.md +2 -0
- package/dist/components/polygon.d.ts +5 -0
- package/dist/components/polygon.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/utils/make-polygon.d.ts +16 -0
- package/dist/utils/make-polygon.js +46 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,10 +12,12 @@ No dependencies are needed, meaning this package can be used independently of Re
|
|
|
12
12
|
- [`makeCircle()`](https://remotion.dev/docs/shapes/make-circle)
|
|
13
13
|
- [`makeTriangle()`](https://remotion.dev/docs/shapes/make-triangle)
|
|
14
14
|
- [`makeEllipse()`](https://remotion.dev/docs/shapes/make-ellipse)
|
|
15
|
+
- [`makePolygon()`](https://remotion.dev/docs/shapes/make-polygon)
|
|
15
16
|
- [`<Circle />`](https://remotion.dev/docs/shapes/circle)
|
|
16
17
|
- [`<Rect />`](https://remotion.dev/shapes/shapes/rect)
|
|
17
18
|
- [`<Triangle />`](https://remotion.dev/shapes/shapes/triangle)
|
|
18
19
|
- [`<Ellipse />`](https://remotion.dev/shapes/shapes/ellipse)
|
|
20
|
+
- [`<Polygon />`](https://remotion.dev/shapes/shapes/polygon)
|
|
19
21
|
|
|
20
22
|
## License
|
|
21
23
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MakePolygonProps } from '../utils/make-polygon';
|
|
3
|
+
import type { AllShapesProps } from './render-svg';
|
|
4
|
+
export type PolygonProps = MakePolygonProps & Omit<AllShapesProps, 'points'>;
|
|
5
|
+
export declare const Polygon: React.FC<PolygonProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Polygon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_polygon_1 = require("../utils/make-polygon");
|
|
6
|
+
const render_svg_1 = require("./render-svg");
|
|
7
|
+
const Polygon = ({ points, radius, cornerRadius, edgeRoundness, ...props }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(render_svg_1.RenderSvg, { ...(0, make_polygon_1.makePolygon)({
|
|
9
|
+
points,
|
|
10
|
+
cornerRadius,
|
|
11
|
+
edgeRoundness,
|
|
12
|
+
radius,
|
|
13
|
+
}), ...props }));
|
|
14
|
+
};
|
|
15
|
+
exports.Polygon = Polygon;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ export { Instruction } from '@remotion/paths';
|
|
|
2
2
|
export { Circle, CircleProps } from './components/circle';
|
|
3
3
|
export { Ellipse, EllipseProps } from './components/ellipse';
|
|
4
4
|
export { Pie, PieProps } from './components/pie';
|
|
5
|
+
export { Polygon, PolygonProps } from './components/polygon';
|
|
5
6
|
export { Rect, RectProps } from './components/rect';
|
|
6
7
|
export { Star, StarProps } from './components/star';
|
|
7
8
|
export { Triangle, TriangleProps } from './components/triangle';
|
|
8
9
|
export { makeCircle, MakeCircleProps } from './utils/make-circle';
|
|
9
10
|
export { makeEllipse, MakeEllipseOptions } from './utils/make-ellipse';
|
|
10
11
|
export { makePie, MakePieProps } from './utils/make-pie';
|
|
12
|
+
export { makePolygon, MakePolygonProps } from './utils/make-polygon';
|
|
11
13
|
export { makeRect, MakeRectOptions } from './utils/make-rect';
|
|
12
14
|
export { makeStar, MakeStarProps } from './utils/make-star';
|
|
13
15
|
export { makeTriangle, MakeTriangleProps } from './utils/make-triangle';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeTriangle = exports.makeStar = exports.makeRect = exports.makePie = exports.makeEllipse = exports.makeCircle = exports.Triangle = exports.Star = exports.Rect = exports.Pie = exports.Ellipse = exports.Circle = void 0;
|
|
3
|
+
exports.makeTriangle = exports.makeStar = exports.makeRect = exports.makePolygon = exports.makePie = exports.makeEllipse = exports.makeCircle = exports.Triangle = exports.Star = exports.Rect = exports.Polygon = exports.Pie = exports.Ellipse = exports.Circle = void 0;
|
|
4
4
|
var circle_1 = require("./components/circle");
|
|
5
5
|
Object.defineProperty(exports, "Circle", { enumerable: true, get: function () { return circle_1.Circle; } });
|
|
6
6
|
var ellipse_1 = require("./components/ellipse");
|
|
7
7
|
Object.defineProperty(exports, "Ellipse", { enumerable: true, get: function () { return ellipse_1.Ellipse; } });
|
|
8
8
|
var pie_1 = require("./components/pie");
|
|
9
9
|
Object.defineProperty(exports, "Pie", { enumerable: true, get: function () { return pie_1.Pie; } });
|
|
10
|
+
var polygon_1 = require("./components/polygon");
|
|
11
|
+
Object.defineProperty(exports, "Polygon", { enumerable: true, get: function () { return polygon_1.Polygon; } });
|
|
10
12
|
var rect_1 = require("./components/rect");
|
|
11
13
|
Object.defineProperty(exports, "Rect", { enumerable: true, get: function () { return rect_1.Rect; } });
|
|
12
14
|
var star_1 = require("./components/star");
|
|
@@ -19,6 +21,8 @@ var make_ellipse_1 = require("./utils/make-ellipse");
|
|
|
19
21
|
Object.defineProperty(exports, "makeEllipse", { enumerable: true, get: function () { return make_ellipse_1.makeEllipse; } });
|
|
20
22
|
var make_pie_1 = require("./utils/make-pie");
|
|
21
23
|
Object.defineProperty(exports, "makePie", { enumerable: true, get: function () { return make_pie_1.makePie; } });
|
|
24
|
+
var make_polygon_1 = require("./utils/make-polygon");
|
|
25
|
+
Object.defineProperty(exports, "makePolygon", { enumerable: true, get: function () { return make_polygon_1.makePolygon; } });
|
|
22
26
|
var make_rect_1 = require("./utils/make-rect");
|
|
23
27
|
Object.defineProperty(exports, "makeRect", { enumerable: true, get: function () { return make_rect_1.makeRect; } });
|
|
24
28
|
var make_star_1 = require("./utils/make-star");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ShapeInfo } from './shape-info';
|
|
2
|
+
export type MakePolygonProps = {
|
|
3
|
+
points: number;
|
|
4
|
+
radius: number;
|
|
5
|
+
edgeRoundness?: number | null;
|
|
6
|
+
cornerRadius?: number;
|
|
7
|
+
};
|
|
8
|
+
export type PolygonProps = {
|
|
9
|
+
centerX: number;
|
|
10
|
+
centerY: number;
|
|
11
|
+
points: number;
|
|
12
|
+
radius: number;
|
|
13
|
+
edgeRoundness: number | null;
|
|
14
|
+
cornerRadius: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const makePolygon: ({ points, radius, cornerRadius, edgeRoundness, }: MakePolygonProps) => ShapeInfo;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePolygon = void 0;
|
|
4
|
+
const paths_1 = require("@remotion/paths");
|
|
5
|
+
const join_points_1 = require("./join-points");
|
|
6
|
+
function polygon({ points, radius, centerX, centerY, cornerRadius, edgeRoundness, }) {
|
|
7
|
+
const degreeIncrement = (Math.PI * 2) / points;
|
|
8
|
+
const d = new Array(points).fill(0).map((_, i) => {
|
|
9
|
+
const angle = degreeIncrement * i - Math.PI / 2;
|
|
10
|
+
const point = {
|
|
11
|
+
x: centerX + radius * Math.cos(angle),
|
|
12
|
+
y: centerY + radius * Math.sin(angle),
|
|
13
|
+
};
|
|
14
|
+
return [point.x, point.y];
|
|
15
|
+
});
|
|
16
|
+
return (0, join_points_1.joinPoints)([...d, d[0]], {
|
|
17
|
+
edgeRoundness,
|
|
18
|
+
cornerRadius,
|
|
19
|
+
roundCornerStrategy: cornerRadius > 0 ? 'bezier' : 'arc',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const makePolygon = ({ points, radius, cornerRadius = 0, edgeRoundness = null, }) => {
|
|
23
|
+
if (points < 3) {
|
|
24
|
+
throw new Error(`"points" should be minimum 3, got ${points}`);
|
|
25
|
+
}
|
|
26
|
+
const width = 2 * radius;
|
|
27
|
+
const height = 2 * radius;
|
|
28
|
+
const centerX = width / 2;
|
|
29
|
+
const centerY = height / 2;
|
|
30
|
+
const polygonPathInstructions = polygon({
|
|
31
|
+
points,
|
|
32
|
+
radius,
|
|
33
|
+
centerX,
|
|
34
|
+
centerY,
|
|
35
|
+
cornerRadius,
|
|
36
|
+
edgeRoundness,
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
path: (0, paths_1.serializeInstructions)(polygonPathInstructions),
|
|
40
|
+
width,
|
|
41
|
+
height,
|
|
42
|
+
transformOrigin: `${centerX} ${centerY}`,
|
|
43
|
+
instructions: polygonPathInstructions,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.makePolygon = makePolygon;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/shapes",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.60",
|
|
4
4
|
"description": "Utility functions and components for SVG shapes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-dom": ">=16.8.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@remotion/paths": "4.0.
|
|
41
|
+
"@remotion/paths": "4.0.60"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"formatting": "prettier src --check",
|