|
| 1 | +import React from "react" |
| 2 | +import { GraphicsObject } from "../lib" |
| 3 | +import InteractiveGraphicsCanvas from "../site/components/InteractiveGraphicsCanvas" |
| 4 | + |
| 5 | +// Example graphics object with different elements and steps |
| 6 | +const steppedGraphics: GraphicsObject = { |
| 7 | + title: "Interactive Canvas Demo with Steps", |
| 8 | + points: [ |
| 9 | + { x: 0, y: 0, label: "Origin", color: "blue", step: 0 }, |
| 10 | + { x: 50, y: 50, label: "Point A", color: "red", step: 1 }, |
| 11 | + { x: -50, y: 20, label: "Point B", color: "green", step: 2 }, |
| 12 | + { x: -20, y: -30, label: "Point C", color: "purple", step: 3 }, |
| 13 | + ], |
| 14 | + lines: [ |
| 15 | + { |
| 16 | + points: [ |
| 17 | + { x: 0, y: 0 }, |
| 18 | + { x: 50, y: 50 }, |
| 19 | + ], |
| 20 | + strokeColor: "gray", |
| 21 | + strokeWidth: 2, |
| 22 | + step: 1, |
| 23 | + }, |
| 24 | + { |
| 25 | + points: [ |
| 26 | + { x: 0, y: 0 }, |
| 27 | + { x: -50, y: 20 }, |
| 28 | + ], |
| 29 | + strokeColor: "green", |
| 30 | + strokeWidth: 2, |
| 31 | + step: 2, |
| 32 | + }, |
| 33 | + { |
| 34 | + points: [ |
| 35 | + { x: 0, y: 0 }, |
| 36 | + { x: -20, y: -30 }, |
| 37 | + ], |
| 38 | + strokeColor: "purple", |
| 39 | + strokeWidth: 2, |
| 40 | + step: 3, |
| 41 | + }, |
| 42 | + ], |
| 43 | + rects: [ |
| 44 | + { |
| 45 | + center: { x: 0, y: 30 }, |
| 46 | + width: 40, |
| 47 | + height: 20, |
| 48 | + fill: "rgba(255, 0, 0, 0.2)", |
| 49 | + stroke: "red", |
| 50 | + step: 1, |
| 51 | + }, |
| 52 | + { |
| 53 | + center: { x: -30, y: 0 }, |
| 54 | + width: 30, |
| 55 | + height: 30, |
| 56 | + fill: "rgba(0, 0, 255, 0.2)", |
| 57 | + stroke: "blue", |
| 58 | + step: 2, |
| 59 | + }, |
| 60 | + ], |
| 61 | + circles: [ |
| 62 | + { |
| 63 | + center: { x: 25, y: 25 }, |
| 64 | + radius: 15, |
| 65 | + fill: "rgba(0, 255, 0, 0.2)", |
| 66 | + stroke: "green", |
| 67 | + step: 1, |
| 68 | + }, |
| 69 | + { |
| 70 | + center: { x: -20, y: -30 }, |
| 71 | + radius: 10, |
| 72 | + fill: "rgba(255, 0, 255, 0.2)", |
| 73 | + stroke: "purple", |
| 74 | + step: 3, |
| 75 | + }, |
| 76 | + ], |
| 77 | + coordinateSystem: "cartesian", |
| 78 | +} |
| 79 | + |
| 80 | +export default function InteractiveGraphicsCanvasFixture() { |
| 81 | + return ( |
| 82 | + <div style={{ display: "flex", flexDirection: "column", gap: "10px" }}> |
| 83 | + <h2>Interactive Graphics Canvas</h2> |
| 84 | + <p>Drag to pan, scroll to zoom</p> |
| 85 | + <p>Use the step controls to visualize the graphics step by step</p> |
| 86 | + <p> |
| 87 | + When dimension tool is enabled, press 'd' key to measure distances and |
| 88 | + coordinates |
| 89 | + </p> |
| 90 | + |
| 91 | + <InteractiveGraphicsCanvas |
| 92 | + graphics={steppedGraphics} |
| 93 | + height={500} |
| 94 | + showGrid={true} |
| 95 | + /> |
| 96 | + </div> |
| 97 | + ) |
| 98 | +} |
0 commit comments