diff --git a/components/svg/SVGObjectRenderer.tsx b/components/svg/SVGObjectRenderer.tsx index e100c40c..2bfaa236 100644 --- a/components/svg/SVGObjectRenderer.tsx +++ b/components/svg/SVGObjectRenderer.tsx @@ -1,38 +1,69 @@ import { SVGObject } from "@/lib/util/types"; +import { randomUUID } from "crypto"; export default function SVGObjectRenderer({ objects }: SVGObjectRenderer) { return ( <> {[...objects] .sort((a, b) => a.zIndex - b.zIndex) - .map((object, i) => ( - - {(object.type === "circle" && ( - - )) - || (object.type === "rect" && ( - - )) - || (object.type === "image" && ) - || (object.type === "react" && object.url)} - - ))} + .map((object, i) => { + let r: number | undefined; + let g: number | undefined; + let b: number | undefined; + let filterURL: string | undefined; + const tint = object.tint; + if (tint) { + r = ((tint & 0xff0000) >> 16) / 255; + g = ((tint & 0x00ff00) >> 8) / 255; + b = (tint & 0x0000ff) / 255; + console.log(r, g, b); + filterURL = randomUUID(); + } + return ( + <> + {tint && ( + + + + )} + + {(object.type === "circle" && ( + + )) + || (object.type === "rect" && ( + + )) + || (object.type === "image" && ) + || (object.type === "react" && object.url)} + + + ); + })} ); } diff --git a/lib/util/types.ts b/lib/util/types.ts index 8e4cf321..1a3c538a 100644 --- a/lib/util/types.ts +++ b/lib/util/types.ts @@ -71,6 +71,7 @@ export type SVGItem = { scaleY?: number rotation?: number origin?: string + tint?: number zIndex: number };