import React from "react";
import { BBox } from "../vendor/bezier-js";
import { getBoundingBoxSize } from "./bounding-box";
import * as colors from "./colors";
import { AttachmentPoint, iterAttachmentPoints, Specs } from "./specs";
const ATTACHMENT_POINT_RADIUS = 20;
const ATTACHMENT_POINT_NORMAL_LENGTH = 50;
const ATTACHMENT_POINT_NORMAL_STROKE = 4;
const SPEC_OPACITY = 0.66;
const VisibleAttachmentPoint: React.FC<{
point: AttachmentPoint;
}> = ({ point: ap }) => {
const { x, y } = ap.point;
const x2 = x + ap.normal.x * ATTACHMENT_POINT_NORMAL_LENGTH;
const y2 = y + ap.normal.y * ATTACHMENT_POINT_NORMAL_LENGTH;
const color = colors.ATTACHMENT_POINT_COLORS[ap.type];
return (
);
};
const BoundingBoxes: React.FC<{ fill: string; bboxes: BBox[] }> = (props) => (
<>
{props.bboxes.map((b, i) => {
const [width, height] = getBoundingBoxSize(b);
return (
);
})}
>
);
export const VisibleSpecs: React.FC<{ specs: Specs }> = ({ specs }) => {
return (
<>
{Array.from(iterAttachmentPoints(specs)).map((point, i) => (
))}
{specs.nesting && (
)}
>
);
};