UNPKG

merchi_product_editor

Version:

A React component for editing product images using Fabric.js

38 lines (37 loc) 1.59 kB
import { fabric } from 'fabric'; /** * Adds an editable text object to the canvas * @param canvas - The Fabric.js canvas instance * @param width - The width of the canvas * @param height - The height of the canvas * @param defaultText - Optional default text (defaults to "Text") * @param fontSize - Optional font size (defaults to 24) * @param fontFamily - Optional font family (defaults to Arial) */ export declare const addTextToCanvas: (canvas: fabric.Canvas, width: number, height: number, defaultText?: string, fontSize?: number, fontFamily?: string) => fabric.IText | null; /** * Renders the entire canvas as an image without displaying grid elements * * @param canvas - The Fabric.js canvas instance * @param options - Optional rendering options * @returns A promise that resolves to the dataURL of the canvas without grid */ export declare const renderCanvasWithoutGrid: (canvas: fabric.Canvas, options?: { format?: string; quality?: number; multiplier?: number; backgroundColor?: string | null; }) => Promise<string | null>; /** * Renders an image containing only what's visible inside a clipPath on the canvas * * @param canvas - The Fabric.js canvas instance * @param options - Optional rendering options * @returns A promise that resolves to the dataURL of the contents inside the clipPath, or null if no clipped object is found */ export declare const renderClippedImage: (canvas: fabric.Canvas, options?: { format?: string; quality?: number; multiplier?: number; backgroundColor?: string; }) => Promise<string | null>;