@remotion/shapes 3.3.78 → 3.3.79
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.
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { Instruction } from '@remotion/paths';
|
|
2
|
-
export declare const joinPoints: (points: [
|
|
3
|
-
number,
|
|
4
|
-
number
|
|
5
|
-
][], { edgeRoundness, cornerRadius, roundCornerStrategy, }: {
|
|
2
|
+
export declare const joinPoints: (points: [number, number][], { edgeRoundness, cornerRadius, roundCornerStrategy, }: {
|
|
6
3
|
edgeRoundness: number | null;
|
|
7
4
|
cornerRadius: number;
|
|
8
5
|
roundCornerStrategy: 'arc' | 'bezier';
|
|
@@ -25,6 +25,8 @@ const joinPoints = (points, { edgeRoundness, cornerRadius, roundCornerStrategy,
|
|
|
25
25
|
(x + prevPoint[0]) / 2,
|
|
26
26
|
(y + prevPoint[1]) / 2,
|
|
27
27
|
];
|
|
28
|
+
const prevVector = [x - prevPoint[0], y - prevPoint[1]];
|
|
29
|
+
const nextVector = [nextPoint[0] - x, nextPoint[1] - y];
|
|
28
30
|
if (i === 0) {
|
|
29
31
|
if (edgeRoundness !== null) {
|
|
30
32
|
return [
|
|
@@ -35,6 +37,16 @@ const joinPoints = (points, { edgeRoundness, cornerRadius, roundCornerStrategy,
|
|
|
35
37
|
},
|
|
36
38
|
];
|
|
37
39
|
}
|
|
40
|
+
if (cornerRadius !== 0) {
|
|
41
|
+
const computeRadius = shortenVector(nextVector, cornerRadius);
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
type: 'M',
|
|
45
|
+
x: computeRadius[0] + x,
|
|
46
|
+
y: computeRadius[1] + y,
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
}
|
|
38
50
|
return [
|
|
39
51
|
{
|
|
40
52
|
type: 'M',
|
|
@@ -43,8 +55,6 @@ const joinPoints = (points, { edgeRoundness, cornerRadius, roundCornerStrategy,
|
|
|
43
55
|
},
|
|
44
56
|
];
|
|
45
57
|
}
|
|
46
|
-
const prevVector = [x - prevPoint[0], y - prevPoint[1]];
|
|
47
|
-
const nextVector = [nextPoint[0] - x, nextPoint[1] - y];
|
|
48
58
|
if (cornerRadius && edgeRoundness !== null) {
|
|
49
59
|
throw new Error(`"cornerRadius" and "edgeRoundness" cannot be specified at the same time.`);
|
|
50
60
|
}
|
|
@@ -59,7 +69,7 @@ const joinPoints = (points, { edgeRoundness, cornerRadius, roundCornerStrategy,
|
|
|
59
69
|
];
|
|
60
70
|
}
|
|
61
71
|
const prevVectorMinusRadius = shortenVector(prevVector, cornerRadius);
|
|
62
|
-
const
|
|
72
|
+
const prevVectorLength = scaleVectorToLength(prevVector, cornerRadius);
|
|
63
73
|
const nextVectorMinusRadius = scaleVectorToLength(nextVector, cornerRadius);
|
|
64
74
|
const firstDraw = [
|
|
65
75
|
prevPoint[0] + prevVectorMinusRadius[0],
|
|
@@ -77,15 +87,15 @@ const joinPoints = (points, { edgeRoundness, cornerRadius, roundCornerStrategy,
|
|
|
77
87
|
rx: cornerRadius,
|
|
78
88
|
ry: cornerRadius,
|
|
79
89
|
xAxisRotation: 0,
|
|
80
|
-
dx:
|
|
81
|
-
dy:
|
|
90
|
+
dx: prevVectorLength[0] + nextVectorMinusRadius[0],
|
|
91
|
+
dy: prevVectorLength[1] + nextVectorMinusRadius[1],
|
|
82
92
|
largeArcFlag: false,
|
|
83
93
|
sweepFlag: true,
|
|
84
94
|
}
|
|
85
95
|
: {
|
|
86
96
|
type: 'C',
|
|
87
|
-
x: firstDraw[0] +
|
|
88
|
-
y: firstDraw[1] +
|
|
97
|
+
x: firstDraw[0] + prevVectorLength[0] + nextVectorMinusRadius[0],
|
|
98
|
+
y: firstDraw[1] + prevVectorLength[1] + nextVectorMinusRadius[1],
|
|
89
99
|
cp1x: x,
|
|
90
100
|
cp1y: y,
|
|
91
101
|
cp2x: x,
|
package/dist/utils/make-rect.js
CHANGED
|
@@ -15,7 +15,7 @@ const makeRect = ({ width, height, edgeRoundness = null, cornerRadius = 0, }) =>
|
|
|
15
15
|
const transformOrigin = [width / 2, height / 2];
|
|
16
16
|
const instructions = [
|
|
17
17
|
...(0, join_points_1.joinPoints)([
|
|
18
|
-
[
|
|
18
|
+
[cornerRadius, 0],
|
|
19
19
|
[width, 0],
|
|
20
20
|
[width, height],
|
|
21
21
|
[0, height],
|
|
@@ -13,6 +13,9 @@ const join_points_1 = require("./join-points");
|
|
|
13
13
|
* @see [Documentation](https://www.remotion.dev/docs/shapes/make-triangle)
|
|
14
14
|
*/
|
|
15
15
|
const makeTriangle = ({ length, direction = 'right', edgeRoundness = null, cornerRadius = 0, }) => {
|
|
16
|
+
if (typeof length !== 'number') {
|
|
17
|
+
throw new Error(`"length" of a triangle must be a number, got ${JSON.stringify(length)}`);
|
|
18
|
+
}
|
|
16
19
|
const longerDimension = length;
|
|
17
20
|
const shorterSize = Math.sqrt(length ** 2 * 0.75); // Calculated on paper;
|
|
18
21
|
const points = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/shapes",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.79",
|
|
4
4
|
"description": "Utility functions and components for SVG shapes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-dom": ">=16.8.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@remotion/paths": "3.3.
|
|
42
|
+
"@remotion/paths": "3.3.79"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"lint": "eslint src --ext ts,tsx",
|