Create professional demos and 3D mockups in seconds, directly in your browser
export function drawRoundedRectPath(
ctx: CanvasRenderingContext2D,
x: number,
y: number,
width: number,
height: number,
radius: number
) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
export function drawMockupShadow(
ctx: CanvasRenderingContext2D,
x: number,
y: number,
width: number,
height: number,
cornerRadius: number,
shadowBlur: number
) {
if (shadowBlur <= 0) return;
ctx.save();
ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
ctx.shadowBlur = shadowBlur;
ctx.shadowOffsetY = shadowBlur * 0.3;
ctx.strokeStyle = 'rgba(0, 0, 0, 0.3)'; // More visible for prominent shadows
ctx.lineWidth = 1;
drawRoundedRectPath(ctx, x, y, width, height, cornerRadius);
ctx.stroke();
ctx.restore();
}