Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

Refactor mockup canvas drawing functions for improved consistency and responsiveness

CristianOlivera1b6561d03840a
diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsx
index 2d26ef7..eadabda 100644
--- a/app/components/ui/editor/VideoCanvas.tsx
+++ b/app/components/ui/editor/VideoCanvas.tsx
@@ -7,7 +7,7 @@ import type { ImageElement, SvgElement } from "@/types/canvas-elements.types";
import { getCameraLayout } from "@/types/camera.types";
import { ASPECT_RATIO_DIMENSIONS } from "@/types";
import { getWallpaperUrl } from "@/lib/wallpaper.utils";
-import { drawRoundedRect, drawRoundedRectBottomOnly, calculateScaledPadding, applyCanvasBackground, getAspectRatioStyle, getAspectRatioNumber, Corner, getCornerStyle, getNearestCorner, snapRotation, drawImageCover } from "@/lib/canvas.utils";
+import { drawRoundedRect, drawRoundedRectBottomOnly, calculateScaledPadding, applyCanvasBackground, getAspectRatioStyle, getAspectRatioNumber, Corner, getCornerStyle, getNearestCorner, snapRotation, drawImageCover, getMockupOuterRadius } from "@/lib/canvas.utils";
import { drawMockupToCanvas } from "@/lib/mockup-canvas.utils";
import { speedToTransitionMs, ZOOM_EASING, calculateZoomPhaseState, zoomLevelToFactor } from "@/types/zoom.types";
import type { ZoomFragment } from "@/types/zoom.types";
@@ -32,6 +32,7 @@ import { Viewer3DControlsBridge } from "@/components/ui/Viewer3DControlsBridge";
import { applyGradientMaskToRegion, GetMediaMaskStyles } from "@/lib/media-mask.utils";
import { MediaContent } from "@/components/ui/MediaContent";
import { RotationGuideLine } from "@/components/ui/RotationGuideLine";
+import { drawCameraOverlayToCtx } from "@/lib/camera-overlay.utils";
export type { VideoCanvasHandle, VideoCanvasProps };
@@ -1526,7 +1527,7 @@ function VideoCanvasInner({
await renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, true);
ctx.restore();
- await drawCameraOverlay(ctx, canvasWidth, canvasHeight);
+ await drawCameraOverlayToCtx(ctx, canvasWidth, canvasHeight, cameraVideoRef.current, videoRef.current, cameraConfig);
const { containerX, containerY, containerWidth, containerHeight } = computeContainer();
@@ -1648,7 +1649,7 @@ function VideoCanvasInner({
await renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, false);
ctx.restore();
- await drawCameraOverlay(ctx, canvasWidth, canvasHeight);
+ await drawCameraOverlayToCtx(ctx, canvasWidth, canvasHeight, cameraVideoRef.current, videoRef.current, cameraConfig);
};
const drawPhone3DCompositeWithZoom = (
@@ -1713,119 +1714,6 @@ function VideoCanvasInner({
}
};
- const drawCameraOverlay = async (
- ctx: CanvasRenderingContext2D,
- canvasWidth: number,
- canvasHeight: number
- ) => {
- const camVideo = cameraVideoRef.current;
- const mainVideo = videoRef.current;
-
- if (!camVideo || !cameraConfig || !cameraConfig.enabled) return;
- if (!camVideo.videoWidth || !camVideo.videoHeight) return;
-
- if (mainVideo && camVideo.paused) {
- const targetTime = Math.min(mainVideo.currentTime, Math.max(0, camVideo.duration - 0.1));
-
- if (Math.abs(camVideo.currentTime - targetTime) > 0.05) {
- try {
- camVideo.currentTime = targetTime;
-
- await new Promise<void>((resolve) => {
-
- const timeoutId = setTimeout(() => {
- camVideo.removeEventListener("seeked", onSeeked);
- resolve();
- }, 2000);
-
- const onSeeked = () => {
- camVideo.removeEventListener("seeked", onSeeked);
-
- const checkReady = setInterval(() => {
- if (camVideo.readyState >= 2) {
- clearInterval(checkReady);
- clearTimeout(timeoutId);
- resolve();
- }
- }, 10);
- };
-
- camVideo.addEventListener("seeked", onSeeked);
- });
- } catch (e) {
- console.warn("Error en seek de la cámara:", e);
- }
- }
- }
-
- // ... From here, the rest of the code continues as-is:
- const { size, left: drawX, top: drawY } = getCameraLayout(
- cameraConfig,
- canvasWidth,
- canvasHeight
- );
- if (size <= 0) return;
-
- const shortSide = Math.min(canvasWidth, canvasHeight);
-
- const sizePercent = cameraConfig.size * 100;
- const sizeMultiplier = 0.5 + (sizePercent - 20) / 40;
-
- const srcShort = Math.min(camVideo.videoWidth, camVideo.videoHeight);
- const sx = (camVideo.videoWidth - srcShort) / 2;
- const sy = (camVideo.videoHeight - srcShort) / 2;
-
- ctx.save();
-
- ctx.shadowColor = "rgba(0, 0, 0, 0.55)";
- ctx.shadowBlur = shortSide * 0.02;
- ctx.shadowOffsetY = shortSide * 0.008;
-
- if (cameraConfig.shape === "circle") {
- const centerX = drawX + size / 2;
- const centerY = drawY + size / 2;
- const radius = size / 2;
-
- ctx.beginPath();
- ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
- ctx.fill();
-
- ctx.shadowColor = "transparent";
- ctx.shadowBlur = 0;
- ctx.shadowOffsetY = 0;
-
- ctx.beginPath();
- ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
- ctx.clip();
- } else {
- const radius =
- cameraConfig.shape === "squircle"
- ? Math.round(85 * sizeMultiplier)
- : Math.round(6 * sizeMultiplier);
-
- drawRoundedRect(ctx, drawX, drawY, size, size, radius);
- ctx.fill();
-
- ctx.shadowColor = "transparent";
- ctx.shadowBlur = 0;
- ctx.shadowOffsetY = 0;
-
- drawRoundedRect(ctx, drawX, drawY, size, size, radius);
- ctx.clip();
- }
-
- if (camVideo && camVideo.readyState >= 2) {
- if (cameraConfig.mirror) {
- ctx.translate(drawX + size, drawY);
- ctx.scale(-1, 1);
- ctx.drawImage(camVideo, sx, sy, srcShort, srcShort, 0, 0, size, size);
- } else {
- ctx.drawImage(camVideo, sx, sy, srcShort, srcShort, drawX, drawY, size, size);
- }
- }
- ctx.restore();
- };
-
useImperativeHandle(ref, () => ({
getExportCanvas: () => exportCanvasRef.current,
drawFrame,
@@ -2284,7 +2172,7 @@ function VideoCanvasInner({
{(isVideoSelected || isVideoHovered) && hasMedia && !isDraggingRotation && !imagePhoneActive && (
<div
className={`absolute -inset-px border pointer-events-none z-10 opacity-80 ${isVideoSelected ? 'border-blue-500' : 'border-white'}`}
- style={{ borderRadius: `${roundedCorners + 1}px` }}
+ style={{ borderRadius: `${getMockupOuterRadius(mockupId, roundedCorners) + 1}px` }}
/>
)}
diff --git a/app/components/ui/editor/mockups/GlassFullMockup.tsx b/app/components/ui/editor/mockups/GlassFullMockup.tsx
index 64bafcb..86be37d 100644
--- a/app/components/ui/editor/mockups/GlassFullMockup.tsx
+++ b/app/components/ui/editor/mockups/GlassFullMockup.tsx
@@ -1,5 +1,4 @@
"use client";
-
import { Icon } from "@iconify/react";
import type { MockupRenderProps } from "@/types/mockup.types";
import { hexToRgba } from "@/lib/utils";
@@ -20,18 +19,15 @@ export function GlassFullMockup({
const frameColor = isDark ? config.frameColor : "#ffffff";
const cornerRadius = roundedCorners ?? config.cornerRadius;
const headerOpacity = config.headerOpacity ?? 10;
-
const headerScale = (config.headerScale || 100) / 100;
-
+
const framePadding = 12 * headerScale;
const buttonWidth = 7 * headerScale;
-
const notchTop = 8 * headerScale;
const notchWidth = 104 * headerScale;
const notchHeight = 24 * headerScale;
const notchPaddingX = 8 * headerScale;
const dotSize = 8 * headerScale;
-
const statusBarHeight = 32 * headerScale;
const statusBarPaddingX = 28 * headerScale;
const timeFontSize = 10 * headerScale;
@@ -40,13 +36,11 @@ export function GlassFullMockup({
const wifiSize = 12 * headerScale;
const batteryWidth = 18 * headerScale;
const batteryHeight = 10 * headerScale;
-
const contentPaddingTop = 40 * headerScale;
-
const homeIndicatorWidth = 128 * headerScale;
const homeIndicatorHeight = 4 * headerScale;
const homeIndicatorBottom = 8 * headerScale;
-
+
const screenBg = isDark ? "#0a0a0a" : "#f9f9f9";
const frameBorderColor = isDark ? "rgba(255, 255, 255, 0.15)" : "rgba(255, 255, 255, 0.3)";
const screenBorderColor = isDark ? "rgba(255, 255, 255, 0.05)" : "rgba(0, 0, 0, 0.05)";
@@ -54,14 +48,18 @@ export function GlassFullMockup({
const statusBarText = isDark ? "rgba(255, 255, 255, 0.8)" : "rgba(0, 0, 0, 0.6)";
const statusBarTextDim = isDark ? "rgba(255, 255, 255, 0.4)" : "rgba(0, 0, 0, 0.2)";
const homeIndicatorBg = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.1)";
-
- const buttonBg = isDark ? "rgba(255, 255, 255, 0.25)" : "rgba(0, 0, 0, 0.15)";
- const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.4)" : "rgba(0, 0, 0, 0.25)";
- const buttonShadow = isDark ? "inset 0px 0px 4px rgba(255,255,255,0.2), 0 1px 3px rgba(0,0,0,0.5)" : "inset 0px 0px 4px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.2)";
+
+ // Aquí está el cambio solicitado: botones blancos (#ffffff) en el modo claro
+ const buttonBg = isDark ? "rgba(255, 255, 255, 0.25)" : "#ffffff";
+ const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.4)" : "#e5e5e5";
+
+ const buttonShadow = isDark
+ ? "inset 0px 0px 4px rgba(255,255,255,0.2), 0 1px 3px rgba(0,0,0,0.5)"
+ : "inset 0px 0px 4px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.2)";
return (
<div className={`relative flex flex-col w-full h-full ${className}`}>
- <div
+ <div
className="relative flex flex-col w-full h-full backdrop-blur-2xl"
style={{
padding: `${framePadding}px`,
@@ -71,7 +69,7 @@ export function GlassFullMockup({
border: `1px solid ${frameBorderColor}`,
}}
>
- <div
+ <div
className="absolute backdrop-blur-md rounded-l-sm z-[-1]"
style={{
left: `-${buttonWidth}px`,
@@ -85,7 +83,7 @@ export function GlassFullMockup({
boxShadow: buttonShadow
}}
/>
- <div
+ <div
className="absolute backdrop-blur-md rounded-l-sm z-[-1]"
style={{
left: `-${buttonWidth}px`,
@@ -99,7 +97,7 @@ export function GlassFullMockup({
boxShadow: buttonShadow
}}
/>
- <div
+ <div
className="absolute backdrop-blur-md rounded-r-sm z-[-1]"
style={{
right: `-${buttonWidth}px`,
@@ -114,7 +112,7 @@ export function GlassFullMockup({
}}
/>
- <div
+ <div
className="relative w-full h-full overflow-hidden flex flex-col shadow-inner"
style={{
backgroundColor: screenBg,
@@ -122,7 +120,7 @@ export function GlassFullMockup({
border: `1px solid ${screenBorderColor}`,
}}
>
- <div
+ <div
className="absolute left-1/2 -translate-x-1/2 rounded-full z-30 flex items-center justify-between shadow-sm"
style={{
top: `${notchTop}px`,
@@ -132,30 +130,29 @@ export function GlassFullMockup({
padding: `0 ${notchPaddingX}px`
}}
>
- <div
+ <div
className="bg-neutral-500 rounded-full border border-neutral-700"
style={{ width: `${dotSize}px`, height: `${dotSize}px` }}
/>
- <div
+ <div
className="bg-indigo-500 rounded-full opacity-80 blur-[1px]"
style={{ width: `${dotSize}px`, height: `${dotSize}px` }}
/>
</div>
- <div
+ <div
className="absolute top-0 w-full flex items-center justify-between z-20"
style={{
height: `${statusBarHeight}px`,
padding: `0 ${statusBarPaddingX}px`,
}}
>
- <span
+ <span
className="font-bold tracking-tight"
style={{ fontSize: `${timeFontSize}px`, color: statusBarText }}
>
9:41
</span>
-
<div className="flex items-center" style={{ gap: `${iconsGap}px` }}>
<div className="flex items-end" style={{ gap: '1px', height: `${batteryHeight * 0.8}px` }}>
<div className="rounded-[0.5px]" style={{ width: `${signalBarWidth}px`, height: '40%', backgroundColor: statusBarText }} />
@@ -164,8 +161,7 @@ export function GlassFullMockup({
<div className="rounded-[0.5px]" style={{ width: `${signalBarWidth}px`, height: '100%', backgroundColor: statusBarTextDim }} />
</div>
<Icon icon="mdi:wifi" style={{ width: `${wifiSize}px`, height: `${wifiSize}px`, color: statusBarText }} />
-
- <div
+ <div
className="relative rounded-[2px] flex items-center"
style={{
width: `${batteryWidth}px`,
@@ -175,20 +171,12 @@ export function GlassFullMockup({
}}
>
<div className="h-full rounded-[0.5px]" style={{ width: '70%', backgroundColor: statusBarText }} />
- <div
- className="absolute rounded-r-full"
- style={{
- right: '-2px',
- width: '1px',
- height: '40%',
- backgroundColor: statusBarTextDim
- }}
- />
+ <div className="absolute rounded-r-full" style={{ right: '-2px', width: '1px', height: '40%', backgroundColor: statusBarTextDim }} />
</div>
</div>
</div>
- <div
+ <div
className="relative w-full h-full"
style={{ paddingTop: `${contentPaddingTop}px` }}
>
@@ -197,7 +185,7 @@ export function GlassFullMockup({
</div>
</div>
- <div
+ <div
className="absolute left-1/2 -translate-x-1/2 rounded-full z-20 pointer-events-none"
style={{
bottom: `${homeIndicatorBottom}px`,
diff --git a/app/components/ui/editor/mockups/HardShellMockup.tsx b/app/components/ui/editor/mockups/HardShellMockup.tsx
index aa24b94..96a7fb1 100644
--- a/app/components/ui/editor/mockups/HardShellMockup.tsx
+++ b/app/components/ui/editor/mockups/HardShellMockup.tsx
@@ -48,10 +48,11 @@ export function HardShellMockup({
const textColor = isDark ? "#ffffff" : "#000000";
const frameBorderColor = isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.2)";
- const buttonBgColor = isDark ? "rgba(255, 255, 255, 0.15)" : "rgba(0, 0, 0, 0.15)";
- const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.3)";
const homeIndicatorBg = isDark ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.2)";
+ const buttonBgColor = isDark ? "rgba(255, 255, 255, 0.15)" : "#ffffff";
+ const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.2)" : "#e5e5e5";
+
return (
<div className={`relative w-full h-full flex flex-col items-center justify-center ${className}`}>
diff --git a/lib/canvas.utils.ts b/lib/canvas.utils.ts
index c11de3b..41c9613 100644
--- a/lib/canvas.utils.ts
+++ b/lib/canvas.utils.ts
@@ -350,6 +350,25 @@ export interface RotationSnapResult {
const ROTATION_SNAP_STEP = 45;
const ROTATION_SNAP_THRESHOLD = 4;
+const MOCKUP_OUTER_RADIUS_MULTIPLIER: Record<string, number> = {
+ "iphone-slim": 2.5,
+ "glass-curve": 2.5,
+ "glass-full": 2.5,
+ "hard-shell": 1.5,
+ "s24-ultra": 1.2,
+ outline: 2.5,
+};
+
+const MOCKUP_OUTER_RADIUS_OFFSET: Record<string, number> = {
+ outline: 8,
+};
+
+export function getMockupOuterRadius(mockupId: string, roundedCorners: number): number {
+ const multiplier = MOCKUP_OUTER_RADIUS_MULTIPLIER[mockupId] ?? 1;
+ const offset = MOCKUP_OUTER_RADIUS_OFFSET[mockupId] ?? 0;
+ return roundedCorners * multiplier + offset;
+}
+
export function snapRotation(
angle: number,
step: number = ROTATION_SNAP_STEP,
diff --git a/lib/constants.ts b/lib/constants.ts
index ceac322..039b9d5 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -51,7 +51,7 @@ export const TIMELINE_ZOOM_SCALE: Record<number, number> = {
};
// Mockups con header → solo esquinas INFERIORES del video redondeadas
-export const BOTTOM_ONLY_RADIUS_MOCKUPS = ["macos", "macos-glass", "macos-ghost", "macos-ghost-glass", "vscode", "macos-dark-ide", "macos-ghost-ide", "brave", "brave-glass", "browser-tab-glass", "chrome", "chrome-glass", "s24-ultra", "glass-curve", "glass-full"];
+export const BOTTOM_ONLY_RADIUS_MOCKUPS = ["macos", "macos-glass", "macos-ghost", "macos-ghost-glass", "vscode", "macos-dark-ide", "macos-ghost-ide", "brave", "brave-glass", "browser-tab-glass", "chrome", "chrome-glass", "s24-ultra", "glass-curve", "glass-full", "iphone-slim", "hard-shell"];
// Glass mockups → handle their own shadow, do not need the solid rect underneath
export const SELF_SHADOWING_MOCKUPS = ["macos-glass", "outline", "macos-ghost-glass", "glass-ui-container", "macos-container-glass", "brave-glass", "browser-tab-glass", "chrome-glass", "iphone-slim", "glass-curve", "glass-full", "s24-ultra", "hard-shell"];
diff --git a/lib/mockup-canvas/glass-full.ts b/lib/mockup-canvas/glass-full.ts
index 4c81698..c330b27 100644
--- a/lib/mockup-canvas/glass-full.ts
+++ b/lib/mockup-canvas/glass-full.ts
@@ -12,28 +12,28 @@ export function drawGlassFullMockup(context: MockupCanvasContext): MockupDrawRes
const headerScale = (config.headerScale || 100) / 100;
const framePadding = 12 * headerScale;
- const buttonWidth = 14 * headerScale;
+ const buttonWidth = 5 * headerScale;
- const notchTop = 22 * headerScale;
- const notchWidth = 180 * headerScale;
- const notchHeight = 52 * headerScale;
- const notchPaddingX = 18 * headerScale;
- const dotSize = 16 * headerScale;
-
- const statusBarHeight = 85 * headerScale;
- const statusBarPaddingX = 50 * headerScale;
- const timeFontSize = 28 * headerScale;
- const signalBarWidth = 5 * headerScale;
- const iconsGap = 16 * headerScale;
- const wifiSize = 32 * headerScale;
- const batteryWidth = 46 * headerScale;
- const batteryHeight = 24 * headerScale;
-
- const contentPaddingTop = 115 * headerScale;
-
- const homeIndicatorWidth = 160 * headerScale;
- const homeIndicatorHeight = 6 * headerScale;
- const homeIndicatorBottom = 12 * headerScale;
+ const notchTop = 8 * headerScale;
+ const notchWidth = 104 * headerScale;
+ const notchHeight = 24 * headerScale;
+ const notchPaddingX = 8 * headerScale;
+ const dotSize = 8 * headerScale;
+
+ const statusBarHeight = 32 * headerScale;
+ const statusBarPaddingX = 28 * headerScale;
+ const timeFontSize = 10 * headerScale;
+ const signalBarWidth = 2 * headerScale;
+ const iconsGap = 6 * headerScale;
+ const wifiSize = 12 * headerScale;
+ const batteryWidth = 18 * headerScale;
+ const batteryHeight = 10 * headerScale;
+
+ const contentPaddingTop = 40 * headerScale;
+
+ const homeIndicatorWidth = 128 * headerScale;
+ const homeIndicatorHeight = 4 * headerScale;
+ const homeIndicatorBottom = 8 * headerScale;
const screenBg = isDark ? "#0a0a0a" : "#f9f9f9";
const frameBorderColor = isDark ? "rgba(255, 255, 255, 0.15)" : "rgba(255, 255, 255, 0.3)";
@@ -43,19 +43,19 @@ export function drawGlassFullMockup(context: MockupCanvasContext): MockupDrawRes
const statusBarTextDim = isDark ? "rgba(255, 255, 255, 0.4)" : "rgba(0, 0, 0, 0.2)";
const homeIndicatorBg = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.1)";
- const buttonBg = isDark ? "rgba(255, 255, 255, 0.25)" : "rgba(0, 0, 0, 0.15)";
- const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.4)" : "rgba(0, 0, 0, 0.25)";
+ const buttonBg = isDark ? "rgba(255, 255, 255, 0.25)" : "#ffffff";
+ const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.4)" : "#e5e5e5";
const buttonShadowColor = isDark ? "rgba(0, 0, 0, 0.5)" : "rgba(0, 0, 0, 0.2)";
- const outerRadius = cornerRadius * 8;
+ const outerRadius = cornerRadius * 2.8;
drawMockupShadow(ctx, x, y, width, height, outerRadius, shadowBlur);
ctx.save();
const drawButton = (percentY: number, percentH: number, isLeft: boolean) => {
const btnW = buttonWidth;
- const btnR = 4 * headerScale;
- const overlap = 2;
+ const btnR = 2 * headerScale;
+ const overlap = 1;
const btnY = y + (height * percentY);
const btnH = height * percentH;
@@ -92,9 +92,9 @@ export function drawGlassFullMockup(context: MockupCanvasContext): MockupDrawRes
ctx.stroke();
};
- drawButton(0.13, 0.09, true);
- drawButton(0.23, 0.18, true);
- drawButton(0.25, 0.20, false);
+ drawButton(0.15, 0.05, true);
+ drawButton(0.25, 0.12, true);
+ drawButton(0.28, 0.14, false);
ctx.restore();
ctx.save();
@@ -110,7 +110,8 @@ export function drawGlassFullMockup(context: MockupCanvasContext): MockupDrawRes
const screenY = y + framePadding;
const screenWidth = width - framePadding * 2;
const screenHeight = height - framePadding * 2;
- const innerRadius = Math.max(0, outerRadius - framePadding);
+
+ const innerRadius = cornerRadius * 2.3;
ctx.save();
drawRoundedRectPath(ctx, screenX, screenY, screenWidth, screenHeight, innerRadius);
@@ -167,20 +168,20 @@ export function drawGlassFullMockup(context: MockupCanvasContext): MockupDrawRes
const batteryY = statusBarCenterY - batteryHeight / 2;
ctx.save();
- drawRoundedRectPath(ctx, batteryX, batteryY, batteryWidth, batteryHeight, 4);
+ drawRoundedRectPath(ctx, batteryX, batteryY, batteryWidth, batteryHeight, 2);
ctx.strokeStyle = statusBarTextDim;
ctx.lineWidth = 1;
ctx.stroke();
ctx.fillStyle = statusBarText;
- const batPadding = 3;
+ const batPadding = 1;
const batInnerW = (batteryWidth - batPadding * 2) * 0.7;
const batInnerH = batteryHeight - batPadding * 2;
- drawRoundedRectPath(ctx, batteryX + batPadding, batteryY + batPadding, batInnerW, batInnerH, 2);
+ drawRoundedRectPath(ctx, batteryX + batPadding, batteryY + batPadding, batInnerW, batInnerH, 1);
ctx.fill();
ctx.fillStyle = statusBarTextDim;
- const nipW = 3;
+ const nipW = 1.5;
const nipH = batteryHeight * 0.4;
const nipY = statusBarCenterY - nipH / 2;
ctx.beginPath();
diff --git a/lib/mockup-canvas/hard-shell.ts b/lib/mockup-canvas/hard-shell.ts
index 1e795d4..15406d5 100644
--- a/lib/mockup-canvas/hard-shell.ts
+++ b/lib/mockup-canvas/hard-shell.ts
@@ -2,218 +2,201 @@ import type { MockupCanvasContext, MockupDrawResult } from "./types";
import { drawRoundedRectPath, drawMockupShadow } from "./shared";
export function drawHardShellMockup(context: MockupCanvasContext): MockupDrawResult {
- const { ctx, x, y, width, height, config, cornerRadius, shadowBlur } = context;
-
- const isDark = config.darkMode;
- const frameColor = isDark ? (config.frameColor || "#27272a") : "#ffffff";
- const headerScale = (config.headerScale || 100) / 100;
-
- const buttonWidth = 20 * headerScale;
- const outerPadding = 8 * headerScale;
- const bezelPadding = 6 * headerScale;
+ const { ctx, x, y, width, height, config, cornerRadius, shadowBlur } = context;
+
+ const isDark = config.darkMode;
+ const frameColor = isDark ? (config.frameColor || "#27272a") : "#ffffff";
+ const headerScale = (config.headerScale || 100) / 100;
+
+ const buttonWidth = 5 * headerScale;
+ const outerPadding = 6 * headerScale;
+ const bezelPadding = 4 * headerScale;
+ const cameraTop = 10 * headerScale;
+ const cameraSize = 14 * headerScale;
+ const cameraLensSize = 5 * headerScale;
+ const statusBarHeight = 32 * headerScale;
+ const statusBarPaddingX = 16 * headerScale;
+ const timeFontSize = 12 * headerScale;
+ const networkFontSize = 10 * headerScale;
+ const signalBarWidth = 3 * headerScale;
+ const batteryWidth = 22 * headerScale;
+ const batteryHeight = 11 * headerScale;
+ const contentPaddingTop = 44 * headerScale;
+ const homeIndicatorWidth = 112 * headerScale;
+ const homeIndicatorHeight = 6 * headerScale;
+ const homeIndicatorBottom = 8 * headerScale;
+
+ const screenBg = isDark ? "#000000" : "#f8fafc";
+ const textColor = isDark ? "#ffffff" : "#000000";
+ const frameBorderColor = isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.2)";
+ const homeIndicatorBg = isDark ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.2)";
+
+ const buttonBgColor = isDark ? "rgba(255, 255, 255, 0.15)" : "#ffffff";
+ const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.2)" : "#e5e5e5";
+
+ const outerRadius = cornerRadius * 1.7;
+
+ drawMockupShadow(ctx, x, y, width, height, outerRadius, shadowBlur);
+
+ ctx.save();
+ const drawButton = (percentY: number, percentH: number, isLeft: boolean) => {
+ const btnW = buttonWidth;
+ const btnR = 2 * headerScale;
+ const overlap = 1;
+ const btnY = y + (height * percentY);
+ const btnH = height * percentH;
+
+ ctx.beginPath();
+ if (isLeft) {
+ const btnX = x - btnW;
+ ctx.moveTo(btnX + btnW + overlap, btnY);
+ ctx.lineTo(btnX + btnR, btnY);
+ ctx.arcTo(btnX, btnY, btnX, btnY + btnR, btnR);
+ ctx.lineTo(btnX, btnY + btnH - btnR);
+ ctx.arcTo(btnX, btnY + btnH, btnX + btnR, btnY + btnH, btnR);
+ ctx.lineTo(btnX + btnW + overlap, btnY + btnH);
+ } else {
+ const btnX = x + width;
+ ctx.moveTo(btnX - overlap, btnY);
+ ctx.lineTo(btnX + btnW - btnR, btnY);
+ ctx.arcTo(btnX + btnW, btnY, btnX + btnW, btnY + btnR, btnR);
+ ctx.lineTo(btnX + btnW, btnY + btnH - btnR);
+ ctx.arcTo(btnX + btnW, btnY + btnH, btnX + btnW - btnR, btnY + btnH, btnR);
+ ctx.lineTo(btnX - overlap, btnY + btnH);
+ }
+
+ ctx.fillStyle = buttonBgColor;
+ ctx.fill();
+ ctx.strokeStyle = buttonBorderColor;
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ };
+
+ drawButton(0.18, 0.09, false);
+ drawButton(0.31, 0.05, false);
+ ctx.restore();
+
+ ctx.save();
+ drawRoundedRectPath(ctx, x, y, width, height, outerRadius);
+ ctx.fillStyle = frameColor;
+ ctx.fill();
+ ctx.strokeStyle = frameBorderColor;
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ ctx.restore();
- const cameraTop = 26 * headerScale;
- const cameraSize = 36 * headerScale;
- const cameraLensSize = 14 * headerScale;
+ const bezelX = x + outerPadding;
+ const bezelY = y + outerPadding;
+ const bezelWidth = width - (outerPadding * 2);
+ const bezelHeight = height - (outerPadding * 2);
+ const bezelRadius = cornerRadius * 1.2;
- const statusBarHeight = 105 * headerScale;
- const statusBarPaddingX = 48 * headerScale;
- const timeFontSize = 34 * headerScale;
- const networkFontSize = 26 * headerScale;
- const signalBarWidth = 7 * headerScale;
+ ctx.save();
+ drawRoundedRectPath(ctx, bezelX, bezelY, bezelWidth, bezelHeight, bezelRadius);
+ ctx.fillStyle = "#000000";
+ ctx.fill();
+ ctx.strokeStyle = "rgba(0,0,0,1)";
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ ctx.restore();
- const batteryWidth = 58 * headerScale;
- const batteryHeight = 28 * headerScale;
+ const screenX = bezelX + bezelPadding;
+ const screenY = bezelY + bezelPadding;
+ const screenWidth = bezelWidth - (bezelPadding * 2);
+ const screenHeight = bezelHeight - (bezelPadding * 2);
+ const screenRadius = cornerRadius * 0.8;
- const contentPaddingTop = 140 * headerScale;
+ ctx.save();
+ drawRoundedRectPath(ctx, screenX, screenY, screenWidth, screenHeight, screenRadius);
+ ctx.fillStyle = screenBg;
+ ctx.fill();
+ ctx.restore();
- const homeIndicatorWidth = 160 * headerScale;
- const homeIndicatorHeight = 8 * headerScale;
- const homeIndicatorBottom = 12 * headerScale;
+ const camCenterX = screenX + screenWidth / 2;
+ const camCenterY = screenY + cameraTop + cameraSize / 2;
- const screenBg = isDark ? "#000000" : "#f8fafc";
- const textColor = isDark ? "#ffffff" : "#000000";
- const frameBorderColor = isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.2)";
- const buttonBgColor = isDark ? "rgba(255, 255, 255, 0.15)" : "rgba(0, 0, 0, 0.15)";
- const buttonBorderColor = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.3)";
- const homeIndicatorBg = isDark ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.2)";
+ ctx.save();
+ ctx.beginPath();
+ ctx.arc(camCenterX, camCenterY, cameraSize / 2, 0, Math.PI * 2);
+ ctx.fillStyle = "#000000";
+ ctx.fill();
- const outerRadius = cornerRadius * 4;
+ ctx.beginPath();
+ ctx.arc(camCenterX, camCenterY, cameraLensSize / 2, 0, Math.PI * 2);
+ ctx.fillStyle = "rgba(30, 58, 138, 0.6)";
+ ctx.fill();
+ ctx.restore();
- drawMockupShadow(ctx, x, y, width, height, outerRadius, shadowBlur);
+ const timeX = screenX + statusBarPaddingX;
+ const timeY = screenY + statusBarHeight / 2;
- ctx.save();
- const drawButton = (percentY: number, percentH: number, isLeft: boolean) => {
- const btnW = buttonWidth;
- const btnR = 6 * headerScale;
- const overlap = 2;
+ ctx.save();
+ ctx.font = `500 ${timeFontSize}px "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
+ ctx.fillStyle = textColor;
+ ctx.textBaseline = "middle";
+ ctx.fillText("11:43", timeX, timeY + 1);
+ ctx.restore();
- const btnY = y + (height * percentY);
- const btnH = height * percentH;
+ const batX = screenX + screenWidth - statusBarPaddingX - batteryWidth;
+ const batY = timeY - batteryHeight / 2 + 1;
+ ctx.save();
+ ctx.strokeStyle = textColor;
+ ctx.lineWidth = 1;
ctx.beginPath();
- if (isLeft) {
- const btnX = x - btnW;
- ctx.moveTo(btnX + btnW + overlap, btnY);
- ctx.lineTo(btnX + btnR, btnY);
- ctx.arcTo(btnX, btnY, btnX, btnY + btnR, btnR);
- ctx.lineTo(btnX, btnY + btnH - btnR);
- ctx.arcTo(btnX, btnY + btnH, btnX + btnR, btnY + btnH, btnR);
- ctx.lineTo(btnX + btnW + overlap, btnY + btnH);
- } else {
- const btnX = x + width;
- ctx.moveTo(btnX - overlap, btnY);
- ctx.lineTo(btnX + btnW - btnR, btnY);
- ctx.arcTo(btnX + btnW, btnY, btnX + btnW, btnY + btnR, btnR);
- ctx.lineTo(btnX + btnW, btnY + btnH - btnR);
- ctx.arcTo(btnX + btnW, btnY + btnH, btnX + btnW - btnR, btnY + btnH, btnR);
- ctx.lineTo(btnX - overlap, btnY + btnH);
- }
+ drawRoundedRectPath(ctx, batX, batY, batteryWidth, batteryHeight, 3 * headerScale);
+ ctx.stroke();
- ctx.fillStyle = buttonBgColor;
+ const batPad = 1.5 * headerScale;
+ const fillWidth = (batteryWidth - batPad * 2) * 0.8;
+ const fillHeight = batteryHeight - batPad * 2;
+ ctx.fillStyle = textColor;
+ ctx.beginPath();
+ drawRoundedRectPath(ctx, batX + batPad, batY + batPad, fillWidth, fillHeight, 1 * headerScale);
ctx.fill();
- ctx.strokeStyle = buttonBorderColor;
- ctx.lineWidth = 2;
- ctx.stroke();
- };
-
- drawButton(0.15, 0.15, false);
- drawButton(0.32, 0.09, false);
- ctx.restore();
-
- ctx.save();
- drawRoundedRectPath(ctx, x, y, width, height, outerRadius);
- ctx.fillStyle = frameColor;
- ctx.fill();
- ctx.strokeStyle = frameBorderColor;
- ctx.lineWidth = 1;
- ctx.stroke();
- ctx.restore();
-
- const bezelX = x + outerPadding;
- const bezelY = y + outerPadding;
- const bezelWidth = width - (outerPadding * 2);
- const bezelHeight = height - (outerPadding * 2);
- const bezelRadius = cornerRadius * 4;
-
- ctx.save();
- drawRoundedRectPath(ctx, bezelX, bezelY, bezelWidth, bezelHeight, bezelRadius);
- ctx.fillStyle = "#000000";
- ctx.fill();
- ctx.strokeStyle = "rgba(0,0,0,1)";
- ctx.lineWidth = 2;
- ctx.stroke();
- ctx.restore();
-
- const screenX = bezelX + bezelPadding;
- const screenY = bezelY + bezelPadding;
- const screenWidth = bezelWidth - (bezelPadding * 2);
- const screenHeight = bezelHeight - (bezelPadding * 2);
- const screenRadius = Math.max(0, outerRadius - bezelPadding);
-
- ctx.save();
- drawRoundedRectPath(ctx, screenX, screenY, screenWidth, screenHeight, screenRadius);
- ctx.fillStyle = screenBg;
- ctx.fill();
- ctx.restore();
-
- const camCenterX = screenX + screenWidth / 2;
- const camCenterY = screenY + cameraTop + cameraSize / 2;
-
- ctx.save();
- ctx.beginPath();
- ctx.arc(camCenterX, camCenterY, cameraSize / 2, 0, Math.PI * 2);
- ctx.fillStyle = "#000000";
- ctx.fill();
- ctx.beginPath();
- ctx.arc(camCenterX, camCenterY, cameraLensSize / 2, 0, Math.PI * 2);
- ctx.fillStyle = "rgba(30, 58, 138, 0.6)";
- ctx.fill();
- ctx.restore();
-
- const timeX = screenX + statusBarPaddingX;
- const timeY = screenY + statusBarHeight / 2;
-
- ctx.save();
- ctx.font = `500 ${timeFontSize}px "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
- ctx.fillStyle = textColor;
- ctx.textBaseline = "middle";
- ctx.fillText("11:43", timeX, timeY + 1);
- ctx.restore();
-
- const batPoleWidth = 5 * headerScale;
- const batPoleHeight = 10 * headerScale;
- const batX = screenX + screenWidth - statusBarPaddingX - batPoleWidth - batteryWidth;
- const batY = timeY - batteryHeight / 2 + 1;
-
- ctx.save();
- ctx.strokeStyle = textColor;
- ctx.lineWidth = 2 * headerScale;
- ctx.beginPath();
- drawRoundedRectPath(ctx, batX, batY, batteryWidth, batteryHeight, 6 * headerScale);
- ctx.stroke();
-
- const batPad = 4 * headerScale;
- const fillWidth = (batteryWidth - batPad * 2) * 0.8;
- const fillHeight = batteryHeight - batPad * 2;
- ctx.fillStyle = textColor;
- ctx.beginPath();
- drawRoundedRectPath(ctx, batX + batPad, batY + batPad, fillWidth, fillHeight, 2.5 * headerScale);
- ctx.fill();
-
- ctx.beginPath();
- const bumpY = batY + (batteryHeight - batPoleHeight) / 2;
- ctx.moveTo(batX + batteryWidth, bumpY);
- ctx.lineTo(batX + batteryWidth + batPoleWidth - 1, bumpY);
- ctx.quadraticCurveTo(batX + batteryWidth + batPoleWidth, bumpY, batX + batteryWidth + batPoleWidth, bumpY + 1);
- ctx.lineTo(batX + batteryWidth + batPoleWidth, bumpY + batPoleHeight - 1);
- ctx.quadraticCurveTo(batX + batteryWidth + batPoleWidth, bumpY + batPoleHeight, batX + batteryWidth + batPoleWidth - 1, bumpY + batPoleHeight);
- ctx.lineTo(batX + batteryWidth, bumpY + batPoleHeight);
- ctx.globalAlpha = 0.9;
- ctx.fill();
- ctx.restore();
-
- const sigGap = 2.5 * headerScale;
- const totalSigWidth = (signalBarWidth * 4) + (sigGap * 3);
- const sigX = batX - 16 * headerScale - totalSigWidth;
- const sigMaxHeight = 32 * headerScale;
- const sigYBottom = batY + batteryHeight;
-
- ctx.save();
- ctx.fillStyle = textColor;
- const sigPercents = [0.5, 0.65, 0.8, 1.0];
- for (let i = 0; i < 4; i++) {
- const h = sigMaxHeight * sigPercents[i];
- const barX = sigX + i * (signalBarWidth + sigGap);
- const barY = sigYBottom - h;
- drawRoundedRectPath(ctx, barX, barY, signalBarWidth, h, 2 * headerScale);
+ ctx.restore();
+
+ const sigGap = 1 * headerScale;
+ const totalSigWidth = (signalBarWidth * 4) + (sigGap * 3);
+ const sigX = batX - 4 * headerScale - totalSigWidth;
+ const sigMaxHeight = 12 * headerScale;
+ const sigYBottom = batY + batteryHeight;
+
+ ctx.save();
+ ctx.fillStyle = textColor;
+ const sigPercents = [0.5, 0.65, 0.8, 1.0];
+ for (let i = 0; i < 4; i++) {
+ const h = sigMaxHeight * sigPercents[i];
+ const barX = sigX + i * (signalBarWidth + sigGap);
+ const barY = sigYBottom - h;
+ drawRoundedRectPath(ctx, barX, barY, signalBarWidth, h, 1 * headerScale);
+ ctx.fill();
+ }
+ ctx.restore();
+
+ const text5G = "5G";
+ ctx.save();
+ ctx.font = `bold ${networkFontSize}px "Inter", sans-serif`;
+ ctx.fillStyle = textColor;
+ ctx.textBaseline = "middle";
+ const textMetrics = ctx.measureText(text5G);
+ const text5GX = sigX - 4 * headerScale - textMetrics.width;
+ ctx.fillText(text5G, text5GX, timeY + 1);
+ ctx.restore();
+
+ const homeIndicatorX = screenX + (screenWidth - homeIndicatorWidth) / 2;
+ const homeIndicatorY = screenY + screenHeight - homeIndicatorBottom - homeIndicatorHeight;
+
+ ctx.save();
+ drawRoundedRectPath(ctx, homeIndicatorX, homeIndicatorY, homeIndicatorWidth, homeIndicatorHeight, homeIndicatorHeight / 2);
+ ctx.fillStyle = homeIndicatorBg;
ctx.fill();
- }
- ctx.restore();
-
- const text5G = "5G";
- ctx.save();
- ctx.font = `bold ${networkFontSize}px "Inter", sans-serif`;
- ctx.fillStyle = textColor;
- ctx.textBaseline = "middle";
- const textMetrics = ctx.measureText(text5G);
- const text5GX = sigX - 16 * headerScale - textMetrics.width;
- ctx.fillText(text5G, text5GX, timeY + 1);
- ctx.restore();
-
- const homeIndicatorX = screenX + (screenWidth - homeIndicatorWidth) / 2;
- const homeIndicatorY = screenY + screenHeight - homeIndicatorBottom - homeIndicatorHeight;
-
- ctx.save();
- drawRoundedRectPath(ctx, homeIndicatorX, homeIndicatorY, homeIndicatorWidth, homeIndicatorHeight, homeIndicatorHeight / 2);
- ctx.fillStyle = homeIndicatorBg;
- ctx.fill();
- ctx.restore();
-
- return {
- contentX: screenX,
- contentY: screenY + contentPaddingTop,
- contentWidth: screenWidth,
- contentHeight: screenHeight - contentPaddingTop,
- };
+ ctx.restore();
+
+ return {
+ contentX: screenX,
+ contentY: screenY + contentPaddingTop,
+ contentWidth: screenWidth,
+ contentHeight: screenHeight - contentPaddingTop,
+ };
}
\ No newline at end of file
diff --git a/lib/mockup-canvas/iphone-slim.ts b/lib/mockup-canvas/iphone-slim.ts
index 2781f91..fb604d4 100644
--- a/lib/mockup-canvas/iphone-slim.ts
+++ b/lib/mockup-canvas/iphone-slim.ts
@@ -11,27 +11,25 @@ export function drawIPhoneSlimMockup(context: MockupCanvasContext): MockupDrawRe
const headerOpacity = config.headerOpacity ?? 100;
const headerScale = (config.headerScale || 100) / 100;
- const framePadding = 6 * headerScale;
+ const framePadding = 4 * headerScale;
const borderColor = isDark ? "#404040" : "#525252";
const statusBarText = isDark ? "#ffffff" : "#000000";
- const outerRadius = cornerRadius * 8;
- const statusBarHeight = 120 * headerScale;
- const dynamicIslandHeight = 44 * headerScale;
- const dynamicIslandTop = 16 * headerScale;
-
- const statusBarPaddingX = 60 * headerScale;
-
- const timeFontSize = 38 * headerScale;
- const iconStatusSize = 34 * headerScale;
- const batteryWidth = 62 * headerScale;
- const batteryHeight = 28 * headerScale;
-
- const buttonWidth = 20 * headerScale;
- const buttonRadius = 6 * headerScale;
-
- const homeIndicatorHeight = 5 * headerScale;
- const homeIndicatorBottom = 10 * headerScale;
+ const outerRadius = cornerRadius * 1.8;
+ const statusBarHeight = 44 * headerScale;
+ const dynamicIslandHeight = 24 * headerScale;
+ const dynamicIslandTop = 10 * headerScale;
+ const statusBarPaddingX = 24 * headerScale;
+ const timeFontSize = 14 * headerScale;
+ const iconStatusSize = 14 * headerScale;
+ const batteryWidth = 24 * headerScale;
+ const batteryHeight = 12 * headerScale;
+
+ const buttonWidth = 5 * headerScale;
+ const buttonRadius = 1.5 * headerScale;
+
+ const homeIndicatorHeight = 4 * headerScale;
+ const homeIndicatorBottom = 8 * headerScale;
drawMockupShadow(ctx, x, y, width, height, outerRadius, shadowBlur);
@@ -39,7 +37,7 @@ export function drawIPhoneSlimMockup(context: MockupCanvasContext): MockupDrawRe
const drawButton = (percentY: number, percentH: number, isLeft: boolean) => {
const btnW = buttonWidth;
const btnR = buttonRadius;
- const overlap = 2;
+ const overlap = 1;
const btnY = y + (height * percentY);
const btnH = height * percentH;
@@ -61,10 +59,11 @@ export function drawIPhoneSlimMockup(context: MockupCanvasContext): MockupDrawRe
ctx.arcTo(btnX + btnW, btnY + btnH, btnX + btnW - btnR, btnY + btnH, btnR);
ctx.lineTo(btnX - overlap, btnY + btnH);
}
+
ctx.fillStyle = hexToRgba(frameColor, headerOpacity);
ctx.fill();
ctx.strokeStyle = borderColor;
- ctx.lineWidth = 2;
+ ctx.lineWidth = 1;
ctx.stroke();
};
@@ -102,13 +101,20 @@ export function drawIPhoneSlimMockup(context: MockupCanvasContext): MockupDrawRe
const dynamicIslandY = screenY + dynamicIslandTop;
ctx.save();
- drawRoundedRectPath(ctx, dynamicIslandX, dynamicIslandY, dynamicIslandWidth, dynamicIslandHeight, dynamicIslandHeight / 2);
+ drawRoundedRectPath(
+ ctx,
+ dynamicIslandX,
+ dynamicIslandY,
+ dynamicIslandWidth,
+ dynamicIslandHeight,
+ dynamicIslandHeight / 2
+ );
ctx.fillStyle = "#000000";
ctx.fill();
ctx.restore();
const timeX = screenX + statusBarPaddingX;
- const timeY = screenY + (statusBarHeight / 2) - (6 * headerScale);
+ const timeY = screenY + (statusBarHeight / 2);
ctx.save();
ctx.font = `bold ${timeFontSize}px "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
@@ -121,11 +127,11 @@ export function drawIPhoneSlimMockup(context: MockupCanvasContext): MockupDrawRe
const batteryY = timeY - (batteryHeight / 2);
drawBattery(ctx, batteryX, batteryY, batteryWidth, batteryHeight, statusBarText, 0.9);
- const wifiX = batteryX - iconStatusSize - 12 * headerScale;
+ const wifiX = batteryX - iconStatusSize - (8 * headerScale);
const wifiY = timeY - (iconStatusSize / 2);
drawWifiIcon(ctx, wifiX, wifiY, iconStatusSize, statusBarText);
- const signalX = wifiX - iconStatusSize - 8 * headerScale;
+ const signalX = wifiX - iconStatusSize - (4 * headerScale);
const signalY = timeY - (iconStatusSize / 2);
drawSignalBars(ctx, signalX, signalY, iconStatusSize, statusBarText);
@@ -134,7 +140,14 @@ export function drawIPhoneSlimMockup(context: MockupCanvasContext): MockupDrawRe
const homeIndicatorY = screenY + screenHeight - homeIndicatorBottom - homeIndicatorHeight;
ctx.save();
- drawRoundedRectPath(ctx, homeIndicatorX, homeIndicatorY, homeIndicatorWidth, homeIndicatorHeight, homeIndicatorHeight / 2);
+ drawRoundedRectPath(
+ ctx,
+ homeIndicatorX,
+ homeIndicatorY,
+ homeIndicatorWidth,
+ homeIndicatorHeight,
+ homeIndicatorHeight / 2
+ );
ctx.fillStyle = `${statusBarText}15`;
ctx.fill();
ctx.restore();
diff --git a/lib/mockup-canvas/s24-ultra.ts b/lib/mockup-canvas/s24-ultra.ts
index 608d4ec..51f716c 100644
--- a/lib/mockup-canvas/s24-ultra.ts
+++ b/lib/mockup-canvas/s24-ultra.ts
@@ -2,192 +2,195 @@ import type { MockupCanvasContext, MockupDrawResult } from "./types";
import { drawRoundedRectPath, drawMockupShadow } from "./shared";
export function drawS24UltraMockup(context: MockupCanvasContext): MockupDrawResult {
- const { ctx, x, y, width, height, config, cornerRadius, shadowBlur } = context;
+ const { ctx, x, y, width, height, config, cornerRadius, shadowBlur } = context;
+
+ const isDark = config.darkMode;
+ const headerScale = (config.headerScale || 100) / 100;
+
+ const frameColor = isDark ? (config.frameColor || "#171717") : "#e5e5e5";
+
+ const framePadding = 4 * headerScale;
+ const buttonWidth = 7 * headerScale;
+ const buttonRadius = 2 * headerScale;
+
+ const cameraTop = 8 * headerScale;
+ const cameraSize = 12 * headerScale;
+ const cameraLensSize = 4 * headerScale;
+
+ const statusBarHeight = 32 * headerScale;
+ const statusBarPaddingX = 16 * headerScale;
+ const timeFontSize = 12 * headerScale;
+
+ const batW = 22 * headerScale;
+ const batH = 11 * headerScale;
+ const box5GSize = 14 * headerScale;
+ const text5GSize = 8 * headerScale;
+ const wifiSize = 14 * headerScale;
+ const gap = 6 * headerScale;
+
+ const navBarHeight = 32 * headerScale;
+ const navIconSize = 12 * headerScale;
+ const navGap = 32 * headerScale;
+
+ const screenBg = isDark ? "#000000" : "#ffffff";
+ const frameBorderColor = isDark ? "#404040" : "#d4d4d4";
+ const screenBorderColor = isDark ? "rgba(255,255,255,0.1)" : "#000000";
+
+ const buttonBgColor = isDark ? "#737373" : "#a3a3a3";
+ const buttonBorderColor = isDark ? "#262626" : "#737373";
+
+ const textAndIconColor = isDark ? "rgba(255,255,255,0.9)" : "rgba(0,0,0,0.9)";
+ const navIconColor = isDark ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.2)";
+ const iconBoxBg = isDark ? "#ffffff" : "#000000";
+ const iconBoxText = isDark ? "#000000" : "#ffffff";
+
+ const outerRadius = cornerRadius * 1.2;
+
+ drawMockupShadow(ctx, x, y, width, height, outerRadius, shadowBlur);
+
+ ctx.save();
+ const drawSideButton = (percentY: number, percentH: number) => {
+ const btnY = y + (height * percentY);
+ const btnH = height * percentH;
+ const overlap = 1;
+ const btnX = x + width - overlap;
+
+ ctx.beginPath();
+ ctx.moveTo(btnX, btnY);
+ ctx.lineTo(btnX + buttonWidth - buttonRadius, btnY);
+ ctx.arcTo(btnX + buttonWidth, btnY, btnX + buttonWidth, btnY + buttonRadius, buttonRadius);
+ ctx.lineTo(btnX + buttonWidth, btnY + btnH - buttonRadius);
+ ctx.arcTo(btnX + buttonWidth, btnY + btnH, btnX + buttonWidth - buttonRadius, btnY + btnH, buttonRadius);
+ ctx.lineTo(btnX, btnY + btnH);
+
+ ctx.fillStyle = buttonBgColor;
+ ctx.fill();
+ ctx.strokeStyle = buttonBorderColor;
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ };
+
+ drawSideButton(0.20, 0.08);
+ drawSideButton(0.32, 0.12);
+ ctx.restore();
+
+ ctx.save();
+ drawRoundedRectPath(ctx, x, y, width, height, outerRadius);
+ ctx.fillStyle = frameColor;
+ ctx.fill();
+ ctx.strokeStyle = frameBorderColor;
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ ctx.restore();
- const isDark = config.darkMode;
- const headerScale = (config.headerScale || 100) / 100;
+ const screenX = x + framePadding;
+ const screenY = y + framePadding;
+ const screenWidth = width - (framePadding * 2);
+ const screenHeight = height - (framePadding * 2);
+ const screenRadius = Math.max(0, outerRadius - framePadding);
- const frameColor = isDark ? (config.frameColor || "#171717") : "#e5e5e5";
- const framePadding = 10 * headerScale;
+ ctx.save();
+ drawRoundedRectPath(ctx, screenX, screenY, screenWidth, screenHeight, screenRadius);
+ ctx.fillStyle = screenBg;
+ ctx.fill();
+ ctx.strokeStyle = screenBorderColor;
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ ctx.restore();
- const buttonWidth = 18 * headerScale;
- const buttonRadius = 4 * headerScale;
+ const camCenterX = screenX + screenWidth / 2;
+ const camCenterY = screenY + cameraTop + cameraSize / 2;
- const cameraTop = 22 * headerScale;
- const cameraSize = 34 * headerScale;
- const cameraLensSize = 10 * headerScale;
+ ctx.save();
+ ctx.beginPath();
+ ctx.arc(camCenterX, camCenterY, cameraSize / 2, 0, Math.PI * 2);
+ ctx.fillStyle = "#000000";
+ ctx.fill();
- const statusBarHeight = 110 * headerScale;
- const statusBarPaddingX = 56 * headerScale;
- const timeFontSize = 32 * headerScale;
+ ctx.beginPath();
+ ctx.arc(camCenterX, camCenterY, cameraLensSize / 2, 0, Math.PI * 2);
+ ctx.fillStyle = "rgba(99, 102, 241, 0.3)";
+ ctx.fill();
+ ctx.restore();
- const batW = 54 * headerScale;
- const batH = 26 * headerScale;
- const box5GSize = 36 * headerScale;
- const text5GSize = 18 * headerScale;
- const wifiSize = 30 * headerScale;
- const gap = 16 * headerScale;
+ const statusYCenter = screenY + (statusBarHeight / 2);
- const navBarHeight = 85 * headerScale;
- const navIconSize = 28 * headerScale;
- const navGap = 85 * headerScale;
+ ctx.save();
+ ctx.font = `500 ${timeFontSize}px "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
+ ctx.fillStyle = textAndIconColor;
+ ctx.textBaseline = "middle";
+ ctx.fillText("12:30", screenX + statusBarPaddingX, statusYCenter + (1 * headerScale));
+ ctx.restore();
- const screenBg = isDark ? "#000000" : "#ffffff";
- const frameBorderColor = isDark ? "#404040" : "#d4d4d4";
- const screenBorderColor = isDark ? "rgba(255,255,255,0.1)" : "#000000";
- const buttonBgColor = isDark ? "#737373" : "#a3a3a3";
- const buttonBorderColor = isDark ? "#262626" : "#737373";
- const textAndIconColor = isDark ? "rgba(255,255,255,0.9)" : "rgba(0,0,0,0.9)";
- const navIconColor = isDark ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.2)";
- const iconBoxBg = isDark ? "#ffffff" : "#000000";
- const iconBoxText = isDark ? "#000000" : "#ffffff";
+ let currentRightX = screenX + screenWidth - statusBarPaddingX;
- const outerRadius = cornerRadius * 1.2;
+ currentRightX -= batW;
+ ctx.save();
+ ctx.strokeStyle = isDark ? "rgba(255,255,255,0.4)" : "rgba(0,0,0,0.4)";
+ ctx.lineWidth = 1 * headerScale;
+ drawRoundedRectPath(ctx, currentRightX, statusYCenter - batH / 2, batW, batH, 2 * headerScale);
+ ctx.stroke();
- drawMockupShadow(ctx, x, y, width, height, outerRadius, shadowBlur);
+ ctx.fillStyle = iconBoxBg;
+ const pad = 1 * headerScale;
+ drawRoundedRectPath(ctx, currentRightX + pad, statusYCenter - batH / 2 + pad, batW - pad * 2, batH - pad * 2, 1 * headerScale);
+ ctx.fill();
+ ctx.restore();
- ctx.save();
- const drawSideButton = (percentY: number, percentH: number) => {
- const btnY = y + (height * percentY);
- const btnH = height * percentH;
- const overlap = 2;
- const btnX = x + width - overlap;
+ currentRightX -= (box5GSize + gap);
+ ctx.save();
+ ctx.fillStyle = iconBoxBg;
+ drawRoundedRectPath(ctx, currentRightX, statusYCenter - box5GSize / 2, box5GSize, box5GSize, 2 * headerScale);
+ ctx.fill();
+ ctx.font = `bold ${text5GSize}px "Inter", sans-serif`;
+ ctx.fillStyle = iconBoxText;
+ ctx.textAlign = "center";
+ ctx.textBaseline = "middle";
+ ctx.fillText("5G", currentRightX + box5GSize / 2, statusYCenter + (0.5 * headerScale));
+ ctx.restore();
+
+ currentRightX -= (wifiSize + gap);
+ ctx.save();
+ ctx.translate(currentRightX, statusYCenter - wifiSize / 2);
+ const wifiScale = wifiSize / 24;
+ ctx.scale(wifiScale, wifiScale);
+ const wifiPath = new Path2D("M12 21l-12-12c5.5-5.5 14.5-5.5 20 0l-8 12z");
+ ctx.fillStyle = textAndIconColor;
+ ctx.globalAlpha = 0.8;
+ ctx.fill(wifiPath);
+ ctx.restore();
+
+ const navYCenter = screenY + screenHeight - navBarHeight / 2;
+ const navCenterX = screenX + screenWidth / 2;
+
+ ctx.save();
+ ctx.strokeStyle = navIconColor;
+ ctx.lineWidth = 1.5 * headerScale;
+ ctx.lineCap = "round";
+ ctx.lineJoin = "round";
+
+ const leftIconX = navCenterX - navGap;
+ ctx.strokeRect(leftIconX - navIconSize / 2, navYCenter - navIconSize / 2, navIconSize, navIconSize);
ctx.beginPath();
- ctx.moveTo(btnX, btnY);
- ctx.lineTo(btnX + buttonWidth - buttonRadius, btnY);
- ctx.arcTo(btnX + buttonWidth, btnY, btnX + buttonWidth, btnY + buttonRadius, buttonRadius);
- ctx.lineTo(btnX + buttonWidth, btnY + btnH - buttonRadius);
- ctx.arcTo(btnX + buttonWidth, btnY + btnH, btnX + buttonWidth - buttonRadius, btnY + btnH, buttonRadius);
- ctx.lineTo(btnX, btnY + btnH);
- ctx.fillStyle = buttonBgColor;
- ctx.fill();
- ctx.strokeStyle = buttonBorderColor;
- ctx.lineWidth = 1.5;
+ ctx.arc(navCenterX, navYCenter, navIconSize / 2, 0, Math.PI * 2);
+ ctx.stroke();
+
+ const rightIconX = navCenterX + navGap + (3 * headerScale);
+ ctx.translate(rightIconX, navYCenter);
+ ctx.rotate(45 * Math.PI / 180);
+ ctx.beginPath();
+ const halfIcon = navIconSize / 2;
+ ctx.moveTo(-halfIcon, -halfIcon);
+ ctx.lineTo(-halfIcon, halfIcon);
+ ctx.lineTo(halfIcon, halfIcon);
ctx.stroke();
- };
-
- drawSideButton(0.20, 0.08);
- drawSideButton(0.32, 0.12);
- ctx.restore();
-
- ctx.save();
- drawRoundedRectPath(ctx, x, y, width, height, outerRadius);
- ctx.fillStyle = frameColor;
- ctx.fill();
- ctx.strokeStyle = frameBorderColor;
- ctx.lineWidth = 1;
- ctx.stroke();
- ctx.restore();
-
- const screenX = x + framePadding;
- const screenY = y + framePadding;
- const screenWidth = width - (framePadding * 2);
- const screenHeight = height - (framePadding * 2);
- const screenRadius = Math.max(0, outerRadius - framePadding);
-
- ctx.save();
- drawRoundedRectPath(ctx, screenX, screenY, screenWidth, screenHeight, screenRadius);
- ctx.fillStyle = screenBg;
- ctx.fill();
- ctx.strokeStyle = screenBorderColor;
- ctx.lineWidth = 1;
- ctx.stroke();
- ctx.restore();
-
- const camCenterX = screenX + screenWidth / 2;
- const camCenterY = screenY + cameraTop + cameraSize / 2;
-
- ctx.save();
- ctx.beginPath();
- ctx.arc(camCenterX, camCenterY, cameraSize / 2, 0, Math.PI * 2);
- ctx.fillStyle = "#000000";
- ctx.fill();
-
- ctx.beginPath();
- ctx.arc(camCenterX, camCenterY, cameraLensSize / 2, 0, Math.PI * 2);
- ctx.fillStyle = "rgba(99, 102, 241, 0.3)";
- ctx.fill();
- ctx.restore();
-
- const statusYCenter = screenY + (statusBarHeight / 2);
-
- ctx.save();
- ctx.font = `500 ${timeFontSize}px "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
- ctx.fillStyle = textAndIconColor;
- ctx.textBaseline = "middle";
- ctx.fillText("12:30", screenX + statusBarPaddingX, statusYCenter + (2 * headerScale));
- ctx.restore();
-
- let currentRightX = screenX + screenWidth - statusBarPaddingX;
-
- currentRightX -= batW;
- ctx.save();
- ctx.strokeStyle = isDark ? "rgba(255,255,255,0.4)" : "rgba(0,0,0,0.4)";
- ctx.lineWidth = 2 * headerScale;
- drawRoundedRectPath(ctx, currentRightX, statusYCenter - batH / 2, batW, batH, 4 * headerScale);
- ctx.stroke();
-
- ctx.fillStyle = iconBoxBg;
- const pad = 2 * headerScale;
- drawRoundedRectPath(ctx, currentRightX + pad, statusYCenter - batH / 2 + pad, batW - pad * 2, batH - pad * 2, 2 * headerScale);
- ctx.fill();
- ctx.restore();
-
- currentRightX -= (box5GSize + gap);
- ctx.save();
- ctx.fillStyle = iconBoxBg;
- drawRoundedRectPath(ctx, currentRightX, statusYCenter - box5GSize / 2, box5GSize, box5GSize, 4 * headerScale);
- ctx.fill();
- ctx.font = `bold ${text5GSize}px "Inter", sans-serif`;
- ctx.fillStyle = iconBoxText;
- ctx.textAlign = "center";
- ctx.textBaseline = "middle";
- ctx.fillText("5G", currentRightX + box5GSize / 2, statusYCenter + (1 * headerScale));
- ctx.restore();
-
- currentRightX -= (wifiSize + gap);
- ctx.save();
- ctx.translate(currentRightX, statusYCenter - wifiSize / 2);
- const wifiScale = wifiSize / 24;
- ctx.scale(wifiScale, wifiScale);
- const wifiPath = new Path2D("M12 21l-12-12c5.5-5.5 14.5-5.5 20 0l-8 12z");
- ctx.fillStyle = textAndIconColor;
- ctx.globalAlpha = 0.8;
- ctx.fill(wifiPath);
- ctx.restore();
-
- const navYCenter = screenY + screenHeight - navBarHeight / 2;
- const navCenterX = screenX + screenWidth / 2;
-
- ctx.save();
- ctx.strokeStyle = navIconColor;
- ctx.lineWidth = 3 * headerScale;
- ctx.lineCap = "round";
- ctx.lineJoin = "round";
-
- const leftIconX = navCenterX - navGap;
- ctx.strokeRect(leftIconX - navIconSize / 2, navYCenter - navIconSize / 2, navIconSize, navIconSize);
-
- ctx.beginPath();
- ctx.arc(navCenterX, navYCenter, navIconSize / 2, 0, Math.PI * 2);
- ctx.stroke();
-
- const rightIconX = navCenterX + navGap + (6 * headerScale);
- ctx.translate(rightIconX, navYCenter);
- ctx.rotate(45 * Math.PI / 180);
- ctx.beginPath();
- const halfIcon = navIconSize / 2;
- ctx.moveTo(-halfIcon, -halfIcon);
- ctx.lineTo(-halfIcon, halfIcon);
- ctx.lineTo(halfIcon, halfIcon);
- ctx.stroke();
- ctx.restore();
-
- return {
- contentX: screenX,
- contentY: screenY + statusBarHeight,
- contentWidth: screenWidth,
- contentHeight: screenHeight - statusBarHeight - navBarHeight,
- };
+ ctx.restore();
+
+ return {
+ contentX: screenX,
+ contentY: screenY + statusBarHeight,
+ contentWidth: screenWidth,
+ contentHeight: screenHeight - statusBarHeight - navBarHeight,
+ };
}
\ No newline at end of file
diff --git a/lib/mockup-data.tsx b/lib/mockup-data.tsx
index 18d3c07..4eb8ff9 100644
--- a/lib/mockup-data.tsx
+++ b/lib/mockup-data.tsx
@@ -208,7 +208,7 @@ export const MOCKUPS: Mockup[] = [
name: "Browser Tab Glass",
category: "browser",
features: {
- hasDarkMode: true,
+ hasDarkMode: false,
hasFrameColor: false,
hasUrl: true,
hasHeaderScale: true,