@remotion/shapes 3.3.35 → 3.3.37
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/dist/components/return-type.d.ts +5 -0
- package/dist/components/return-type.js +2 -0
- package/dist/components/shape-info.d.ts +5 -0
- package/dist/components/shape-info.js +2 -0
- package/dist/components/star.d.ts +5 -0
- package/dist/components/star.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/make-circle.d.ts +2 -4
- package/dist/make-circle.js +3 -1
- package/dist/make-ellipse.d.ts +2 -2
- package/dist/make-rect.d.ts +1 -3
- package/dist/make-rect.js +3 -1
- package/dist/utils/make-star.d.ts +18 -0
- package/dist/utils/make-star.js +46 -0
- package/dist/utils/star.d.ts +10 -0
- package/dist/utils/star.js +34 -0
- package/package/dist/Ellipse.d.ts +10 -0
- package/package/dist/Ellipse.js +12 -0
- package/package/dist/circle.d.ts +10 -0
- package/package/dist/circle.js +13 -0
- package/package/dist/components/circle.d.ts +5 -0
- package/package/dist/components/circle.js +10 -0
- package/package/dist/components/ellipse.d.ts +5 -0
- package/package/dist/components/ellipse.js +10 -0
- package/package/dist/components/rect.d.ts +5 -0
- package/package/dist/components/rect.js +10 -0
- package/package/dist/components/render-svg.d.ts +12 -0
- package/package/dist/components/render-svg.js +21 -0
- package/package/dist/components/return-type.d.ts +5 -0
- package/package/dist/components/return-type.js +2 -0
- package/package/dist/components/shape-info.d.ts +5 -0
- package/package/dist/components/shape-info.js +2 -0
- package/package/dist/components/triangle.d.ts +5 -0
- package/package/dist/components/triangle.js +10 -0
- package/package/dist/index.d.ts +8 -0
- package/package/dist/index.js +19 -0
- package/package/dist/make-circle.d.ts +4 -0
- package/package/dist/make-circle.js +9 -0
- package/package/dist/make-ellipse.d.ts +5 -0
- package/package/dist/make-ellipse.js +7 -0
- package/package/dist/make-rect.d.ts +5 -0
- package/{dist/make-square.js → package/dist/make-rect.js} +3 -1
- package/package/dist/make-triangle.d.ts +6 -0
- package/package/dist/make-triangle.js +14 -0
- package/{dist/square.d.ts → package/dist/rect.d.ts} +1 -1
- package/{dist/square.js → package/dist/rect.js} +5 -5
- package/package/dist/triangle.d.ts +9 -0
- package/package/dist/triangle.js +13 -0
- package/package/dist/utils/make-circle.d.ts +5 -0
- package/package/dist/utils/make-circle.js +12 -0
- package/package/dist/utils/make-ellipse.d.ts +6 -0
- package/package/dist/utils/make-ellipse.js +12 -0
- package/package/dist/utils/make-rect.d.ts +6 -0
- package/package/dist/utils/make-rect.js +12 -0
- package/package/dist/utils/make-triangle.d.ts +6 -0
- package/package/dist/utils/make-triangle.js +57 -0
- package/package/dist/utils/shape-info.d.ts +6 -0
- package/package/dist/utils/shape-info.js +2 -0
- package/package.json +2 -2
- package/dist/make-square.d.ts +0 -7
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Star = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_star_1 = require("../utils/make-star");
|
|
6
|
+
const render_svg_1 = require("./render-svg");
|
|
7
|
+
const Star = ({ innerRadius, outerRadius, points, cornerRadius, edgeRoundness, ...props }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(render_svg_1.RenderSvg, { ...(0, make_star_1.makeStar)({
|
|
9
|
+
innerRadius,
|
|
10
|
+
outerRadius,
|
|
11
|
+
points,
|
|
12
|
+
cornerRadius,
|
|
13
|
+
edgeRoundness,
|
|
14
|
+
}), ...props }));
|
|
15
|
+
};
|
|
16
|
+
exports.Star = Star;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { Circle, CircleProps } from './components/circle';
|
|
2
2
|
export { Ellipse, EllipseProps } from './components/ellipse';
|
|
3
3
|
export { Rect, RectProps } from './components/rect';
|
|
4
|
+
export { Star, StarProps } from './components/star';
|
|
4
5
|
export { Triangle, TriangleProps } from './components/triangle';
|
|
5
6
|
export { Instruction } from './utils/instructions';
|
|
6
7
|
export { makeCircle, MakeCircleProps } from './utils/make-circle';
|
|
7
8
|
export { makeEllipse, MakeEllipseOptions } from './utils/make-ellipse';
|
|
8
9
|
export { makeRect, MakeRectOptions } from './utils/make-rect';
|
|
10
|
+
export { makeStar, MakeStarProps } from './utils/make-star';
|
|
9
11
|
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.makeRect = exports.makeEllipse = exports.makeCircle = exports.Triangle = exports.Rect = exports.Ellipse = exports.Circle = void 0;
|
|
3
|
+
exports.makeTriangle = exports.makeStar = exports.makeRect = exports.makeEllipse = exports.makeCircle = exports.Triangle = exports.Star = exports.Rect = 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 rect_1 = require("./components/rect");
|
|
9
9
|
Object.defineProperty(exports, "Rect", { enumerable: true, get: function () { return rect_1.Rect; } });
|
|
10
|
+
var star_1 = require("./components/star");
|
|
11
|
+
Object.defineProperty(exports, "Star", { enumerable: true, get: function () { return star_1.Star; } });
|
|
10
12
|
var triangle_1 = require("./components/triangle");
|
|
11
13
|
Object.defineProperty(exports, "Triangle", { enumerable: true, get: function () { return triangle_1.Triangle; } });
|
|
12
14
|
var make_circle_1 = require("./utils/make-circle");
|
|
@@ -15,5 +17,7 @@ var make_ellipse_1 = require("./utils/make-ellipse");
|
|
|
15
17
|
Object.defineProperty(exports, "makeEllipse", { enumerable: true, get: function () { return make_ellipse_1.makeEllipse; } });
|
|
16
18
|
var make_rect_1 = require("./utils/make-rect");
|
|
17
19
|
Object.defineProperty(exports, "makeRect", { enumerable: true, get: function () { return make_rect_1.makeRect; } });
|
|
20
|
+
var make_star_1 = require("./utils/make-star");
|
|
21
|
+
Object.defineProperty(exports, "makeStar", { enumerable: true, get: function () { return make_star_1.makeStar; } });
|
|
18
22
|
var make_triangle_1 = require("./utils/make-triangle");
|
|
19
23
|
Object.defineProperty(exports, "makeTriangle", { enumerable: true, get: function () { return make_triangle_1.makeTriangle; } });
|
package/dist/make-circle.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export declare type MakeCircleProps = {
|
|
2
|
-
|
|
3
|
-
cy?: number | string;
|
|
4
|
-
radius?: number | string;
|
|
2
|
+
radius: number;
|
|
5
3
|
};
|
|
6
|
-
export declare const makeCircle: ({
|
|
4
|
+
export declare const makeCircle: ({ radius }: MakeCircleProps) => string;
|
package/dist/make-circle.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeCircle = void 0;
|
|
4
|
-
const makeCircle = ({
|
|
4
|
+
const makeCircle = ({ radius }) => {
|
|
5
|
+
const cx = radius;
|
|
6
|
+
const cy = radius;
|
|
5
7
|
return `M ${cx} ${cy} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${radius * 2} 0 ${radius} ${radius} 0 1 0 ${-radius * 2} 0`;
|
|
6
8
|
};
|
|
7
9
|
exports.makeCircle = makeCircle;
|
package/dist/make-ellipse.d.ts
CHANGED
package/dist/make-rect.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export declare type MakeRectOptions = {
|
|
2
|
-
x?: number;
|
|
3
|
-
y?: number;
|
|
4
2
|
width: number;
|
|
5
3
|
height: number;
|
|
6
4
|
};
|
|
7
|
-
export declare const makeRect: ({
|
|
5
|
+
export declare const makeRect: ({ width, height }: MakeRectOptions) => string;
|
package/dist/make-rect.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeRect = void 0;
|
|
4
|
-
const makeRect = ({
|
|
4
|
+
const makeRect = ({ width, height }) => {
|
|
5
|
+
const x = 0;
|
|
6
|
+
const y = 0;
|
|
5
7
|
return `M ${x} ${y} l ${width} 0 l 0 ${height} l ${-width} 0 Z`;
|
|
6
8
|
};
|
|
7
9
|
exports.makeRect = makeRect;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ShapeInfo } from './shape-info';
|
|
2
|
+
export declare type MakeStarProps = {
|
|
3
|
+
points: number;
|
|
4
|
+
innerRadius: number;
|
|
5
|
+
outerRadius: number;
|
|
6
|
+
edgeRoundness?: number | null;
|
|
7
|
+
cornerRadius?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare type StarProps = {
|
|
10
|
+
centerX: number;
|
|
11
|
+
centerY: number;
|
|
12
|
+
points: number;
|
|
13
|
+
innerRadius: number;
|
|
14
|
+
outerRadius: number;
|
|
15
|
+
edgeRoundness: number | null;
|
|
16
|
+
cornerRadius: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const makeStar: ({ points, innerRadius, outerRadius, cornerRadius, edgeRoundness, }: MakeStarProps) => ShapeInfo;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copied from https://stackblitz.com/edit/svg-star-generator?file=index.js
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.makeStar = void 0;
|
|
5
|
+
const instructions_1 = require("./instructions");
|
|
6
|
+
const join_points_1 = require("./join-points");
|
|
7
|
+
const star = ({ centerX, centerY, points, innerRadius, outerRadius, cornerRadius, edgeRoundness, }) => {
|
|
8
|
+
const degreeIncrement = (Math.PI * 2) / (points * 2);
|
|
9
|
+
const d = new Array(points * 2).fill(true).map((_p, i) => {
|
|
10
|
+
const radius = i % 2 === 0 ? outerRadius : innerRadius;
|
|
11
|
+
const angle = degreeIncrement * i - Math.PI / 2;
|
|
12
|
+
const point = {
|
|
13
|
+
x: centerX + radius * Math.cos(angle),
|
|
14
|
+
y: centerY + radius * Math.sin(angle),
|
|
15
|
+
};
|
|
16
|
+
return [point.x, point.y];
|
|
17
|
+
});
|
|
18
|
+
return (0, join_points_1.joinPoints)([...d, d[0]], {
|
|
19
|
+
edgeRoundness,
|
|
20
|
+
cornerRadius,
|
|
21
|
+
roundCornerStrategy: cornerRadius > 0 ? 'bezier' : 'arc',
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const makeStar = ({ points, innerRadius, outerRadius, cornerRadius = 0, edgeRoundness = null, }) => {
|
|
25
|
+
const width = outerRadius * 2;
|
|
26
|
+
const height = outerRadius * 2;
|
|
27
|
+
const centerX = width / 2;
|
|
28
|
+
const centerY = height / 2;
|
|
29
|
+
const starPathInstructions = star({
|
|
30
|
+
centerX,
|
|
31
|
+
centerY,
|
|
32
|
+
points,
|
|
33
|
+
innerRadius,
|
|
34
|
+
outerRadius,
|
|
35
|
+
cornerRadius,
|
|
36
|
+
edgeRoundness,
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
path: (0, instructions_1.serializeInstructions)(starPathInstructions),
|
|
40
|
+
width,
|
|
41
|
+
height,
|
|
42
|
+
transformOrigin: `${centerX} ${centerY}`,
|
|
43
|
+
instructions: starPathInstructions,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.makeStar = makeStar;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare type StarProps = {
|
|
2
|
+
centerX: number;
|
|
3
|
+
centerY: number;
|
|
4
|
+
points: number;
|
|
5
|
+
innerRadius: number;
|
|
6
|
+
outerRadius: number;
|
|
7
|
+
edgeRoundness: number | null;
|
|
8
|
+
cornerRadius: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const star: ({ centerX, centerY, points, innerRadius, outerRadius, cornerRadius, edgeRoundness, }: StarProps) => string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.star = void 0;
|
|
4
|
+
const instructions_1 = require("./instructions");
|
|
5
|
+
const join_points_1 = require("./join-points");
|
|
6
|
+
const polarToCartesian = ({ centerX, centerY, radius, angleInDegrees, }) => {
|
|
7
|
+
const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
|
|
8
|
+
return {
|
|
9
|
+
x: centerX + radius * Math.cos(angleInRadians),
|
|
10
|
+
y: centerY + radius * Math.sin(angleInRadians),
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const star = ({ centerX, centerY, points, innerRadius, outerRadius, cornerRadius, edgeRoundness, }) => {
|
|
14
|
+
const degreeIncrement = 360 / (points * 2);
|
|
15
|
+
const d = new Array(points * 2)
|
|
16
|
+
.fill('true')
|
|
17
|
+
.map((_p, i) => {
|
|
18
|
+
const radius = i % 2 === 0 ? outerRadius : innerRadius;
|
|
19
|
+
const degrees = degreeIncrement * i;
|
|
20
|
+
const point = polarToCartesian({
|
|
21
|
+
centerX,
|
|
22
|
+
centerY,
|
|
23
|
+
radius,
|
|
24
|
+
angleInDegrees: degrees,
|
|
25
|
+
});
|
|
26
|
+
return [point.x, point.y];
|
|
27
|
+
});
|
|
28
|
+
return (0, instructions_1.serializeInstructions)((0, join_points_1.joinPoints)([...d, d[0]], {
|
|
29
|
+
edgeRoundness,
|
|
30
|
+
cornerRadius,
|
|
31
|
+
roundCornerStrategy: 'arc',
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
exports.star = star;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type EllipseProps = React.SVGProps<SVGPathElement> & {
|
|
3
|
+
rx: number;
|
|
4
|
+
ry: number;
|
|
5
|
+
fill?: string;
|
|
6
|
+
stroke?: string;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare const Ellipse: React.FC<EllipseProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ellipse = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_ellipse_1 = require("./make-ellipse");
|
|
6
|
+
const Ellipse = ({ fill, stroke, strokeWidth, rx, ry, style, }) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: rx * 2, height: ry * 2, viewBox: `0 0 ${rx * 2} ${ry * 2}`, xmlns: "http://www.w3.org/2000/svg", style: style, "data-shape-type": "ellipse", children: (0, jsx_runtime_1.jsx)("path", { d: (0, make_ellipse_1.makeEllipse)({
|
|
8
|
+
rx,
|
|
9
|
+
ry,
|
|
10
|
+
}), fill: fill, stroke: stroke, strokeWidth: strokeWidth }) }));
|
|
11
|
+
};
|
|
12
|
+
exports.Ellipse = Ellipse;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type CircleProps = React.SVGProps<SVGPathElement> & {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
fill?: string;
|
|
6
|
+
stroke?: string;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare const Circle: React.FC<CircleProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Circle = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_circle_1 = require("./make-circle");
|
|
6
|
+
const Circle = ({ width, height, fill, stroke, strokeWidth, style, }) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, xmlns: "http://www.w3.org/2000/svg", style: style, "data-shape-type": "circle", children: (0, jsx_runtime_1.jsx)("path", { d: (0, make_circle_1.makeCircle)({
|
|
8
|
+
cx: 50,
|
|
9
|
+
cy: 50,
|
|
10
|
+
radius: 50,
|
|
11
|
+
}), fill: fill, stroke: stroke, strokeWidth: strokeWidth }) }));
|
|
12
|
+
};
|
|
13
|
+
exports.Circle = Circle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Circle = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_circle_1 = require("../utils/make-circle");
|
|
6
|
+
const render_svg_1 = require("./render-svg");
|
|
7
|
+
const Circle = ({ radius, ...props }) => {
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(render_svg_1.RenderSvg, { ...(0, make_circle_1.makeCircle)({ radius }), ...props });
|
|
9
|
+
};
|
|
10
|
+
exports.Circle = Circle;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MakeEllipseOptions } from '../utils/make-ellipse';
|
|
3
|
+
import type { AllShapesProps } from './render-svg';
|
|
4
|
+
export declare type EllipseProps = MakeEllipseOptions & AllShapesProps;
|
|
5
|
+
export declare const Ellipse: React.FC<EllipseProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ellipse = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_ellipse_1 = require("../utils/make-ellipse");
|
|
6
|
+
const render_svg_1 = require("./render-svg");
|
|
7
|
+
const Ellipse = ({ rx, ry, ...props }) => {
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(render_svg_1.RenderSvg, { ...(0, make_ellipse_1.makeEllipse)({ rx, ry }), ...props });
|
|
9
|
+
};
|
|
10
|
+
exports.Ellipse = Ellipse;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Rect = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_rect_1 = require("../utils/make-rect");
|
|
6
|
+
const render_svg_1 = require("./render-svg");
|
|
7
|
+
const Rect = ({ width, height, ...props }) => {
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(render_svg_1.RenderSvg, { ...(0, make_rect_1.makeRect)({ height, width }), ...props });
|
|
9
|
+
};
|
|
10
|
+
exports.Rect = Rect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type AllShapesProps = Omit<React.SVGProps<SVGPathElement>, 'width' | 'height' | 'd'> & {
|
|
3
|
+
pathStyle?: React.CSSProperties;
|
|
4
|
+
};
|
|
5
|
+
export declare const RenderSvg: ({ width, height, path, style, pathStyle, transformOrigin, ...props }: {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
path: string;
|
|
9
|
+
transformOrigin: string;
|
|
10
|
+
} & Omit<React.SVGProps<SVGPathElement>, "width" | "height" | "d"> & {
|
|
11
|
+
pathStyle?: React.CSSProperties | undefined;
|
|
12
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenderSvg = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const RenderSvg = ({ width, height, path, style, pathStyle, transformOrigin, ...props }) => {
|
|
7
|
+
const actualStyle = (0, react_1.useMemo)(() => {
|
|
8
|
+
return {
|
|
9
|
+
overflow: 'visible',
|
|
10
|
+
...(style !== null && style !== void 0 ? style : {}),
|
|
11
|
+
};
|
|
12
|
+
}, [style]);
|
|
13
|
+
const actualPathStyle = (0, react_1.useMemo)(() => {
|
|
14
|
+
return {
|
|
15
|
+
transformBox: 'fill-box',
|
|
16
|
+
...(pathStyle !== null && pathStyle !== void 0 ? pathStyle : {}),
|
|
17
|
+
};
|
|
18
|
+
}, [pathStyle]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, xmlns: "http://www.w3.org/2000/svg", style: actualStyle, children: (0, jsx_runtime_1.jsx)("path", { "transform-origin": transformOrigin, d: path, style: actualPathStyle, ...props }) }));
|
|
20
|
+
};
|
|
21
|
+
exports.RenderSvg = RenderSvg;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MakeTriangleProps } from '../utils/make-triangle';
|
|
3
|
+
import type { AllShapesProps } from './render-svg';
|
|
4
|
+
export declare type TriangleProps = MakeTriangleProps & AllShapesProps;
|
|
5
|
+
export declare const Triangle: React.FC<TriangleProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Triangle = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_triangle_1 = require("../utils/make-triangle");
|
|
6
|
+
const render_svg_1 = require("./render-svg");
|
|
7
|
+
const Triangle = ({ length, direction, ...props }) => {
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(render_svg_1.RenderSvg, { ...(0, make_triangle_1.makeTriangle)({ length, direction }), ...props });
|
|
9
|
+
};
|
|
10
|
+
exports.Triangle = Triangle;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Circle, CircleProps } from './components/circle';
|
|
2
|
+
export { Ellipse, EllipseProps } from './components/ellipse';
|
|
3
|
+
export { Rect, RectProps } from './components/rect';
|
|
4
|
+
export { Triangle, TriangleProps } from './components/triangle';
|
|
5
|
+
export { makeCircle, MakeCircleProps } from './utils/make-circle';
|
|
6
|
+
export { makeEllipse, MakeEllipseOptions } from './utils/make-ellipse';
|
|
7
|
+
export { makeRect, MakeRectOptions } from './utils/make-rect';
|
|
8
|
+
export { makeTriangle, MakeTriangleProps } from './utils/make-triangle';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTriangle = exports.makeRect = exports.makeEllipse = exports.makeCircle = exports.Triangle = exports.Rect = exports.Ellipse = exports.Circle = void 0;
|
|
4
|
+
var circle_1 = require("./components/circle");
|
|
5
|
+
Object.defineProperty(exports, "Circle", { enumerable: true, get: function () { return circle_1.Circle; } });
|
|
6
|
+
var ellipse_1 = require("./components/ellipse");
|
|
7
|
+
Object.defineProperty(exports, "Ellipse", { enumerable: true, get: function () { return ellipse_1.Ellipse; } });
|
|
8
|
+
var rect_1 = require("./components/rect");
|
|
9
|
+
Object.defineProperty(exports, "Rect", { enumerable: true, get: function () { return rect_1.Rect; } });
|
|
10
|
+
var triangle_1 = require("./components/triangle");
|
|
11
|
+
Object.defineProperty(exports, "Triangle", { enumerable: true, get: function () { return triangle_1.Triangle; } });
|
|
12
|
+
var make_circle_1 = require("./utils/make-circle");
|
|
13
|
+
Object.defineProperty(exports, "makeCircle", { enumerable: true, get: function () { return make_circle_1.makeCircle; } });
|
|
14
|
+
var make_ellipse_1 = require("./utils/make-ellipse");
|
|
15
|
+
Object.defineProperty(exports, "makeEllipse", { enumerable: true, get: function () { return make_ellipse_1.makeEllipse; } });
|
|
16
|
+
var make_rect_1 = require("./utils/make-rect");
|
|
17
|
+
Object.defineProperty(exports, "makeRect", { enumerable: true, get: function () { return make_rect_1.makeRect; } });
|
|
18
|
+
var make_triangle_1 = require("./utils/make-triangle");
|
|
19
|
+
Object.defineProperty(exports, "makeTriangle", { enumerable: true, get: function () { return make_triangle_1.makeTriangle; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCircle = void 0;
|
|
4
|
+
const makeCircle = ({ radius }) => {
|
|
5
|
+
const cx = radius;
|
|
6
|
+
const cy = radius;
|
|
7
|
+
return `M ${cx} ${cy} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${radius * 2} 0 ${radius} ${radius} 0 1 0 ${-radius * 2} 0`;
|
|
8
|
+
};
|
|
9
|
+
exports.makeCircle = makeCircle;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeRect = void 0;
|
|
4
|
-
const makeRect = ({
|
|
4
|
+
const makeRect = ({ width, height }) => {
|
|
5
|
+
const x = 0;
|
|
6
|
+
const y = 0;
|
|
5
7
|
return `M ${x} ${y} l ${width} 0 l 0 ${height} l ${-width} 0 Z`;
|
|
6
8
|
};
|
|
7
9
|
exports.makeRect = makeRect;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copied from https://stackblitz.com/edit/react-triangle-svg?file=index.js
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.makeTriangle = void 0;
|
|
5
|
+
const makeTriangle = ({ width, height, direction = 'right', }) => {
|
|
6
|
+
const points = {
|
|
7
|
+
top: [`${width / 2} 0`, 'L', `0 ${height}`, 'L', `${width} ${height}`],
|
|
8
|
+
right: [`0 0`, 'L', `0 ${height}`, 'L', `${width} ${height / 2}`],
|
|
9
|
+
bottom: [`0 0`, 'L', `${width} 0`, 'L', `${width / 2} ${height}`],
|
|
10
|
+
left: [`${width} 0`, 'L', `${width} ${height}`, 'L', `0 ${height / 2}`],
|
|
11
|
+
};
|
|
12
|
+
return `M ${points[direction].join(' ')} z`;
|
|
13
|
+
};
|
|
14
|
+
exports.makeTriangle = makeTriangle;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Rect = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, xmlns: "http://www.w3.org/2000/svg", style: style, "data-shape-type": "
|
|
5
|
+
const make_rect_1 = require("./make-rect");
|
|
6
|
+
const Rect = ({ width, height, fill, style }) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, xmlns: "http://www.w3.org/2000/svg", style: style, "data-shape-type": "rect", children: (0, jsx_runtime_1.jsx)("path", { d: (0, make_rect_1.makeRect)({
|
|
8
8
|
width,
|
|
9
9
|
height,
|
|
10
10
|
}), fill: fill }) }));
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
12
|
+
exports.Rect = Rect;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Triangle = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const make_triangle_1 = require("./make-triangle");
|
|
6
|
+
const Triangle = ({ width, height, fill, direction, style, }) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, xmlns: "http://www.w3.org/2000/svg", style: style, "data-shape-type": "triangle", children: (0, jsx_runtime_1.jsx)("path", { d: (0, make_triangle_1.makeTriangle)({
|
|
8
|
+
width,
|
|
9
|
+
height,
|
|
10
|
+
direction,
|
|
11
|
+
}), fill: fill }) }));
|
|
12
|
+
};
|
|
13
|
+
exports.Triangle = Triangle;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCircle = void 0;
|
|
4
|
+
const makeCircle = ({ radius }) => {
|
|
5
|
+
return {
|
|
6
|
+
height: radius * 2,
|
|
7
|
+
width: radius * 2,
|
|
8
|
+
path: `M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${radius * 2} 0 ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
|
|
9
|
+
transformOrigin: `${radius} ${radius}`,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.makeCircle = makeCircle;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeEllipse = void 0;
|
|
4
|
+
const makeEllipse = ({ rx, ry }) => {
|
|
5
|
+
return {
|
|
6
|
+
width: rx * 2,
|
|
7
|
+
height: ry * 2,
|
|
8
|
+
path: `M ${rx} ${0} a ${rx} ${ry} 0 1 0 1 0`,
|
|
9
|
+
transformOrigin: `${rx} ${ry}`,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.makeEllipse = makeEllipse;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRect = void 0;
|
|
4
|
+
const makeRect = ({ width, height }) => {
|
|
5
|
+
return {
|
|
6
|
+
width,
|
|
7
|
+
height,
|
|
8
|
+
path: `M 0 0 l ${width} 0 l 0 ${height} l ${-width} 0 Z`,
|
|
9
|
+
transformOrigin: `${width / 2} ${height / 2}`,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.makeRect = makeRect;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copied from https://stackblitz.com/edit/react-triangle-svg?file=index.js
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.makeTriangle = void 0;
|
|
5
|
+
const makeTriangle = ({ length, direction = 'right', }) => {
|
|
6
|
+
const longerDimension = length;
|
|
7
|
+
const shorterSize = Math.sqrt(length ** 2 * 0.75); // Calculated on paper;
|
|
8
|
+
const points = {
|
|
9
|
+
top: [
|
|
10
|
+
`${longerDimension / 2} 0`,
|
|
11
|
+
'L',
|
|
12
|
+
`0 ${shorterSize}`,
|
|
13
|
+
'L',
|
|
14
|
+
`${longerDimension} ${shorterSize}`,
|
|
15
|
+
],
|
|
16
|
+
right: [
|
|
17
|
+
`0 0`,
|
|
18
|
+
'L',
|
|
19
|
+
`0 ${longerDimension}`,
|
|
20
|
+
'L',
|
|
21
|
+
`${shorterSize} ${longerDimension / 2}`,
|
|
22
|
+
],
|
|
23
|
+
bottom: [
|
|
24
|
+
`0 0`,
|
|
25
|
+
'L',
|
|
26
|
+
`${longerDimension} 0`,
|
|
27
|
+
'L',
|
|
28
|
+
`${longerDimension / 2} ${shorterSize}`,
|
|
29
|
+
],
|
|
30
|
+
left: [
|
|
31
|
+
`${shorterSize} 0`,
|
|
32
|
+
'L',
|
|
33
|
+
`${shorterSize} ${longerDimension}`,
|
|
34
|
+
'L',
|
|
35
|
+
`0 ${longerDimension / 2}`,
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
const transformOriginX = {
|
|
39
|
+
left: (shorterSize / 3) * 2,
|
|
40
|
+
right: shorterSize / 3,
|
|
41
|
+
top: longerDimension / 2,
|
|
42
|
+
bottom: longerDimension / 2,
|
|
43
|
+
}[direction];
|
|
44
|
+
const transformOriginY = {
|
|
45
|
+
top: (shorterSize / 3) * 2,
|
|
46
|
+
bottom: shorterSize / 3,
|
|
47
|
+
left: longerDimension / 2,
|
|
48
|
+
right: longerDimension / 2,
|
|
49
|
+
}[direction];
|
|
50
|
+
return {
|
|
51
|
+
path: `M ${points[direction].join(' ')} z`,
|
|
52
|
+
width: direction === 'top' || direction === 'bottom' ? length : shorterSize,
|
|
53
|
+
height: direction === 'top' || direction === 'bottom' ? shorterSize : length,
|
|
54
|
+
transformOrigin: `${transformOriginX} ${transformOriginY}`,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.makeTriangle = makeTriangle;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/shapes",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.37",
|
|
4
4
|
"description": "Utility functions and components for SVG shapes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"react": ">=16.8.0",
|
|
45
45
|
"react-dom": ">=16.8.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ead6bdacc14a9953cae738159c49bf3daf09e9b0"
|
|
48
48
|
}
|