feat: add first-class text layers
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Rect, Size, Vec2D } from "@core/geometry";
|
||||
import type { InputArtboardId, InputDocument, InputLayer, InputLayerId } from "./read-model";
|
||||
import { measureTextLayer } from "@core/text-layer";
|
||||
|
||||
export type InputViewportState = {
|
||||
center: Vec2D;
|
||||
@@ -90,6 +91,12 @@ function resolveLayerBounds(document: InputDocument, layer: InputLayer): Rect |
|
||||
h: asset.intrinsicSize.h * layer.transform.scale.y,
|
||||
};
|
||||
}
|
||||
case "text": {
|
||||
const size = measureTextLayer(layer);
|
||||
return { x: layer.transform.position.x, y: layer.transform.position.y, w: size.w * layer.transform.scale.x, h: size.h * layer.transform.scale.y };
|
||||
}
|
||||
case "adjustment":
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Rect, Size, Transform } from "@core/geometry";
|
||||
import type { TextStyle } from "@core/text-layer";
|
||||
|
||||
export type InputLayerId = string;
|
||||
export type InputArtboardId = string;
|
||||
@@ -17,6 +18,7 @@ type InputBaseLayer = {
|
||||
export type InputLayer =
|
||||
| (InputBaseLayer & { type: "group"; children: InputLayer[] })
|
||||
| (InputBaseLayer & { type: "adjustment" })
|
||||
| (InputBaseLayer & { type: "text"; content: string; style: TextStyle })
|
||||
| (InputBaseLayer & { type: "image" | "raster"; assetId: string });
|
||||
|
||||
export type InputDocument = {
|
||||
|
||||
Reference in New Issue
Block a user