UNPKG

@thi.ng/imago

Version:

JSON & API-based declarative and extensible image processing trees/pipelines

32 lines (31 loc) 616 B
import { coerceColor, computeSize, positionOrGravity } from "../utils.js"; const colorLayerImpl = async (layer, _, ctx) => { const { type: __, bg, gravity, path, pos, ref, size, unit, ...opts } = layer; const layerSize = size ? computeSize(size, ctx.size, ref, unit) : ctx.size; const $pos = positionOrGravity(layerSize, ctx.size, layer); return { input: { create: { width: layerSize[0], height: layerSize[1], channels: 4, background: coerceColor(bg) } }, ...$pos, ...opts }; }; export { colorLayerImpl };