Merge pull request #161 from IBCornelsen/Jens

CAD
This commit is contained in:
Jens Cornelsen
2024-12-09 15:17:52 +01:00
committed by GitHub

View File

@@ -15,7 +15,7 @@ import Widget2 from "#components/Widget.svelte";
</div> </div>
<div class="controls"> <div class="controls">
<button onclick="clearCanvas()">Clear</button> <button onclick="clearCanvas()">Clear</button>
</div> </div>
<canvas id="cadCanvas" width="800" height="600"></canvas> <canvas id="cadCanvas" width="800" height="600"></canvas>
@@ -29,7 +29,7 @@ import Widget2 from "#components/Widget.svelte";
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
const lineLog = document.getElementById('line-log'); const lineLog = document.getElementById('line-log');
const pixelToMeter = 0.01; // Conversion factor: 1 pixel = 0.01 meter const pixelToMeter = 0.01; // Conversion factor: 1 pixel = 0.01 meter
const gridSize = 5; // Size of each grid cell in pixels const gridSize = 10; // Size of each grid cell in pixels (set to 10 for coarser grid)
let startX = null; let startX = null;
let startY = null; let startY = null;
let capturedLines = []; let capturedLines = [];
@@ -110,6 +110,8 @@ import Widget2 from "#components/Widget.svelte";
// Drawing functions // Drawing functions
function drawLine(x1, y1, x2, y2) { function drawLine(x1, y1, x2, y2) {
ctx.beginPath(); ctx.beginPath();
ctx.strokeStyle = "#000000"; // Black color for lines
ctx.lineWidth = 2; // Thicker lines
ctx.moveTo(x1, y1); ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2); ctx.lineTo(x2, y2);
ctx.stroke(); ctx.stroke();