@tldraw/editor
Version:
tldraw infinite canvas SDK (editor).
8 lines (7 loc) • 2.05 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../../src/lib/editor/shapes/BaseBoxShapeUtil.tsx"],
"sourcesContent": ["import { TLBaseShape } from '@tldraw/tlschema'\nimport { lerp } from '@tldraw/utils'\nimport { Geometry2d } from '../../primitives/geometry/Geometry2d'\nimport { Rectangle2d } from '../../primitives/geometry/Rectangle2d'\nimport { HandleSnapGeometry } from '../managers/SnapManager/HandleSnaps'\nimport { ShapeUtil, TLResizeInfo } from './ShapeUtil'\nimport { resizeBox } from './shared/resizeBox'\n\n/** @public */\nexport type TLBaseBoxShape = TLBaseShape<string, { w: number; h: number }>\n\n/** @public */\nexport abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> extends ShapeUtil<Shape> {\n\tgetGeometry(shape: Shape): Geometry2d {\n\t\treturn new Rectangle2d({\n\t\t\twidth: shape.props.w,\n\t\t\theight: shape.props.h,\n\t\t\tisFilled: true,\n\t\t})\n\t}\n\n\toverride onResize(shape: any, info: TLResizeInfo<any>) {\n\t\treturn resizeBox(shape, info)\n\t}\n\n\toverride getHandleSnapGeometry(shape: Shape): HandleSnapGeometry {\n\t\treturn {\n\t\t\tpoints: this.getGeometry(shape).bounds.cornersAndCenter,\n\t\t}\n\t}\n\n\toverride getInterpolatedProps(startShape: Shape, endShape: Shape, t: number): Shape['props'] {\n\t\treturn {\n\t\t\t...endShape.props,\n\t\t\tw: lerp(startShape.props.w, endShape.props.w, t),\n\t\t\th: lerp(startShape.props.h, endShape.props.h, t),\n\t\t}\n\t}\n}\n"],
"mappings": "AACA,SAAS,YAAY;AAErB,SAAS,mBAAmB;AAE5B,SAAS,iBAA+B;AACxC,SAAS,iBAAiB;AAMnB,MAAe,yBAAuD,UAAiB;AAAA,EAC7F,YAAY,OAA0B;AACrC,WAAO,IAAI,YAAY;AAAA,MACtB,OAAO,MAAM,MAAM;AAAA,MACnB,QAAQ,MAAM,MAAM;AAAA,MACpB,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EAES,SAAS,OAAY,MAAyB;AACtD,WAAO,UAAU,OAAO,IAAI;AAAA,EAC7B;AAAA,EAES,sBAAsB,OAAkC;AAChE,WAAO;AAAA,MACN,QAAQ,KAAK,YAAY,KAAK,EAAE,OAAO;AAAA,IACxC;AAAA,EACD;AAAA,EAES,qBAAqB,YAAmB,UAAiB,GAA2B;AAC5F,WAAO;AAAA,MACN,GAAG,SAAS;AAAA,MACZ,GAAG,KAAK,WAAW,MAAM,GAAG,SAAS,MAAM,GAAG,CAAC;AAAA,MAC/C,GAAG,KAAK,WAAW,MAAM,GAAG,SAAS,MAAM,GAAG,CAAC;AAAA,IAChD;AAAA,EACD;AACD;",
"names": []
}