mirror of
https://github.com/igorski/bitmappery.git
synced 2026-06-17 03:34:56 +02:00
92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
/**
|
|
* The MIT License (MIT)
|
|
*
|
|
* Igor Zinken 2020-2023 - https://www.igorski.nl
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
* the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
* subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
import type { Point } from "zcanvas";
|
|
import type { BlendModes } from "./blend-modes";
|
|
import type { LayerTypes } from "./layer-types";
|
|
|
|
export type Layer = {
|
|
id: string;
|
|
name: string;
|
|
type: LayerTypes;
|
|
left: number;
|
|
top: number;
|
|
maskX: number;
|
|
maskY: number;
|
|
width: number;
|
|
height: number;
|
|
visible: boolean;
|
|
transparent: boolean;
|
|
source?: HTMLCanvasElement;
|
|
mask?: HTMLCanvasElement;
|
|
effects: Effects;
|
|
filters: Filters;
|
|
text: Text;
|
|
};
|
|
|
|
export type Effects = {
|
|
scale: number;
|
|
rotation: number;
|
|
mirrorX: boolean;
|
|
mirrorY: boolean;
|
|
};
|
|
|
|
export type Filters = {
|
|
enabled: boolean;
|
|
blendMode: BlendModes;
|
|
opacity: number;
|
|
gamma: number;
|
|
brightness: number;
|
|
contrast: number;
|
|
vibrance: number;
|
|
threshold: number;
|
|
desaturate: boolean;
|
|
};
|
|
|
|
export type Text = {
|
|
value: string;
|
|
font: string;
|
|
size: number;
|
|
unit: string;
|
|
lineHeight: number;
|
|
spacing: number;
|
|
color: string;
|
|
};
|
|
|
|
// a shape is a list of Points (describing coordinates within a polygon)
|
|
export type Shape = Point[];
|
|
|
|
// selections can consist of multiple non-connecting Shapes
|
|
export type Selection = Shape[];
|
|
|
|
export type Document = {
|
|
id: string;
|
|
name: string;
|
|
layers: Layer[];
|
|
width: number;
|
|
height: number;
|
|
selections: Record<string, Selection>,
|
|
// the below are only used at runtime, will not be serialized
|
|
activeSelection: Selection;
|
|
invertSelection: boolean;
|
|
};
|