{ "version": 3, "sources": ["../../../../src/lib/ui/components/HTMLCanvas.tsx"], "sourcesContent": ["import { track, useEditor } from '@tldraw/editor'\nimport * as React from 'react'\n\n/** @internal */\nexport const HTMLCanvas = track(function HTMLCanvas() {\n\tconst editor = useEditor()\n\tconst rCanvas = React.useRef(null)\n\n\tconst camera = editor.camera\n\tconst shapes = editor.currentPageShapes\n\tif (rCanvas.current) {\n\t\tconst cvs = rCanvas.current\n\t\tconst ctx = cvs.getContext('2d')!\n\t\tctx.resetTransform()\n\t\tctx.clearRect(0, 0, cvs.width, cvs.height)\n\n\t\tconst path = new Path2D()\n\n\t\tctx.translate(camera.x, camera.y)\n\n\t\tfor (const shape of shapes) {\n\t\t\tconst bounds = editor.getShapePageBounds(shape)!\n\t\t\tpath.rect(bounds.minX, bounds.minY, bounds.width, bounds.height)\n\t\t}\n\n\t\tctx.fillStyle = '#cccccc'\n\t\tctx.fill(path)\n\n\t\t// for (const shape of shapes) {\n\t\t// \tctx.save()\n\t\t// \tconst corners = editor.getPageCorners(shape)\n\t\t// \tcorners.forEach((corner) => dot(ctx, corner.x, corner.y, 'red'))\n\t\t// \tctx.restore()\n\t\t// }\n\t}\n\n\treturn (\n\t\t\n\t)\n})\n\n// function dot(ctx: CanvasRenderingContext2D, x: number, y: number, color = '#000') {\n// \tctx.save()\n// \tctx.beginPath()\n// \tctx.ellipse(x, y, 4, 4, 0, 0, Math.PI * 2)\n// \tctx.fillStyle = color\n// \tctx.fill()\n// \tctx.restore()\n// }\n"], "mappings": "AAqCE;AArCF,SAAS,OAAO,iBAAiB;AACjC,YAAY,WAAW;AAGhB,MAAM,aAAa,MAAM,SAASA,cAAa;AACrD,QAAM,SAAS,UAAU;AACzB,QAAM,UAAU,MAAM,OAA0B,IAAI;AAEpD,QAAM,SAAS,OAAO;AACtB,QAAM,SAAS,OAAO;AACtB,MAAI,QAAQ,SAAS;AACpB,UAAM,MAAM,QAAQ;AACpB,UAAM,MAAM,IAAI,WAAW,IAAI;AAC/B,QAAI,eAAe;AACnB,QAAI,UAAU,GAAG,GAAG,IAAI,OAAO,IAAI,MAAM;AAEzC,UAAM,OAAO,IAAI,OAAO;AAExB,QAAI,UAAU,OAAO,GAAG,OAAO,CAAC;AAEhC,eAAW,SAAS,QAAQ;AAC3B,YAAM,SAAS,OAAO,mBAAmB,KAAK;AAC9C,WAAK,KAAK,OAAO,MAAM,OAAO,MAAM,OAAO,OAAO,OAAO,MAAM;AAAA,IAChE;AAEA,QAAI,YAAY;AAChB,QAAI,KAAK,IAAI;AAAA,EAQd;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAK;AAAA,MACL,OAAO,OAAO,qBAAqB;AAAA,MACnC,QAAQ,OAAO,qBAAqB;AAAA,MACpC,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO;AAAA;AAAA,EACxC;AAEF,CAAC;", "names": ["HTMLCanvas"] }