Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

feat(image): add layer effects, per-corner radius, color palettes, and text shadow

Augustus Otu6700020bc91c
diff --git a/apps/image/src/components/editor/canvas/Canvas.tsx b/apps/image/src/components/editor/canvas/Canvas.tsx
index 8fec7312..fce1bad4 100644
--- a/apps/image/src/components/editor/canvas/Canvas.tsx
+++ b/apps/image/src/components/editor/canvas/Canvas.tsx
@@ -485,7 +485,7 @@ function renderLayer(
layer: Layer,
project: { assets: Record<string, { dataUrl?: string; blobUrl?: string }> }
) {
- const { transform } = layer;
+ const { transform, shadow, glow } = layer;
ctx.save();
ctx.translate(transform.x, transform.y);
@@ -493,6 +493,41 @@ function renderLayer(
ctx.scale(transform.scaleX, transform.scaleY);
ctx.globalAlpha = transform.opacity;
+ if (glow.enabled && glow.blur > 0) {
+ ctx.save();
+ ctx.shadowColor = glow.color;
+ ctx.shadowBlur = glow.blur * glow.intensity;
+ ctx.shadowOffsetX = 0;
+ ctx.shadowOffsetY = 0;
+
+ for (let i = 0; i < 3; i++) {
+ renderLayerContent(ctx, layer, project);
+ }
+ ctx.restore();
+ }
+
+ if (shadow.enabled) {
+ ctx.shadowColor = shadow.color;
+ ctx.shadowBlur = shadow.blur;
+ ctx.shadowOffsetX = shadow.offsetX;
+ ctx.shadowOffsetY = shadow.offsetY;
+ }
+
+ renderLayerContent(ctx, layer, project);
+
+ ctx.shadowColor = 'transparent';
+ ctx.shadowBlur = 0;
+ ctx.shadowOffsetX = 0;
+ ctx.shadowOffsetY = 0;
+
+ ctx.restore();
+}
+
+function renderLayerContent(
+ ctx: CanvasRenderingContext2D,
+ layer: Layer,
+ project: { assets: Record<string, { dataUrl?: string; blobUrl?: string }> }
+) {
switch (layer.type) {
case 'image':
renderImageLayer(ctx, layer as ImageLayer, project);
@@ -504,8 +539,6 @@ function renderLayer(
renderShapeLayer(ctx, layer as ShapeLayer);
break;
}
-
- ctx.restore();
}
function applyMotionBlur(
@@ -704,6 +737,13 @@ function renderTextLayer(ctx: CanvasRenderingContext2D, layer: TextLayer) {
}
}
+ if (style.textShadow?.enabled) {
+ ctx.shadowColor = style.textShadow.color;
+ ctx.shadowBlur = style.textShadow.blur;
+ ctx.shadowOffsetX = style.textShadow.offsetX;
+ ctx.shadowOffsetY = style.textShadow.offsetY;
+ }
+
lines.forEach((line, i) => {
const y = i * lineHeight;
@@ -718,6 +758,13 @@ function renderTextLayer(ctx: CanvasRenderingContext2D, layer: TextLayer) {
ctx.fillStyle = fillStyle;
ctx.fillText(line, textX, y);
});
+
+ if (style.textShadow?.enabled) {
+ ctx.shadowColor = 'transparent';
+ ctx.shadowBlur = 0;
+ ctx.shadowOffsetX = 0;
+ ctx.shadowOffsetY = 0;
+ }
}
function renderShapeLayer(ctx: CanvasRenderingContext2D, layer: ShapeLayer) {
@@ -727,22 +774,39 @@ function renderShapeLayer(ctx: CanvasRenderingContext2D, layer: ShapeLayer) {
ctx.beginPath();
switch (shapeType) {
- case 'rectangle':
- if (shapeStyle.cornerRadius > 0) {
+ case 'rectangle': {
+ let tl = 0, tr = 0, br = 0, bl = 0;
+
+ if (shapeStyle.individualCorners && shapeStyle.corners) {
+ tl = Math.min(shapeStyle.corners.topLeft, width / 2, height / 2);
+ tr = Math.min(shapeStyle.corners.topRight, width / 2, height / 2);
+ br = Math.min(shapeStyle.corners.bottomRight, width / 2, height / 2);
+ bl = Math.min(shapeStyle.corners.bottomLeft, width / 2, height / 2);
+ } else if (shapeStyle.cornerRadius > 0) {
const r = Math.min(shapeStyle.cornerRadius, width / 2, height / 2);
- ctx.moveTo(r, 0);
- ctx.lineTo(width - r, 0);
- ctx.quadraticCurveTo(width, 0, width, r);
- ctx.lineTo(width, height - r);
- ctx.quadraticCurveTo(width, height, width - r, height);
- ctx.lineTo(r, height);
- ctx.quadraticCurveTo(0, height, 0, height - r);
- ctx.lineTo(0, r);
- ctx.quadraticCurveTo(0, 0, r, 0);
+ tl = tr = br = bl = r;
+ }
+
+ if (tl > 0 || tr > 0 || br > 0 || bl > 0) {
+ ctx.moveTo(tl, 0);
+ ctx.lineTo(width - tr, 0);
+ if (tr > 0) ctx.quadraticCurveTo(width, 0, width, tr);
+ else ctx.lineTo(width, 0);
+ ctx.lineTo(width, height - br);
+ if (br > 0) ctx.quadraticCurveTo(width, height, width - br, height);
+ else ctx.lineTo(width, height);
+ ctx.lineTo(bl, height);
+ if (bl > 0) ctx.quadraticCurveTo(0, height, 0, height - bl);
+ else ctx.lineTo(0, height);
+ ctx.lineTo(0, tl);
+ if (tl > 0) ctx.quadraticCurveTo(0, 0, tl, 0);
+ else ctx.lineTo(0, 0);
+ ctx.closePath();
} else {
ctx.rect(0, 0, width, height);
}
break;
+ }
case 'ellipse':
ctx.ellipse(width / 2, height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);
diff --git a/apps/image/src/components/editor/inspector/ColorHarmonySection.tsx b/apps/image/src/components/editor/inspector/ColorHarmonySection.tsx
index 114e14c8..93bdc2fa 100644
--- a/apps/image/src/components/editor/inspector/ColorHarmonySection.tsx
+++ b/apps/image/src/components/editor/inspector/ColorHarmonySection.tsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { getAllHarmonies, type HarmonyType } from '../../../utils/color-harmony';
import { Palette, Copy, Check } from 'lucide-react';
+import { ColorPalettes, QuickColorSwatches } from '../../ui/ColorPalettes';
interface Props {
baseColor: string;
@@ -81,6 +82,13 @@ export function ColorHarmonySection({ baseColor, onColorSelect }: Props) {
Click a color to apply, or copy its hex code
</p>
</div>
+
+ {onColorSelect && (
+ <>
+ <QuickColorSwatches onColorSelect={onColorSelect} selectedColor={baseColor} />
+ <ColorPalettes onColorSelect={onColorSelect} selectedColor={baseColor} />
+ </>
+ )}
</div>
);
}
diff --git a/apps/image/src/components/editor/inspector/ShapeSection.tsx b/apps/image/src/components/editor/inspector/ShapeSection.tsx
index bb3ac769..0808637a 100644
--- a/apps/image/src/components/editor/inspector/ShapeSection.tsx
+++ b/apps/image/src/components/editor/inspector/ShapeSection.tsx
@@ -4,7 +4,7 @@ import type { ShapeLayer, ShapeStyle, Gradient, FillType, StrokeDashType } from
import { Slider } from '@openreel/ui';
import { GradientPicker } from '../../ui/GradientPicker';
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@openreel/ui';
-import { ChevronDown } from 'lucide-react';
+import { ChevronDown, Link, Unlink } from 'lucide-react';
const DASH_PATTERNS: { value: StrokeDashType; label: string; preview: string }[] = [
{ value: 'solid', label: 'Solid', preview: '━━━━━━' },
@@ -261,18 +261,122 @@ export function ShapeSection({ layer }: Props) {
</Collapsible>
{layer.shapeType === 'rectangle' && (
- <div className="p-3 space-y-2 bg-secondary/50 rounded-lg">
- <div className="flex items-center justify-between mb-1">
- <label className="text-[10px] text-muted-foreground">Corner Radius</label>
- <span className="text-[10px] text-muted-foreground">{layer.shapeStyle.cornerRadius}px</span>
+ <div className="p-3 space-y-3 bg-secondary/50 rounded-lg">
+ <div className="flex items-center justify-between">
+ <label className="text-xs font-medium">Corner Radius</label>
+ <button
+ onClick={() => {
+ const currentRadius = layer.shapeStyle.cornerRadius;
+ handleStyleChange({
+ individualCorners: !layer.shapeStyle.individualCorners,
+ corners: layer.shapeStyle.individualCorners
+ ? layer.shapeStyle.corners
+ : {
+ topLeft: currentRadius,
+ topRight: currentRadius,
+ bottomRight: currentRadius,
+ bottomLeft: currentRadius,
+ },
+ });
+ }}
+ className={`flex items-center gap-1 px-2 py-1 text-[10px] rounded-md transition-colors ${
+ layer.shapeStyle.individualCorners
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title={layer.shapeStyle.individualCorners ? 'Link corners' : 'Unlink corners'}
+ >
+ {layer.shapeStyle.individualCorners ? <Unlink size={12} /> : <Link size={12} />}
+ {layer.shapeStyle.individualCorners ? 'Individual' : 'Uniform'}
+ </button>
</div>
- <Slider
- value={[layer.shapeStyle.cornerRadius]}
- onValueChange={([radius]) => handleStyleChange({ cornerRadius: radius })}
- min={0}
- max={100}
- step={1}
- />
+
+ {!layer.shapeStyle.individualCorners ? (
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <label className="text-[10px] text-muted-foreground">All Corners</label>
+ <span className="text-[10px] text-muted-foreground">{layer.shapeStyle.cornerRadius}px</span>
+ </div>
+ <Slider
+ value={[layer.shapeStyle.cornerRadius]}
+ onValueChange={([radius]) => handleStyleChange({ cornerRadius: radius })}
+ min={0}
+ max={100}
+ step={1}
+ />
+ </div>
+ ) : (
+ <div className="grid grid-cols-2 gap-3">
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <label className="text-[10px] text-muted-foreground">Top Left</label>
+ <span className="text-[10px] text-muted-foreground">{layer.shapeStyle.corners?.topLeft ?? 0}px</span>
+ </div>
+ <Slider
+ value={[layer.shapeStyle.corners?.topLeft ?? 0]}
+ onValueChange={([radius]) =>
+ handleStyleChange({
+ corners: { ...(layer.shapeStyle.corners ?? { topLeft: 0, topRight: 0, bottomRight: 0, bottomLeft: 0 }), topLeft: radius },
+ })
+ }
+ min={0}
+ max={100}
+ step={1}
+ />
+ </div>
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <label className="text-[10px] text-muted-foreground">Top Right</label>
+ <span className="text-[10px] text-muted-foreground">{layer.shapeStyle.corners?.topRight ?? 0}px</span>
+ </div>
+ <Slider
+ value={[layer.shapeStyle.corners?.topRight ?? 0]}
+ onValueChange={([radius]) =>
+ handleStyleChange({
+ corners: { ...(layer.shapeStyle.corners ?? { topLeft: 0, topRight: 0, bottomRight: 0, bottomLeft: 0 }), topRight: radius },
+ })
+ }
+ min={0}
+ max={100}
+ step={1}
+ />
+ </div>
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <label className="text-[10px] text-muted-foreground">Bottom Left</label>
+ <span className="text-[10px] text-muted-foreground">{layer.shapeStyle.corners?.bottomLeft ?? 0}px</span>
+ </div>
+ <Slider
+ value={[layer.shapeStyle.corners?.bottomLeft ?? 0]}
+ onValueChange={([radius]) =>
+ handleStyleChange({
+ corners: { ...(layer.shapeStyle.corners ?? { topLeft: 0, topRight: 0, bottomRight: 0, bottomLeft: 0 }), bottomLeft: radius },
+ })
+ }
+ min={0}
+ max={100}
+ step={1}
+ />
+ </div>
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <label className="text-[10px] text-muted-foreground">Bottom Right</label>
+ <span className="text-[10px] text-muted-foreground">{layer.shapeStyle.corners?.bottomRight ?? 0}px</span>
+ </div>
+ <Slider
+ value={[layer.shapeStyle.corners?.bottomRight ?? 0]}
+ onValueChange={([radius]) =>
+ handleStyleChange({
+ corners: { ...(layer.shapeStyle.corners ?? { topLeft: 0, topRight: 0, bottomRight: 0, bottomLeft: 0 }), bottomRight: radius },
+ })
+ }
+ min={0}
+ max={100}
+ step={1}
+ />
+ </div>
+ </div>
+ )}
</div>
)}
diff --git a/apps/image/src/components/editor/inspector/TextSection.tsx b/apps/image/src/components/editor/inspector/TextSection.tsx
index d0e99731..280e8a29 100644
--- a/apps/image/src/components/editor/inspector/TextSection.tsx
+++ b/apps/image/src/components/editor/inspector/TextSection.tsx
@@ -3,7 +3,7 @@ import type { TextLayer, TextStyle, TextFillType, Gradient } from '../../../type
import { AlignLeft, AlignCenter, AlignRight, Bold, Italic, Underline, CaseUpper, CaseLower, CaseSensitive, Strikethrough } from 'lucide-react';
import { FontPicker } from '../../ui/FontPicker';
import { GradientPicker } from '../../ui/GradientPicker';
-import { Slider } from '@openreel/ui';
+import { Slider, Switch } from '@openreel/ui';
interface Props {
layer: TextLayer;
@@ -418,6 +418,107 @@ export function TextSection({ layer }: Props) {
</div>
)}
</div>
+
+ <div className="space-y-2 p-3 bg-secondary/50 rounded-lg">
+ <div className="flex items-center justify-between">
+ <label className="text-xs font-medium">Text Shadow</label>
+ <Switch
+ checked={layer.style.textShadow?.enabled ?? false}
+ onCheckedChange={(enabled) =>
+ handleStyleChange({
+ textShadow: {
+ ...(layer.style.textShadow ?? { enabled: false, color: 'rgba(0, 0, 0, 0.5)', blur: 4, offsetX: 0, offsetY: 2 }),
+ enabled,
+ },
+ })
+ }
+ />
+ </div>
+ {layer.style.textShadow?.enabled && (
+ <div className="space-y-3">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1.5">Color</label>
+ <div className="flex items-center gap-2">
+ <input
+ type="color"
+ value={layer.style.textShadow.color.startsWith('rgba') ? '#000000' : layer.style.textShadow.color}
+ onChange={(e) =>
+ handleStyleChange({
+ textShadow: { ...layer.style.textShadow, color: e.target.value },
+ })
+ }
+ className="w-8 h-8 rounded border border-input cursor-pointer"
+ />
+ <input
+ type="text"
+ value={layer.style.textShadow.color}
+ onChange={(e) =>
+ handleStyleChange({
+ textShadow: { ...layer.style.textShadow, color: e.target.value },
+ })
+ }
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary font-mono"
+ />
+ </div>
+ </div>
+
+ <div>
+ <div className="flex items-center justify-between mb-1.5">
+ <label className="text-[10px] text-muted-foreground">Blur</label>
+ <span className="text-[10px] text-muted-foreground">{layer.style.textShadow.blur}px</span>
+ </div>
+ <Slider
+ value={[layer.style.textShadow.blur]}
+ onValueChange={([blur]) =>
+ handleStyleChange({
+ textShadow: { ...layer.style.textShadow, blur },
+ })
+ }
+ min={0}
+ max={50}
+ step={1}
+ />
+ </div>
+
+ <div className="grid grid-cols-2 gap-3">
+ <div>
+ <div className="flex items-center justify-between mb-1.5">
+ <label className="text-[10px] text-muted-foreground">Offset X</label>
+ <span className="text-[10px] text-muted-foreground">{layer.style.textShadow.offsetX}px</span>
+ </div>
+ <Slider
+ value={[layer.style.textShadow.offsetX]}
+ onValueChange={([offsetX]) =>
+ handleStyleChange({
+ textShadow: { ...layer.style.textShadow, offsetX },
+ })
+ }
+ min={-30}
+ max={30}
+ step={1}
+ />
+ </div>
+ <div>
+ <div className="flex items-center justify-between mb-1.5">
+ <label className="text-[10px] text-muted-foreground">Offset Y</label>
+ <span className="text-[10px] text-muted-foreground">{layer.style.textShadow.offsetY}px</span>
+ </div>
+ <Slider
+ value={[layer.style.textShadow.offsetY]}
+ onValueChange={([offsetY]) =>
+ handleStyleChange({
+ textShadow: { ...layer.style.textShadow, offsetY },
+ })
+ }
+ min={-30}
+ max={30}
+ step={1}
+ />
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
</div>
);
}
diff --git a/apps/image/src/components/ui/ColorPalettes.tsx b/apps/image/src/components/ui/ColorPalettes.tsx
new file mode 100644
index 00000000..6a5e7b49
--- /dev/null
+++ b/apps/image/src/components/ui/ColorPalettes.tsx
@@ -0,0 +1,169 @@
+import { useState } from 'react';
+import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@openreel/ui';
+import { ChevronDown, Palette } from 'lucide-react';
+
+export interface ColorPalette {
+ id: string;
+ name: string;
+ colors: string[];
+}
+
+export const PRESET_PALETTES: ColorPalette[] = [
+ {
+ id: 'modern-minimal',
+ name: 'Modern Minimal',
+ colors: ['#ffffff', '#f5f5f5', '#d4d4d4', '#737373', '#262626', '#000000'],
+ },
+ {
+ id: 'ocean-breeze',
+ name: 'Ocean Breeze',
+ colors: ['#0ea5e9', '#38bdf8', '#7dd3fc', '#bae6fd', '#e0f2fe', '#f0f9ff'],
+ },
+ {
+ id: 'sunset-glow',
+ name: 'Sunset Glow',
+ colors: ['#dc2626', '#f97316', '#facc15', '#fde047', '#fef08a', '#fefce8'],
+ },
+ {
+ id: 'forest-green',
+ name: 'Forest Green',
+ colors: ['#14532d', '#166534', '#22c55e', '#4ade80', '#86efac', '#dcfce7'],
+ },
+ {
+ id: 'royal-purple',
+ name: 'Royal Purple',
+ colors: ['#581c87', '#7c3aed', '#a78bfa', '#c4b5fd', '#ddd6fe', '#f5f3ff'],
+ },
+ {
+ id: 'warm-earth',
+ name: 'Warm Earth',
+ colors: ['#78350f', '#a16207', '#ca8a04', '#facc15', '#fde68a', '#fefce8'],
+ },
+ {
+ id: 'cool-slate',
+ name: 'Cool Slate',
+ colors: ['#1e293b', '#334155', '#475569', '#64748b', '#94a3b8', '#cbd5e1'],
+ },
+ {
+ id: 'rose-garden',
+ name: 'Rose Garden',
+ colors: ['#881337', '#be123c', '#f43f5e', '#fb7185', '#fda4af', '#ffe4e6'],
+ },
+ {
+ id: 'neon-nights',
+ name: 'Neon Nights',
+ colors: ['#0d0d0d', '#7c3aed', '#ec4899', '#22d3ee', '#a3e635', '#fbbf24'],
+ },
+ {
+ id: 'pastel-dreams',
+ name: 'Pastel Dreams',
+ colors: ['#fce7f3', '#dbeafe', '#dcfce7', '#fef3c7', '#f3e8ff', '#ffe4e6'],
+ },
+ {
+ id: 'monochrome-blue',
+ name: 'Monochrome Blue',
+ colors: ['#172554', '#1e3a8a', '#2563eb', '#60a5fa', '#93c5fd', '#dbeafe'],
+ },
+ {
+ id: 'autumn-harvest',
+ name: 'Autumn Harvest',
+ colors: ['#7c2d12', '#c2410c', '#ea580c', '#fb923c', '#fdba74', '#fed7aa'],
+ },
+];
+
+interface ColorPalettesProps {
+ onColorSelect: (color: string) => void;
+ selectedColor?: string;
+}
+
+export function ColorPalettes({ onColorSelect, selectedColor }: ColorPalettesProps) {
+ const [isOpen, setIsOpen] = useState(false);
+ const [expandedPalette, setExpandedPalette] = useState<string | null>(null);
+
+ return (
+ <Collapsible open={isOpen} onOpenChange={setIsOpen}>
+ <CollapsibleTrigger asChild>
+ <button className="w-full flex items-center justify-between p-2 rounded-lg bg-secondary/50 hover:bg-secondary transition-colors">
+ <div className="flex items-center gap-2">
+ <Palette size={14} className="text-muted-foreground" />
+ <span className="text-xs font-medium">Color Palettes</span>
+ </div>
+ <ChevronDown size={14} className={`text-muted-foreground transition-transform ${isOpen ? 'rotate-180' : ''}`} />
+ </button>
+ </CollapsibleTrigger>
+ <CollapsibleContent>
+ <div className="p-2 space-y-2 bg-background/50 rounded-b-lg border border-t-0 border-border max-h-[300px] overflow-y-auto">
+ {PRESET_PALETTES.map((palette) => (
+ <div key={palette.id} className="space-y-1">
+ <button
+ onClick={() => setExpandedPalette(expandedPalette === palette.id ? null : palette.id)}
+ className="w-full flex items-center justify-between px-2 py-1 rounded hover:bg-secondary/50 transition-colors"
+ >
+ <span className="text-[10px] text-muted-foreground">{palette.name}</span>
+ <div className="flex gap-0.5">
+ {palette.colors.slice(0, 6).map((color, i) => (
+ <div
+ key={i}
+ className="w-3 h-3 rounded-sm border border-border/50"
+ style={{ backgroundColor: color }}
+ />
+ ))}
+ </div>
+ </button>
+ {expandedPalette === palette.id && (
+ <div className="grid grid-cols-6 gap-1 px-2 pb-1">
+ {palette.colors.map((color, i) => (
+ <button
+ key={i}
+ onClick={() => onColorSelect(color)}
+ className={`w-full aspect-square rounded border transition-all hover:scale-110 ${
+ selectedColor === color
+ ? 'border-primary ring-2 ring-primary/30'
+ : 'border-border/50 hover:border-border'
+ }`}
+ style={{ backgroundColor: color }}
+ title={color}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+ </CollapsibleContent>
+ </Collapsible>
+ );
+}
+
+interface QuickColorSwatchesProps {
+ onColorSelect: (color: string) => void;
+ selectedColor?: string;
+}
+
+export function QuickColorSwatches({ onColorSelect, selectedColor }: QuickColorSwatchesProps) {
+ const quickColors = [
+ '#000000', '#ffffff', '#ef4444', '#f97316', '#eab308', '#22c55e',
+ '#14b8a6', '#3b82f6', '#8b5cf6', '#ec4899', '#6b7280', '#1f2937',
+ ];
+
+ return (
+ <div className="space-y-1.5">
+ <label className="text-[10px] text-muted-foreground">Quick Colors</label>
+ <div className="grid grid-cols-6 gap-1">
+ {quickColors.map((color) => (
+ <button
+ key={color}
+ onClick={() => onColorSelect(color)}
+ className={`w-full aspect-square rounded border transition-all hover:scale-110 ${
+ selectedColor === color
+ ? 'border-primary ring-2 ring-primary/30'
+ : 'border-border/50 hover:border-border'
+ }`}
+ style={{ backgroundColor: color }}
+ title={color}
+ />
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/image/src/types/project.ts b/apps/image/src/types/project.ts
index 4439faf5..9ec89b57 100644
--- a/apps/image/src/types/project.ts
+++ b/apps/image/src/types/project.ts
@@ -79,6 +79,14 @@ export interface ImageLayer extends BaseLayer {
export type TextFillType = 'solid' | 'gradient';
+export interface TextShadow {
+ enabled: boolean;
+ color: string;
+ blur: number;
+ offsetX: number;
+ offsetY: number;
+}
+
export interface TextStyle {
fontFamily: string;
fontSize: number;
@@ -97,6 +105,7 @@ export interface TextStyle {
backgroundColor: string | null;
backgroundPadding: number;
backgroundRadius: number;
+ textShadow: TextShadow;
}
export interface TextLayer extends BaseLayer {
@@ -123,6 +132,13 @@ export type FillType = 'solid' | 'gradient';
export type StrokeDashType = 'solid' | 'dashed' | 'dotted' | 'dash-dot' | 'long-dash';
+export interface CornerRadius {
+ topLeft: number;
+ topRight: number;
+ bottomRight: number;
+ bottomLeft: number;
+}
+
export interface ShapeStyle {
fillType: FillType;
fill: string | null;
@@ -133,6 +149,8 @@ export interface ShapeStyle {
strokeOpacity: number;
strokeDash: StrokeDashType;
cornerRadius: number;
+ individualCorners: boolean;
+ corners: CornerRadius;
}
export interface ShapeLayer extends BaseLayer {
@@ -280,6 +298,13 @@ export const DEFAULT_TEXT_STYLE: TextStyle = {
backgroundColor: null,
backgroundPadding: 8,
backgroundRadius: 4,
+ textShadow: {
+ enabled: false,
+ color: 'rgba(0, 0, 0, 0.5)',
+ blur: 4,
+ offsetX: 0,
+ offsetY: 2,
+ },
};
export const DEFAULT_SHAPE_STYLE: ShapeStyle = {
@@ -292,6 +317,13 @@ export const DEFAULT_SHAPE_STYLE: ShapeStyle = {
strokeOpacity: 1,
strokeDash: 'solid',
cornerRadius: 0,
+ individualCorners: false,
+ corners: {
+ topLeft: 0,
+ topRight: 0,
+ bottomRight: 0,
+ bottomLeft: 0,
+ },
};
export const CANVAS_PRESETS: { name: string; width: number; height: number; category: string }[] = [