/**
* Launch-event headline / כותרת של אירוע השקה (student motion library, id "mac-keynote")
* Use: copy this file into your Remotion project and register it in your Root:
*
* Render transparent: npx remotion render src/index.ts LibMacKeynote out.webm --codec=vp9 --pixel-format=yuva420p --image-format=png --props=props.json
* Change the words / colours / side in props.json (same keys as macKeynoteDefaults). A vertical video: width 1080, height 1920.
*/
// ---------------------------------------------------------------- helpers (shared by every library scene)
// Conventions: 1920x1080, 30 fps, transparent background. Sizes follow the frame's short side, so 1080x1920 works too.
// Common props: duration (s), side 'right' | 'left' | 'center', x / y (centre in % of the frame, override side),
// scale, font (a CSS font-family; default Heebo). Time is in seconds; the first and last frames are empty.
import React from 'react';
import {AbsoluteFill, Easing, useCurrentFrame, useVideoConfig} from 'remotion';
import {loadFont as loadHeebo} from '@remotion/google-fonts/Heebo';
const heebo = loadHeebo('normal', {weights: ['400', '500', '700', '800', '900'], subsets: ['hebrew', 'latin']});
/** Hebrew + Latin font (Google "Heebo"). props.font overrides it per scene. */
export const HEEBO = `${heebo.fontFamily}, "Helvetica Neue", Arial, sans-serif`;
export const MONO = 'ui-monospace, "SF Mono", Menlo, Consolas, monospace';
export type Side = 'right' | 'left' | 'center';
export type Base = {duration?: number; side?: Side; x?: number; y?: number; scale?: number; font?: string};
export const clamp01 = (x: number) => Math.min(1, Math.max(0, x));
/** 0..1 progress of t between a and b (seconds) */
export const p01 = (t: number, a: number, b: number) => clamp01((t - a) / (b - a));
export const lerp = (a: number, b: number, k: number) => a + (b - a) * k;
export const outE = Easing.bezier(0.16, 1, 0.3, 1); // fast out, long settle
export const inOut = Easing.bezier(0.65, 0, 0.35, 1);
export const inE = Easing.bezier(0.55, 0, 0.9, 0.45);
export const backOut = (x: number, s = 1.7) => (x <= 0 ? 0 : x >= 1 ? 1 : 1 + (s + 1) * Math.pow(x - 1, 3) + s * Math.pow(x - 1, 2));
/** Damped spring 0 -> 1 starting at t0 (closed form, so any frame computes on its own). */
export const spr = (t: number, t0: number, freq = 16, damp = 9) => {
const x = t - t0;
return x <= 0 ? 0 : 1 - Math.exp(-damp * x) * Math.cos(freq * x);
};
/** Deterministic pseudo random 0..1 */
export const rnd = (i: number, seed = 1) => {
const v = Math.sin(i * 127.1 + seed * 311.7) * 43758.5453;
return v - Math.floor(v);
};
export const isHe = (s: string) => /[-]/.test(s);
export const dirOf = (s: string): 'rtl' | 'ltr' => (isHe(s) ? 'rtl' : 'ltr');
/** "#a1b2c3" / "#abc" + alpha -> rgba() */
export const rgba = (hex: string, a = 1) => {
let h = hex.replace('#', '');
if (h.length === 3) h = h.split('').map((ch) => ch + ch).join('');
const n = parseInt(h.slice(0, 6), 16);
return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a})`;
};
export const useT = () => {
const f = useCurrentFrame();
const {fps} = useVideoConfig();
return f / fps;
};
/** 12345 -> "12,345" */
export const fmt = (n: number, sep = ',') => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, sep);
/** Arrive (scale up out of a blur) and leave (shrink into a blur) for a whole group. */
export const life = (t: number, total: number, inDur = 0.45, outDur = 0.35) => {
const a = p01(t, 0, inDur);
const z = inOut(p01(t, total - outDur, total));
return {
opacity: clamp01(a * 2.2) * (1 - z),
scale: lerp(0.82, 1, backOut(a, 1.4)) * (1 - 0.08 * z),
blur: (1 - outE(a)) * 12 + z * 10,
style: {} as React.CSSProperties,
};
};
export const lifeStyle = (t: number, total: number, inDur = 0.45, outDur = 0.35): React.CSSProperties => {
const l = life(t, total, inDur, outDur);
return {opacity: l.opacity, transform: `scale(${l.scale})`, filter: l.blur > 0.2 ? `blur(${l.blur}px)` : undefined};
};
/**
* Places a w x h box (design pixels of a 1080-high frame) on its side of the frame and scales it with the frame's
* short side and props.scale. Children are positioned inside the box.
*/
export const Stage: React.FC<{p: Base; w: number; h: number; children: React.ReactNode; style?: React.CSSProperties; defSide?: Side}> = ({p, w, h, children, style, defSide = 'center'}) => {
const {width: W, height: H} = useVideoConfig();
const u = (Math.min(W, H) / 1080) * (p.scale ?? 1);
const side = p.side ?? defSide;
const cx = ((p.x ?? (side === 'right' ? 73 : side === 'left' ? 27 : 50)) / 100) * W;
const cy = ((p.y ?? 50) / 100) * H;
return (
{children}
);
};
/** Soft two-layer drop shadow for cards on any footage */
export const SHADOW = '0 22px 48px rgba(12,12,20,0.22), 0 4px 12px rgba(12,12,20,0.14)';
/** The classic arrow cursor; (x, y) = its tip; press 0..1 = mouse down. */
export const Cursor: React.FC<{x: number; y: number; press?: number; size?: number; fill?: string; stroke?: string}> = ({x, y, press = 0, size = 1.6, fill = '#111', stroke = '#fff'}) => {
const s = size * (1 - 0.12 * press);
return (
);
};
/** A four-point sparkle centred on (0,0) in a -50..50 box. */
export const SPARK_PATH = 'M0 -50 C 6 -14 14 -6 50 0 C 14 6 6 14 0 50 C -6 14 -14 6 -50 0 C -14 -6 -6 -14 0 -50 Z';
export const Spark: React.FC<{x: number; y: number; size: number; color: string; rotate?: number; opacity?: number; glow?: boolean}> = ({x, y, size, color, rotate = 0, opacity = 1, glow = false}) => (
);
// ---------------------------------------------------------------- Mac-style parts (all drawn in code)
import {loadFont as loadInter} from '@remotion/google-fonts/Inter';
const inter = loadInter('normal', {weights: ['400', '500', '600', '700', '800'], subsets: ['latin']});
/** Latin text: Inter (closest free cousin of the system font), Hebrew falls through to Heebo. */
export const INTER = `${inter.fontFamily}, "Heebo", "Helvetica Neue", Arial, sans-serif`;
export const macFont = (s: string, own?: string) => own ?? (isHe(s) ? '"Heebo", "Helvetica Neue", Arial, sans-serif' : INTER);
/** Tight tracking for big Latin type, none for Hebrew. */
export const macTrack = (s: string, size: number) => (isHe(s) ? 0 : size >= 90 ? '-0.035em' : size >= 48 ? '-0.022em' : size >= 28 ? '-0.01em' : 0);
/** The system blue (selection, links). */
export const MAC_BLUE = '#0A84FF';
/** A smooth "spring" like the system animations: response (s) and damping ratio, closed form, starts at t0. */
export const macSpring = (t: number, t0: number, response = 0.5, damping = 0.82) => {
const x = t - t0;
if (x <= 0) return 0;
const w0 = (2 * Math.PI) / response;
if (damping >= 1) return 1 - (1 + w0 * x) * Math.exp(-w0 * x);
const wd = w0 * Math.sqrt(1 - damping * damping);
return 1 - Math.exp(-damping * w0 * x) * (Math.cos(wd * x) + ((damping * w0) / wd) * Math.sin(wd * x));
};
// ------------------------------------------------------------------------------------------------ glass
/**
* A liquid-glass plate. On a transparent render there is nothing behind it to blur, so the look comes from a soft
* milky fill, a bright rim and a sheen; inside Remotion, over your footage, `backdrop-filter` also blurs what's behind.
* dark = smoked glass (for light footage).
*/
export const Glass: React.FC<{w: number; h: number; r?: number; dark?: boolean; frost?: boolean; opacity?: number; style?: React.CSSProperties; children?: React.ReactNode; shadow?: number}> = ({w, h, r = 32, dark = false, frost = false, opacity = 1, style, children, shadow = 1}) => (
{/* the sheen: light caught on the upper left of the glass */}
{/* the rim: bright on top, a thin line all round */}
{children}
);
// ------------------------------------------------------------------------------------------------ icons
/** A generic blue folder (our own drawing): back with its tab, a lighter front. */
export const FolderIcon: React.FC<{size: number; color?: string; dim?: number}> = ({size, color = '#3BA6F5', dim = 0}) => {
const id = `fd${color.replace('#', '')}`;
return (
);
};
/** A document with a folded corner and a coloured label for its type ("MP4", "PDF"...). */
export const FileIcon: React.FC<{size: number; ext?: string; color?: string; dim?: number}> = ({size, ext = 'MP4', color = '#7C5CFF', dim = 0}) => (
);
/** A glassy trash can with ribs (our own drawing). fill 0..1 = papers inside; lid lifts with `open`. */
export const TrashIcon: React.FC<{size: number; fill?: number; open?: number}> = ({size, fill = 0, open = 0}) => (
);
/** The kinds of generic app tiles (no real app's logo). */
export type TileKind = 'files' | 'photos' | 'video' | 'music' | 'chat' | 'mail' | 'notes' | 'calendar' | 'camera' | 'ai' | 'settings' | 'design' | 'browser' | 'maps';
const TILE_BG: Record = {
files: 'linear-gradient(180deg, #5ac8fa, #1e7cf2)',
photos: 'linear-gradient(160deg, #ffd25e, #ff7a59 55%, #ff4f8b)',
video: 'linear-gradient(160deg, #8f6bff, #4b2fd6)',
music: 'linear-gradient(160deg, #ff6a88, #ff2d55)',
chat: 'linear-gradient(180deg, #67e37b, #22b845)',
mail: 'linear-gradient(180deg, #4fc3ff, #1475f5)',
notes: 'linear-gradient(180deg, #fff6c9 0%, #fff6c9 26%, #ffffff 26%)',
calendar: '#ffffff',
camera: 'linear-gradient(180deg, #e9ebef, #b9bec8)',
ai: 'linear-gradient(150deg, #1b1b22, #2c2a3a)',
settings: 'linear-gradient(180deg, #d7dae0, #9aa0ab)',
design: 'linear-gradient(160deg, #ffb340, #ff6a2c)',
browser: 'linear-gradient(180deg, #ffffff, #e6ecf5)',
maps: 'linear-gradient(150deg, #8ee08a 0%, #8ee08a 45%, #f4e7c5 45%)',
};
const glyph = (k: TileKind, day: string): React.ReactNode => {
const w = {stroke: '#fff', strokeWidth: 5, fill: 'none', strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const};
switch (k) {
case 'files': return ;
case 'photos': return ;
case 'video': return ;
case 'music': return ;
case 'chat': return ;
case 'mail': return ;
case 'notes': return {[44, 56, 68].map((y) => )};
case 'calendar': return {'MON'}{day};
case 'camera': return ;
case 'ai': return ;
case 'settings': return ;
case 'design': return ;
case 'browser': return ;
case 'maps': return ;
}
};
/** A rounded app tile in that squircle shape, with a simple glyph. */
export const Tile: React.FC<{kind: TileKind; size: number; day?: string; style?: React.CSSProperties}> = ({kind, size, day = '10', style}) => (
);
/** A file / folder name under an icon; selected = white on blue, like a desktop selection. */
export const IconLabel: React.FC<{text: string; selected?: boolean; size?: number; font?: string; maxW?: number}> = ({text, selected = false, size = 22, font, maxW = 220}) => (
{text}
);
/**
* A dock: glass shelf, tiles left to right, a thin divider, the trash can last. `cx`/`cy` = centre of the shelf.
* grow = how much the trash swells (1 = none), magnify = index of a tile under the cursor (-1 = none).
*/
export const dockWidth = (n: number, size: number) => (n + 1) * size + (n + 1) * size * 0.2 + size * 0.5;
export const Dock: React.FC<{apps: TileKind[]; cx: number; cy: number; size?: number; grow?: number; trashFill?: number; dark?: boolean; lift?: number[]}> = ({apps, cx, cy, size = 84, grow = 1, trashFill = 0, dark = false, lift = []}) => {
const gap = size * 0.2;
const w = dockWidth(apps.length, size);
const h = size + gap * 1.6;
const x0 = cx - w / 2;
return (
{apps.map((k, i) => (
))}
);
};
/** Centre x of the trash can in a dock of n apps centred on cx. */
export const dockTrashX = (n: number, cx: number, size = 84) => {
const gap = size * 0.2;
const x0 = cx - dockWidth(n, size) / 2;
return x0 + gap + n * (size + gap) + gap * 0.5 + size / 2;
};
/** Centre x of app i. */
export const dockAppX = (i: number, n: number, cx: number, size = 84) => cx - dockWidth(n, size) / 2 + size * 0.2 + i * size * 1.2 + size / 2;
// ------------------------------------------------------------------------------------------------ colour
/** Lighten (k > 0) or darken (k < 0) a hex colour. */
export function shade(hex: string, k: number) {
const m = rgba(hex, 1).match(/\d+/g)!.slice(0, 3).map(Number);
const f = (c: number) => Math.round(k >= 0 ? c + (255 - c) * k : c * (1 + k));
return `rgb(${m.map(f).join(',')})`;
}
// ------------------------------------------------------------------------------------------------ frosted windows (the "Mac glass" edit style)
/** Pop in (spring up out of a blur) and out (shrink into a blur): the way every frosted window arrives and leaves. */
export const pop = (t: number, total: number, t0 = 0.05, outDur = 0.38): React.CSSProperties & {k: number} => {
const k = macSpring(t, t0, 0.5, 0.74);
const o = Math.min(1, Math.max(0, (t - (total - outDur)) / outDur));
const oe = o * o;
const blur = Math.max(0, (1 - k) * 14) + oe * 12;
return {k, opacity: Math.min(1, Math.max(0, k * 1.8)) * (1 - oe), transform: `scale(${(0.82 + 0.18 * k) * (1 - 0.1 * oe)}) translateY(${(1 - k) * 24}px)`,
filter: blur > 0.3 ? `blur(${blur}px)` : undefined};
};
/** The three window dots. */
export const Lights: React.FC<{size?: number}> = ({size = 15}) => (
{['#FF5F57', '#FEBC2E', '#28C840'].map((c) => )}
);
/** A frosted window: dots on the left, a small grey title in the middle, then the content. dark = terminal glass. */
export const Win: React.FC<{w: number; h: number; title: string; dark?: boolean; font?: string; children?: React.ReactNode; style?: React.CSSProperties}> = ({w, h, title, dark = false, font, children, style}) => (
{title}
{children}
);
/** A frosted pill with text (an emoji / icon before it is fine). */
export const Pill: React.FC<{text: React.ReactNode; size?: number; w?: number; font?: string; rtl?: boolean; style?: React.CSSProperties}> = ({text, size = 34, w, font, rtl = true, style}) => (
{text}
);
/** Dark ink for text on frosted glass. */
export const INK = '#1f1f24';
export const INK2 = 'rgba(31,31,36,0.45)';
// ---------------------------------------------------------------- the scene
/**
* Mac style: the launch-event title. A small line fades in, then a big bold headline rises word by word out of a soft
* blur; its last words are filled with a slowly moving colour gradient and a light sweep passes over them. A thin line
* under it settles last. 4.8 s. Design: the big type of a product launch, drawn in code.
*/
export type MacKeynoteProps = Base & {
eyebrow: string;
lead: string; // plain words of the headline
accent: string; // the gradient words
sub: string;
colors: string[]; // the gradient
ink: string; // colour of the plain words
};
export const macKeynoteDefaults: MacKeynoteProps = {
duration: 4.8,
side: 'center',
y: 50,
eyebrow: 'הכירו את',
lead: 'העורך',
accent: 'הכי חכם שלכם',
sub: 'עורך את הסרטונים שלכם, בזמן שאתם ישנים',
colors: ['#FF9F43', '#FF4F8B', '#9B5CFF', '#3D8BFF'],
ink: '#ffffff',
};
const W = 1500;
const H = 520;
export const MacKeynote: React.FC = (props) => {
const p = {...macKeynoteDefaults, ...props};
const t = useT();
const total = p.duration!;
const head = `${p.lead} ${p.accent}`;
const rtl = dirOf(head) === 'rtl';
const font = macFont(head, p.font);
const size = Math.min(150, (W * 1.7) / Math.max(8, head.length));
const words = [...p.lead.split(' ').filter(Boolean).map((w) => ({w, acc: false})), ...p.accent.split(' ').filter(Boolean).map((w) => ({w, acc: true}))];
const leave = p01(t, total - 0.45, total);
const leaveE = leave * leave;
const grad = `linear-gradient(${rtl ? 270 : 90}deg, ${[...p.colors, p.colors[0]].join(', ')})`;
const gx = (t * 18) % 200; // the gradient drifts
const sweep = p01(t, 1.6, 2.6); // a light sweep over the gradient words
const rise = (t0: number) => {
const k = macSpring(t, t0, 0.7, 0.92);
return {opacity: clamp01(k * 1.4) * (1 - leaveE), transform: `translateY(${(1 - k) * size * 0.45 - leaveE * 20}px)`, filter: k < 0.97 || leave > 0 ? `blur(${(1 - k) * 18 + leaveE * 12}px)` : undefined} as React.CSSProperties;
};
return (