Skip to content

🎥 Make videos programmatically with React

shapes: Improve Heart shape to create proper heart proportions

copilot-swe-agent[bot]e70ff5e7d303
diff --git a/packages/shapes/src/utils/make-heart.ts b/packages/shapes/src/utils/make-heart.ts
index aad7255b37..01bfd284ee 100644
--- a/packages/shapes/src/utils/make-heart.ts
+++ b/packages/shapes/src/utils/make-heart.ts
@@ -12,61 +12,72 @@ export type MakeHeartProps = {
* @see [Documentation](https://www.remotion.dev/docs/shapes/make-heart)
*/
export const makeHeart = ({size}: MakeHeartProps): ShapeInfo => {
- // Center the heart within the size x size bounding box
+ // Heart shape using a classic approach with proper proportions
const centerX = size / 2;
const centerY = size / 2;
- // Scale factor for the heart proportions (normalized to 100px base size)
+ // Heart scaling factor
const scale = size / 100;
+
+ // Heart key points
+ const bottomX = centerX;
+ const bottomY = centerY + 35 * scale; // Bottom point
+
+ // Lobe parameters for classic heart shape
+ const lobeOffsetX = 25 * scale; // How far lobes are from center
+ const lobeRadius = 18 * scale; // Size of each lobe
+ const lobeY = centerY - 15 * scale; // Vertical center of lobes
+
+ const leftLobeX = centerX - lobeOffsetX;
+ const rightLobeX = centerX + lobeOffsetX;
- // Create heart shape using bezier curves
- // Heart is made of two rounded lobes at the top and a point at the bottom
+ // Create heart with 4 bezier curves (M + 4 C + Z = 6 instructions)
const instructions: Instruction[] = [
- // Start at the bottom point of the heart
+ // Start at the bottom point
{
type: 'M',
- x: centerX,
- y: centerY + 35 * scale,
+ x: bottomX,
+ y: bottomY,
},
- // Left side curve - from bottom point to left lobe
+ // Left side - from bottom to left lobe
{
type: 'C',
- cp1x: centerX - 25 * scale,
- cp1y: centerY + 15 * scale,
- cp2x: centerX - 40 * scale,
- cp2y: centerY - 5 * scale,
- x: centerX - 25 * scale,
- y: centerY - 15 * scale,
+ cp1x: bottomX - 30 * scale,
+ cp1y: bottomY - 15 * scale,
+ cp2x: leftLobeX - lobeRadius,
+ cp2y: lobeY + lobeRadius * 0.5,
+ x: leftLobeX - lobeRadius,
+ y: lobeY,
},
- // Left lobe top curve
+ // Left lobe - semicircular top, ending at center dip
{
type: 'C',
- cp1x: centerX - 10 * scale,
- cp1y: centerY - 25 * scale,
- cp2x: centerX - 5 * scale,
- cp2y: centerY - 25 * scale,
+ cp1x: leftLobeX - lobeRadius,
+ cp1y: lobeY - lobeRadius,
+ cp2x: leftLobeX + lobeRadius * 0.8,
+ cp2y: lobeY - lobeRadius,
x: centerX,
- y: centerY - 15 * scale,
+ y: lobeY + lobeRadius * 0.2,
},
- // Right lobe top curve
+ // Right lobe - from center dip to right lobe edge
{
type: 'C',
- cp1x: centerX + 5 * scale,
- cp1y: centerY - 25 * scale,
- cp2x: centerX + 10 * scale,
- cp2y: centerY - 25 * scale,
- x: centerX + 25 * scale,
- y: centerY - 15 * scale,
+ cp1x: rightLobeX - lobeRadius * 0.8,
+ cp1y: lobeY - lobeRadius,
+ cp2x: rightLobeX + lobeRadius,
+ cp2y: lobeY - lobeRadius,
+ x: rightLobeX + lobeRadius,
+ y: lobeY,
},
- // Right side curve - from right lobe back to bottom point
+ // Right side - from right lobe back to bottom
{
type: 'C',
- cp1x: centerX + 40 * scale,
- cp1y: centerY - 5 * scale,
- cp2x: centerX + 25 * scale,
- cp2y: centerY + 15 * scale,
- x: centerX,
- y: centerY + 35 * scale,
+ cp1x: rightLobeX + lobeRadius,
+ cp1y: lobeY + lobeRadius * 0.5,
+ cp2x: bottomX + 30 * scale,
+ cp2y: bottomY - 15 * scale,
+ x: bottomX,
+ y: bottomY,
},
{
type: 'Z',