docs(canvas): explain legacy resources and geometry ownership
This commit is contained in:
@@ -46,10 +46,12 @@ export function resizeFromPointer(node: CanvasNode, direction: ResizeDirection,
|
||||
const rotation = node.data.rotation || 0;
|
||||
// 指针位移先消除节点旋转,才能区分拖动的是本地宽还是高。
|
||||
const local = rotateVector(delta, -rotation);
|
||||
// delta 是手势起点到当前的场景位移,屏幕缩放换算需由调用者提前完成。
|
||||
const horizontal = direction.includes("left") ? -1 : direction.includes("right") ? 1 : 0;
|
||||
const vertical = direction.includes("top") ? -1 : direction.includes("bottom") ? 1 : 0;
|
||||
const plain = node.data.kind === "plain-text";
|
||||
const icon = node.data.kind === "icon" || node.data.kind === "plain-image";
|
||||
// viewScale 只用于尺寸约束;此处不校验正有限值,0 会按 || 回退成1。
|
||||
const viewScale = node.data.viewScale || 1;
|
||||
// 约束随显示viewScale缩放;frame可更大,普通卡片/文字/图标最小尺寸各有不同。
|
||||
const maximum = node.data.kind === "frame" ? 100000 * viewScale : 3000 * viewScale;
|
||||
@@ -84,6 +86,7 @@ export type Connector = { point: XYPosition; normal: XYPosition };
|
||||
export function nodeConnector(node: CanvasNode, side: ConnectorSide): Connector {
|
||||
const { width, height } = nodeSize(node);
|
||||
const vectors = { top: { x: 0, y: -1 }, right: { x: 1, y: 0 }, bottom: { x: 0, y: 1 }, left: { x: -1, y: 0 } };
|
||||
// side 由联合类型限制,不在运行时回退未知端口;这里的法线假设为四个单位轴向量。
|
||||
const local = vectors[side];
|
||||
const angle = node.data.rotation || 0;
|
||||
const normal = rotateVector(local, angle);
|
||||
|
||||
Reference in New Issue
Block a user