diff --git a/app/src/components/Properties/Primitives.tsx b/app/src/components/Properties/Primitives.tsx index ae1e060..92c31ea 100644 --- a/app/src/components/Properties/Primitives.tsx +++ b/app/src/components/Properties/Primitives.tsx @@ -9,7 +9,7 @@ import { import { Paint, PaintStyle, PaintStyleType } from "primitives/Paint"; import { FC } from "react"; import { z } from "zod"; -import { AnimatedVec2Properties, ColorProperties } from "./Values"; +import { ColorProperties } from "./Values"; import { PropertiesProps } from "./common"; import { useFontsStore } from "stores/fonts.store"; import { @@ -57,7 +57,7 @@ export const PaintProperties: FC = ({ - + {Object.keys(PaintStyleType.Values).map((paintStyleType) => ( {paintStyleType} ))} diff --git a/app/src/components/Properties/Values.tsx b/app/src/components/Properties/Values.tsx index 5a92a75..13211a7 100644 --- a/app/src/components/Properties/Values.tsx +++ b/app/src/components/Properties/Values.tsx @@ -4,12 +4,19 @@ import { FC } from "react"; import { z } from "zod"; import { produce } from "immer"; import { Interpolation, InterpolationType } from "primitives/Interpolation"; -import { Color } from "primitives/Paint"; +import { Color, PaintStyle, PaintStyleType } from "primitives/Paint"; import { parseCssColor } from "@tempblade/common"; import { rgbToHex } from "utils"; import { SpringInterpolation } from "primitives/Interpolation"; import FloatInput from "components/Inputs/FloatInput"; import { Keyframe } from "primitives/Keyframe"; +import { + Select, + SelectTrigger, + SelectValue, + SelectContent, + SelectItem, +} from "components/Inputs/Select"; const SpringInterpolationProperties: FC< PropertiesProps> @@ -25,22 +32,29 @@ export const InterpolationProperties: FC< - { + if (entity.type !== value) { + const interpolation = { type: value }; + + const parsedInterpolation = Interpolation.parse(interpolation); + + onUpdate(parsedInterpolation); + } }} - value={entity.type} > - {Object.keys(InterpolationType.Values).map((key) => ( - - ))} - + + + + + {Object.keys(InterpolationType.Values).map((interpolationType) => ( + + {interpolationType} + + ))} + + ); }; @@ -129,35 +143,35 @@ export const ColorProperties: FC< > = ({ entity, onUpdate, mode = "Picker" }) => { if (mode === "Picker") { return ( - + if (color) { + draft.value = [...color, 1.0]; + } + }) + ) + } + /> + ); } diff --git a/app/src/drawers/effect-layer.ts b/app/src/drawers/effect-layer.ts new file mode 100644 index 0000000..e69de29 diff --git a/app/src/drawers/effects/blur.ts b/app/src/drawers/effects/blur.ts new file mode 100644 index 0000000..3bd9170 --- /dev/null +++ b/app/src/drawers/effects/blur.ts @@ -0,0 +1,27 @@ +import { Canvas, CanvasKit, Surface } from "canvaskit-wasm"; +import { BlurEffectLayer } from "primitives/Effects"; +import { z } from "zod"; + +export default function applyBlur( + CanvasKit: CanvasKit, + canvas: Canvas, + surface: Surface, + options: z.input +) { + const image = surface.makeImageSnapshot(); + + if (image) { + const blurFilter = CanvasKit.ImageFilter.MakeBlur( + options.amountX, + options.amountY, + CanvasKit.TileMode[options.tileMode], + null + ); + + const paint = new CanvasKit.Paint(); + + paint.setImageFilter(blurFilter); + + canvas.drawImage(image, 0, 0, paint); + } +} diff --git a/app/src/primitives/Effects.ts b/app/src/primitives/Effects.ts new file mode 100644 index 0000000..917958e --- /dev/null +++ b/app/src/primitives/Effects.ts @@ -0,0 +1,19 @@ +import { z } from "zod"; + +export const EffectTypeOptions = ["Blur", "Erode", "Displace"] as const; + +export const TileModeOptions = ["Clamp", "Decal", "Mirror", "Repeat"] as const; + +export const EffectType = z.enum(EffectTypeOptions); +export const TileMode = z.enum(TileModeOptions); + +export const EffectLayer = z.object({ + entityId: z.string().uuid(), +}); + +export const BlurEffectLayer = EffectLayer.extend({ + type: z.literal(EffectType.enum.Blur), + amountX: z.number().min(0), + amountY: z.number().min(0), + tileMode: TileMode, +}); diff --git a/app/src/primitives/Interpolation.ts b/app/src/primitives/Interpolation.ts index 7415441..2a96472 100644 --- a/app/src/primitives/Interpolation.ts +++ b/app/src/primitives/Interpolation.ts @@ -36,13 +36,13 @@ export const LinearInterpolation = z.object({ export const EasingFunctionInterpolation = z.object({ type: z.literal(InterpolationType.Enum.EasingFunction), - easing_function: EasingFunction, + easing_function: EasingFunction.default("CircOut"), }); export const SpringInterpolation = z.object({ - mass: z.number(), - damping: z.number(), - stiffness: z.number(), + mass: z.number().default(1), + damping: z.number().default(15), + stiffness: z.number().default(200), type: z.literal(InterpolationType.Enum.Spring), }); diff --git a/app/src/styles.css b/app/src/styles.css index 3a08b54..5821e81 100644 --- a/app/src/styles.css +++ b/app/src/styles.css @@ -131,7 +131,7 @@ label { } fieldset { - @apply mb-2 flex flex-col items-start w-16; + @apply mb-2 flex flex-col items-start; } :root {