@tscircuit/cli 0.1.1894 → 0.1.1895
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/main.js +598 -302
- package/dist/lib/index.js +2 -2
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -72006,22 +72006,23 @@ import { applyToPoint as applyToPoint82 } from "transformation-matrix";
|
|
|
72006
72006
|
import { applyToPoint as applyToPoint92 } from "transformation-matrix";
|
|
72007
72007
|
import { applyToPoint as applyToPoint102 } from "transformation-matrix";
|
|
72008
72008
|
import { applyToPoint as applyToPoint112 } from "transformation-matrix";
|
|
72009
|
-
import { applyToPoint as
|
|
72010
|
-
import { applyToPoint as applyToPoint122, compose as compose10, rotate as rotate13, translate as translate10 } from "transformation-matrix";
|
|
72011
|
-
import { applyToPoint as applyToPoint132, compose as compose23, rotate as rotate23, translate as translate23 } from "transformation-matrix";
|
|
72012
|
-
import { applyToPoint as applyToPoint142 } from "transformation-matrix";
|
|
72009
|
+
import { applyToPoint as applyToPoint122 } from "transformation-matrix";
|
|
72013
72010
|
import { applyToPoint as applyToPoint162 } from "transformation-matrix";
|
|
72011
|
+
import { applyToPoint as applyToPoint132, compose as compose10, rotate as rotate13, translate as translate10 } from "transformation-matrix";
|
|
72012
|
+
import { applyToPoint as applyToPoint142, compose as compose23, rotate as rotate23, translate as translate23 } from "transformation-matrix";
|
|
72013
|
+
import { applyToPoint as applyToPoint152 } from "transformation-matrix";
|
|
72014
72014
|
import { applyToPoint as applyToPoint172 } from "transformation-matrix";
|
|
72015
72015
|
import { applyToPoint as applyToPoint182 } from "transformation-matrix";
|
|
72016
72016
|
import { applyToPoint as applyToPoint192 } from "transformation-matrix";
|
|
72017
72017
|
import { applyToPoint as applyToPoint202 } from "transformation-matrix";
|
|
72018
|
-
import { applyToPoint as applyToPoint232 } from "transformation-matrix";
|
|
72019
|
-
import { applyToPoint as applyToPoint222 } from "transformation-matrix";
|
|
72020
72018
|
import { applyToPoint as applyToPoint212 } from "transformation-matrix";
|
|
72021
72019
|
import { applyToPoint as applyToPoint242 } from "transformation-matrix";
|
|
72020
|
+
import { applyToPoint as applyToPoint232 } from "transformation-matrix";
|
|
72021
|
+
import { applyToPoint as applyToPoint222 } from "transformation-matrix";
|
|
72022
72022
|
import { applyToPoint as applyToPoint252 } from "transformation-matrix";
|
|
72023
72023
|
import { applyToPoint as applyToPoint262 } from "transformation-matrix";
|
|
72024
72024
|
import { applyToPoint as applyToPoint272 } from "transformation-matrix";
|
|
72025
|
+
import { applyToPoint as applyToPoint282 } from "transformation-matrix";
|
|
72025
72026
|
import { getElementRenderLayers } from "@tscircuit/circuit-json-util";
|
|
72026
72027
|
function drawPath(params2) {
|
|
72027
72028
|
const {
|
|
@@ -72187,41 +72188,20 @@ function drawPcbBoard(params2) {
|
|
|
72187
72188
|
});
|
|
72188
72189
|
}
|
|
72189
72190
|
}
|
|
72190
|
-
function
|
|
72191
|
-
|
|
72192
|
-
|
|
72193
|
-
|
|
72194
|
-
|
|
72195
|
-
|
|
72196
|
-
|
|
72197
|
-
if (
|
|
72198
|
-
return;
|
|
72199
|
-
const [firstX, firstY] = firstPoint;
|
|
72200
|
-
ctx.moveTo(firstX, firstY);
|
|
72201
|
-
for (let i4 = 1;i4 < canvasPoints.length; i4++) {
|
|
72202
|
-
const point9 = canvasPoints[i4];
|
|
72203
|
-
if (!point9)
|
|
72204
|
-
continue;
|
|
72205
|
-
const [x4, y4] = point9;
|
|
72206
|
-
ctx.lineTo(x4, y4);
|
|
72207
|
-
}
|
|
72208
|
-
ctx.closePath();
|
|
72209
|
-
ctx.fillStyle = fill;
|
|
72210
|
-
ctx.fill();
|
|
72211
|
-
}
|
|
72212
|
-
function layerToColor(layer, colorMap2) {
|
|
72213
|
-
return colorMap2.copper[layer] ?? colorMap2.copper.top;
|
|
72214
|
-
}
|
|
72215
|
-
function computeArcFromBulge(startX, startY, endX, endY, bulge) {
|
|
72216
|
-
if (Math.abs(bulge) < 0.0000000001) {
|
|
72191
|
+
function computeArcFromBulge({
|
|
72192
|
+
startX,
|
|
72193
|
+
startY,
|
|
72194
|
+
endX,
|
|
72195
|
+
endY,
|
|
72196
|
+
bulge
|
|
72197
|
+
}) {
|
|
72198
|
+
if (Math.abs(bulge) < 0.0000000001)
|
|
72217
72199
|
return null;
|
|
72218
|
-
}
|
|
72219
72200
|
const chordX = endX - startX;
|
|
72220
72201
|
const chordY = endY - startY;
|
|
72221
72202
|
const chordLength = Math.hypot(chordX, chordY);
|
|
72222
|
-
if (chordLength < 0.0000000001)
|
|
72203
|
+
if (chordLength < 0.0000000001)
|
|
72223
72204
|
return null;
|
|
72224
|
-
}
|
|
72225
72205
|
const sagitta = Math.abs(bulge) * (chordLength / 2);
|
|
72226
72206
|
const halfChord = chordLength / 2;
|
|
72227
72207
|
const radius = (sagitta * sagitta + halfChord * halfChord) / (2 * sagitta);
|
|
@@ -72231,144 +72211,190 @@ function computeArcFromBulge(startX, startY, endX, endY, bulge) {
|
|
|
72231
72211
|
const perpX = -chordY / chordLength;
|
|
72232
72212
|
const perpY = chordX / chordLength;
|
|
72233
72213
|
const sign = bulge > 0 ? -1 : 1;
|
|
72234
|
-
|
|
72235
|
-
|
|
72236
|
-
|
|
72214
|
+
return {
|
|
72215
|
+
centerX: midX + sign * perpX * distToCenter,
|
|
72216
|
+
centerY: midY + sign * perpY * distToCenter,
|
|
72217
|
+
radius
|
|
72218
|
+
};
|
|
72237
72219
|
}
|
|
72238
|
-
function
|
|
72220
|
+
function addArcFromBulgeToPath({
|
|
72221
|
+
ctx,
|
|
72222
|
+
realStartX,
|
|
72223
|
+
realStartY,
|
|
72224
|
+
realEndX,
|
|
72225
|
+
realEndY,
|
|
72226
|
+
bulge,
|
|
72227
|
+
realToCanvasMat
|
|
72228
|
+
}) {
|
|
72239
72229
|
if (Math.abs(bulge) < 0.0000000001) {
|
|
72240
|
-
const [endX, endY] =
|
|
72230
|
+
const [endX, endY] = applyToPoint33(realToCanvasMat, [realEndX, realEndY]);
|
|
72241
72231
|
ctx.lineTo(endX, endY);
|
|
72242
72232
|
return;
|
|
72243
72233
|
}
|
|
72244
|
-
const arc2 = computeArcFromBulge(
|
|
72234
|
+
const arc2 = computeArcFromBulge({
|
|
72235
|
+
startX: realStartX,
|
|
72236
|
+
startY: realStartY,
|
|
72237
|
+
endX: realEndX,
|
|
72238
|
+
endY: realEndY,
|
|
72239
|
+
bulge
|
|
72240
|
+
});
|
|
72245
72241
|
if (!arc2) {
|
|
72246
|
-
const [endX, endY] =
|
|
72242
|
+
const [endX, endY] = applyToPoint33(realToCanvasMat, [realEndX, realEndY]);
|
|
72247
72243
|
ctx.lineTo(endX, endY);
|
|
72248
72244
|
return;
|
|
72249
72245
|
}
|
|
72250
|
-
const [canvasStartX, canvasStartY] =
|
|
72246
|
+
const [canvasStartX, canvasStartY] = applyToPoint33(realToCanvasMat, [
|
|
72251
72247
|
realStartX,
|
|
72252
72248
|
realStartY
|
|
72253
72249
|
]);
|
|
72254
|
-
const [canvasEndX, canvasEndY] =
|
|
72250
|
+
const [canvasEndX, canvasEndY] = applyToPoint33(realToCanvasMat, [
|
|
72255
72251
|
realEndX,
|
|
72256
72252
|
realEndY
|
|
72257
72253
|
]);
|
|
72258
|
-
const [canvasCenterX, canvasCenterY] =
|
|
72254
|
+
const [canvasCenterX, canvasCenterY] = applyToPoint33(realToCanvasMat, [
|
|
72259
72255
|
arc2.centerX,
|
|
72260
72256
|
arc2.centerY
|
|
72261
72257
|
]);
|
|
72262
72258
|
const canvasRadius = Math.hypot(canvasStartX - canvasCenterX, canvasStartY - canvasCenterY);
|
|
72263
72259
|
const startAngle = Math.atan2(canvasStartY - canvasCenterY, canvasStartX - canvasCenterX);
|
|
72264
72260
|
const endAngle = Math.atan2(canvasEndY - canvasCenterY, canvasEndX - canvasCenterX);
|
|
72265
|
-
const
|
|
72266
|
-
const isFlipped =
|
|
72261
|
+
const determinant = realToCanvasMat.a * realToCanvasMat.d - realToCanvasMat.b * realToCanvasMat.c;
|
|
72262
|
+
const isFlipped = determinant < 0;
|
|
72267
72263
|
const counterclockwise = bulge > 0 ? !isFlipped : isFlipped;
|
|
72268
72264
|
ctx.arc(canvasCenterX, canvasCenterY, canvasRadius, startAngle, endAngle, counterclockwise);
|
|
72269
72265
|
}
|
|
72270
|
-
function
|
|
72266
|
+
function addBrepRingToPath({
|
|
72267
|
+
ctx,
|
|
72268
|
+
ring,
|
|
72269
|
+
realToCanvasMat
|
|
72270
|
+
}) {
|
|
72271
72271
|
if (ring.vertices.length < 2)
|
|
72272
72272
|
return;
|
|
72273
72273
|
if (ring.vertices.length === 2) {
|
|
72274
|
-
const v02 = ring.vertices
|
|
72275
|
-
const v12 = ring.vertices[1];
|
|
72274
|
+
const [v02, v12] = ring.vertices;
|
|
72276
72275
|
if (v02 && v12 && Math.abs((v02.bulge ?? 0) - 1) < 0.0000000001 && Math.abs((v12.bulge ?? 0) - 1) < 0.0000000001) {
|
|
72277
|
-
const [x02, y02] =
|
|
72276
|
+
const [x02, y02] = applyToPoint33(realToCanvasMat, [v02.x, v02.y]);
|
|
72278
72277
|
ctx.moveTo(x02, y02);
|
|
72279
|
-
|
|
72280
|
-
|
|
72278
|
+
addArcFromBulgeToPath({
|
|
72279
|
+
ctx,
|
|
72280
|
+
realStartX: v02.x,
|
|
72281
|
+
realStartY: v02.y,
|
|
72282
|
+
realEndX: v12.x,
|
|
72283
|
+
realEndY: v12.y,
|
|
72284
|
+
bulge: 1,
|
|
72285
|
+
realToCanvasMat
|
|
72286
|
+
});
|
|
72287
|
+
addArcFromBulgeToPath({
|
|
72288
|
+
ctx,
|
|
72289
|
+
realStartX: v12.x,
|
|
72290
|
+
realStartY: v12.y,
|
|
72291
|
+
realEndX: v02.x,
|
|
72292
|
+
realEndY: v02.y,
|
|
72293
|
+
bulge: 1,
|
|
72294
|
+
realToCanvasMat
|
|
72295
|
+
});
|
|
72281
72296
|
return;
|
|
72282
72297
|
}
|
|
72283
72298
|
}
|
|
72284
72299
|
const firstVertex = ring.vertices[0];
|
|
72285
72300
|
if (!firstVertex)
|
|
72286
72301
|
return;
|
|
72287
|
-
const [firstX, firstY] =
|
|
72302
|
+
const [firstX, firstY] = applyToPoint33(realToCanvasMat, [
|
|
72288
72303
|
firstVertex.x,
|
|
72289
72304
|
firstVertex.y
|
|
72290
72305
|
]);
|
|
72291
72306
|
ctx.moveTo(firstX, firstY);
|
|
72292
72307
|
for (let i4 = 0;i4 < ring.vertices.length; i4++) {
|
|
72293
72308
|
const currentVertex = ring.vertices[i4];
|
|
72294
|
-
const
|
|
72295
|
-
const nextVertex = ring.vertices[nextIndex];
|
|
72309
|
+
const nextVertex = ring.vertices[(i4 + 1) % ring.vertices.length];
|
|
72296
72310
|
if (!currentVertex || !nextVertex)
|
|
72297
72311
|
continue;
|
|
72298
|
-
|
|
72299
|
-
|
|
72300
|
-
|
|
72301
|
-
|
|
72302
|
-
|
|
72303
|
-
|
|
72304
|
-
|
|
72305
|
-
|
|
72306
|
-
|
|
72307
|
-
}
|
|
72312
|
+
addArcFromBulgeToPath({
|
|
72313
|
+
ctx,
|
|
72314
|
+
realStartX: currentVertex.x,
|
|
72315
|
+
realStartY: currentVertex.y,
|
|
72316
|
+
realEndX: nextVertex.x,
|
|
72317
|
+
realEndY: nextVertex.y,
|
|
72318
|
+
bulge: currentVertex.bulge ?? 0,
|
|
72319
|
+
realToCanvasMat
|
|
72320
|
+
});
|
|
72308
72321
|
}
|
|
72309
72322
|
}
|
|
72310
|
-
function
|
|
72311
|
-
|
|
72312
|
-
|
|
72313
|
-
|
|
72314
|
-
|
|
72315
|
-
ctx.
|
|
72323
|
+
function addBrepShapeToPath({
|
|
72324
|
+
ctx,
|
|
72325
|
+
shape,
|
|
72326
|
+
realToCanvasMat
|
|
72327
|
+
}) {
|
|
72328
|
+
addBrepRingToPath({ ctx, ring: shape.outer_ring, realToCanvasMat });
|
|
72329
|
+
for (const innerRing of shape.inner_rings ?? []) {
|
|
72330
|
+
addBrepRingToPath({ ctx, ring: innerRing, realToCanvasMat });
|
|
72331
|
+
}
|
|
72332
|
+
}
|
|
72333
|
+
function layerToColor(layer, colorMap2) {
|
|
72334
|
+
return colorMap2.copper[layer] ?? colorMap2.copper.top;
|
|
72335
|
+
}
|
|
72336
|
+
function appendPcbCopperPourPath(params2) {
|
|
72337
|
+
const { ctx, pour, realToCanvasMat } = params2;
|
|
72316
72338
|
if (pour.shape === "rect") {
|
|
72317
|
-
const
|
|
72318
|
-
|
|
72319
|
-
|
|
72320
|
-
|
|
72321
|
-
const
|
|
72322
|
-
const
|
|
72323
|
-
|
|
72324
|
-
|
|
72325
|
-
|
|
72339
|
+
const halfWidth = pour.width / 2;
|
|
72340
|
+
const halfHeight = pour.height / 2;
|
|
72341
|
+
const rotation11 = (pour.rotation ?? 0) * Math.PI / 180;
|
|
72342
|
+
const cos2 = Math.cos(rotation11);
|
|
72343
|
+
const sin2 = Math.sin(rotation11);
|
|
72344
|
+
const canvasPoints = [
|
|
72345
|
+
{ x: -halfWidth, y: -halfHeight },
|
|
72346
|
+
{ x: halfWidth, y: -halfHeight },
|
|
72347
|
+
{ x: halfWidth, y: halfHeight },
|
|
72348
|
+
{ x: -halfWidth, y: halfHeight }
|
|
72349
|
+
].map((point9) => applyToPoint43(realToCanvasMat, [
|
|
72350
|
+
pour.center.x + point9.x * cos2 - point9.y * sin2,
|
|
72351
|
+
pour.center.y + point9.x * sin2 + point9.y * cos2
|
|
72352
|
+
]));
|
|
72353
|
+
const firstPoint = canvasPoints[0];
|
|
72354
|
+
if (!firstPoint)
|
|
72355
|
+
return;
|
|
72356
|
+
ctx.moveTo(firstPoint[0], firstPoint[1]);
|
|
72357
|
+
for (let index = 1;index < canvasPoints.length; index++) {
|
|
72358
|
+
const point9 = canvasPoints[index];
|
|
72359
|
+
if (point9)
|
|
72360
|
+
ctx.lineTo(point9[0], point9[1]);
|
|
72326
72361
|
}
|
|
72327
|
-
ctx.
|
|
72328
|
-
ctx.rect(-scaledWidth / 2, -scaledHeight / 2, scaledWidth, scaledHeight);
|
|
72329
|
-
ctx.fillStyle = color;
|
|
72330
|
-
ctx.fill();
|
|
72331
|
-
ctx.restore();
|
|
72362
|
+
ctx.closePath();
|
|
72332
72363
|
return;
|
|
72333
72364
|
}
|
|
72334
72365
|
if (pour.shape === "polygon") {
|
|
72335
|
-
|
|
72336
|
-
|
|
72337
|
-
|
|
72338
|
-
|
|
72339
|
-
|
|
72340
|
-
|
|
72341
|
-
|
|
72342
|
-
|
|
72343
|
-
|
|
72344
|
-
|
|
72345
|
-
|
|
72346
|
-
|
|
72347
|
-
|
|
72348
|
-
|
|
72349
|
-
const [x4, y4] = point9;
|
|
72350
|
-
ctx.lineTo(x4, y4);
|
|
72351
|
-
}
|
|
72352
|
-
ctx.closePath();
|
|
72353
|
-
ctx.fillStyle = color;
|
|
72354
|
-
ctx.fill();
|
|
72366
|
+
const firstPoint = pour.points[0];
|
|
72367
|
+
if (!firstPoint)
|
|
72368
|
+
return;
|
|
72369
|
+
const [firstX, firstY] = applyToPoint43(realToCanvasMat, [
|
|
72370
|
+
firstPoint.x,
|
|
72371
|
+
firstPoint.y
|
|
72372
|
+
]);
|
|
72373
|
+
ctx.moveTo(firstX, firstY);
|
|
72374
|
+
for (let index = 1;index < pour.points.length; index++) {
|
|
72375
|
+
const point9 = pour.points[index];
|
|
72376
|
+
if (!point9)
|
|
72377
|
+
continue;
|
|
72378
|
+
const [x4, y4] = applyToPoint43(realToCanvasMat, [point9.x, point9.y]);
|
|
72379
|
+
ctx.lineTo(x4, y4);
|
|
72355
72380
|
}
|
|
72356
|
-
ctx.
|
|
72381
|
+
ctx.closePath();
|
|
72357
72382
|
return;
|
|
72358
72383
|
}
|
|
72359
|
-
if (pour.shape
|
|
72360
|
-
ctx.beginPath();
|
|
72361
|
-
drawRing(ctx, pour.brep_shape.outer_ring, realToCanvasMat);
|
|
72362
|
-
if (pour.brep_shape.inner_rings) {
|
|
72363
|
-
for (const innerRing of pour.brep_shape.inner_rings) {
|
|
72364
|
-
drawRing(ctx, innerRing, realToCanvasMat);
|
|
72365
|
-
}
|
|
72366
|
-
}
|
|
72367
|
-
ctx.fillStyle = color;
|
|
72368
|
-
ctx.fill("evenodd");
|
|
72369
|
-
ctx.restore();
|
|
72384
|
+
if (pour.shape !== "brep")
|
|
72370
72385
|
return;
|
|
72371
|
-
}
|
|
72386
|
+
addBrepShapeToPath({ ctx, shape: pour.brep_shape, realToCanvasMat });
|
|
72387
|
+
}
|
|
72388
|
+
function drawPcbCopperPour(params2) {
|
|
72389
|
+
const { ctx, pour, realToCanvasMat, colorMap: colorMap2 } = params2;
|
|
72390
|
+
const color = layerToColor(pour.layer, colorMap2);
|
|
72391
|
+
const opacity = 0.5;
|
|
72392
|
+
ctx.save();
|
|
72393
|
+
ctx.globalAlpha = opacity;
|
|
72394
|
+
ctx.beginPath();
|
|
72395
|
+
appendPcbCopperPourPath({ ctx, pour, realToCanvasMat });
|
|
72396
|
+
ctx.fillStyle = color;
|
|
72397
|
+
ctx.fill(pour.shape === "brep" ? "evenodd" : "nonzero");
|
|
72372
72398
|
ctx.restore();
|
|
72373
72399
|
}
|
|
72374
72400
|
function addPolygonToPath(ctx, points) {
|
|
@@ -72785,6 +72811,28 @@ function drawPcbCourtyardRect(params2) {
|
|
|
72785
72811
|
lineJoin: "round"
|
|
72786
72812
|
});
|
|
72787
72813
|
}
|
|
72814
|
+
function drawPolygon(params2) {
|
|
72815
|
+
const { ctx, points, fill, realToCanvasMat } = params2;
|
|
72816
|
+
if (points.length < 3)
|
|
72817
|
+
return;
|
|
72818
|
+
ctx.beginPath();
|
|
72819
|
+
const canvasPoints = points.map((p3) => applyToPoint82(realToCanvasMat, [p3.x, p3.y]));
|
|
72820
|
+
const firstPoint = canvasPoints[0];
|
|
72821
|
+
if (!firstPoint)
|
|
72822
|
+
return;
|
|
72823
|
+
const [firstX, firstY] = firstPoint;
|
|
72824
|
+
ctx.moveTo(firstX, firstY);
|
|
72825
|
+
for (let i4 = 1;i4 < canvasPoints.length; i4++) {
|
|
72826
|
+
const point9 = canvasPoints[i4];
|
|
72827
|
+
if (!point9)
|
|
72828
|
+
continue;
|
|
72829
|
+
const [x4, y4] = point9;
|
|
72830
|
+
ctx.lineTo(x4, y4);
|
|
72831
|
+
}
|
|
72832
|
+
ctx.closePath();
|
|
72833
|
+
ctx.fillStyle = fill;
|
|
72834
|
+
ctx.fill();
|
|
72835
|
+
}
|
|
72788
72836
|
function drawPcbCutout(params2) {
|
|
72789
72837
|
const { ctx, cutout, realToCanvasMat, colorMap: colorMap2 } = params2;
|
|
72790
72838
|
if (cutout.shape === "rect") {
|
|
@@ -72951,11 +72999,11 @@ function drawDimensionLine(params2) {
|
|
|
72951
72999
|
x: (from.x + to3.x) / 2 + offsetVector.x,
|
|
72952
73000
|
y: (from.y + to3.y) / 2 + offsetVector.y
|
|
72953
73001
|
};
|
|
72954
|
-
const [screenFromX, screenFromY] =
|
|
73002
|
+
const [screenFromX, screenFromY] = applyToPoint92(realToCanvasMat, [
|
|
72955
73003
|
fromOffset.x,
|
|
72956
73004
|
fromOffset.y
|
|
72957
73005
|
]);
|
|
72958
|
-
const [screenToX, screenToY] =
|
|
73006
|
+
const [screenToX, screenToY] = applyToPoint92(realToCanvasMat, [
|
|
72959
73007
|
toOffset.x,
|
|
72960
73008
|
toOffset.y
|
|
72961
73009
|
]);
|
|
@@ -73027,8 +73075,8 @@ function drawLine(params2) {
|
|
|
73027
73075
|
realToCanvasMat,
|
|
73028
73076
|
lineCap = "round"
|
|
73029
73077
|
} = params2;
|
|
73030
|
-
const [x12, y12] =
|
|
73031
|
-
const [x22, y22] =
|
|
73078
|
+
const [x12, y12] = applyToPoint102(realToCanvasMat, [start.x, start.y]);
|
|
73079
|
+
const [x22, y22] = applyToPoint102(realToCanvasMat, [end.x, end.y]);
|
|
73032
73080
|
const scaledStrokeWidth = strokeWidth * Math.abs(realToCanvasMat.a);
|
|
73033
73081
|
ctx.beginPath();
|
|
73034
73082
|
ctx.moveTo(x12, y12);
|
|
@@ -73110,7 +73158,7 @@ function drawOval(params2) {
|
|
|
73110
73158
|
realToCanvasMat,
|
|
73111
73159
|
rotation: rotation11 = 0
|
|
73112
73160
|
} = params2;
|
|
73113
|
-
const [cx3, cy3] =
|
|
73161
|
+
const [cx3, cy3] = applyToPoint112(realToCanvasMat, [center2.x, center2.y]);
|
|
73114
73162
|
const scaledRadiusX = radius_x * Math.abs(realToCanvasMat.a);
|
|
73115
73163
|
const scaledRadiusY = radius_y * Math.abs(realToCanvasMat.a);
|
|
73116
73164
|
const scaledStrokeWidth = strokeWidth * Math.abs(realToCanvasMat.a);
|
|
@@ -73144,7 +73192,7 @@ function drawPill(params2) {
|
|
|
73144
73192
|
stroke,
|
|
73145
73193
|
strokeWidth
|
|
73146
73194
|
} = params2;
|
|
73147
|
-
const [cx3, cy3] =
|
|
73195
|
+
const [cx3, cy3] = applyToPoint122(realToCanvasMat, [center2.x, center2.y]);
|
|
73148
73196
|
const scaledWidth = width * Math.abs(realToCanvasMat.a);
|
|
73149
73197
|
const scaledHeight = height * Math.abs(realToCanvasMat.a);
|
|
73150
73198
|
const scaledStrokeWidth = strokeWidth ? strokeWidth * Math.abs(realToCanvasMat.a) : undefined;
|
|
@@ -73291,15 +73339,15 @@ function drawPillPath(params2) {
|
|
|
73291
73339
|
if (width > height) {
|
|
73292
73340
|
const semicircleRadius = height / 2;
|
|
73293
73341
|
const semicircleCenterOffset = (width - height) / 2;
|
|
73294
|
-
const leftSemicircleCenter =
|
|
73342
|
+
const leftSemicircleCenter = applyToPoint132(realToPxTransform, {
|
|
73295
73343
|
x: -semicircleCenterOffset,
|
|
73296
73344
|
y: 0
|
|
73297
73345
|
});
|
|
73298
|
-
const rightSemicircleCenter =
|
|
73346
|
+
const rightSemicircleCenter = applyToPoint132(realToPxTransform, {
|
|
73299
73347
|
x: semicircleCenterOffset,
|
|
73300
73348
|
y: 0
|
|
73301
73349
|
});
|
|
73302
|
-
const startPoint =
|
|
73350
|
+
const startPoint = applyToPoint132(realToPxTransform, {
|
|
73303
73351
|
x: semicircleCenterOffset,
|
|
73304
73352
|
y: -semicircleRadius
|
|
73305
73353
|
});
|
|
@@ -73309,15 +73357,15 @@ function drawPillPath(params2) {
|
|
|
73309
73357
|
} else if (height > width) {
|
|
73310
73358
|
const semicircleRadius = width / 2;
|
|
73311
73359
|
const semicircleCenterOffset = (height - width) / 2;
|
|
73312
|
-
const topSemicircleCenter =
|
|
73360
|
+
const topSemicircleCenter = applyToPoint132(realToPxTransform, {
|
|
73313
73361
|
x: 0,
|
|
73314
73362
|
y: -semicircleCenterOffset
|
|
73315
73363
|
});
|
|
73316
|
-
const bottomSemicircleCenter =
|
|
73364
|
+
const bottomSemicircleCenter = applyToPoint132(realToPxTransform, {
|
|
73317
73365
|
x: 0,
|
|
73318
73366
|
y: semicircleCenterOffset
|
|
73319
73367
|
});
|
|
73320
|
-
const startPoint =
|
|
73368
|
+
const startPoint = applyToPoint132(realToPxTransform, {
|
|
73321
73369
|
x: semicircleRadius,
|
|
73322
73370
|
y: semicircleCenterOffset
|
|
73323
73371
|
});
|
|
@@ -73363,23 +73411,23 @@ function drawRoundedRectPath(params2) {
|
|
|
73363
73411
|
const rectHalfHeight = height / 2;
|
|
73364
73412
|
const rectCornerRadius = Math.min(radius, rectHalfWidth, rectHalfHeight);
|
|
73365
73413
|
if (rectCornerRadius > 0) {
|
|
73366
|
-
const rectTopLeftCorner =
|
|
73414
|
+
const rectTopLeftCorner = applyToPoint142(realToPxTransform, {
|
|
73367
73415
|
x: -rectHalfWidth,
|
|
73368
73416
|
y: -rectHalfHeight
|
|
73369
73417
|
});
|
|
73370
|
-
const rectTopRightCorner =
|
|
73418
|
+
const rectTopRightCorner = applyToPoint142(realToPxTransform, {
|
|
73371
73419
|
x: rectHalfWidth,
|
|
73372
73420
|
y: -rectHalfHeight
|
|
73373
73421
|
});
|
|
73374
|
-
const rectBottomRightCorner =
|
|
73422
|
+
const rectBottomRightCorner = applyToPoint142(realToPxTransform, {
|
|
73375
73423
|
x: rectHalfWidth,
|
|
73376
73424
|
y: rectHalfHeight
|
|
73377
73425
|
});
|
|
73378
|
-
const rectBottomLeftCorner =
|
|
73426
|
+
const rectBottomLeftCorner = applyToPoint142(realToPxTransform, {
|
|
73379
73427
|
x: -rectHalfWidth,
|
|
73380
73428
|
y: rectHalfHeight
|
|
73381
73429
|
});
|
|
73382
|
-
const leftEdgeMidpoint =
|
|
73430
|
+
const leftEdgeMidpoint = applyToPoint142(realToPxTransform, {
|
|
73383
73431
|
x: -rectHalfWidth,
|
|
73384
73432
|
y: 0
|
|
73385
73433
|
});
|
|
@@ -73389,19 +73437,19 @@ function drawRoundedRectPath(params2) {
|
|
|
73389
73437
|
ctx.arcTo(rectBottomRightCorner.x, rectBottomRightCorner.y, rectBottomLeftCorner.x, rectBottomLeftCorner.y, rectCornerRadius);
|
|
73390
73438
|
ctx.arcTo(rectBottomLeftCorner.x, rectBottomLeftCorner.y, rectTopLeftCorner.x, rectTopLeftCorner.y, rectCornerRadius);
|
|
73391
73439
|
} else {
|
|
73392
|
-
const rectTopLeftCorner =
|
|
73440
|
+
const rectTopLeftCorner = applyToPoint142(realToPxTransform, {
|
|
73393
73441
|
x: -rectHalfWidth,
|
|
73394
73442
|
y: -rectHalfHeight
|
|
73395
73443
|
});
|
|
73396
|
-
const rectTopRightCorner =
|
|
73444
|
+
const rectTopRightCorner = applyToPoint142(realToPxTransform, {
|
|
73397
73445
|
x: rectHalfWidth,
|
|
73398
73446
|
y: -rectHalfHeight
|
|
73399
73447
|
});
|
|
73400
|
-
const rectBottomRightCorner =
|
|
73448
|
+
const rectBottomRightCorner = applyToPoint142(realToPxTransform, {
|
|
73401
73449
|
x: rectHalfWidth,
|
|
73402
73450
|
y: rectHalfHeight
|
|
73403
73451
|
});
|
|
73404
|
-
const rectBottomLeftCorner =
|
|
73452
|
+
const rectBottomLeftCorner = applyToPoint142(realToPxTransform, {
|
|
73405
73453
|
x: -rectHalfWidth,
|
|
73406
73454
|
y: rectHalfHeight
|
|
73407
73455
|
});
|
|
@@ -73555,7 +73603,7 @@ function appendDrillCutoutPath(ctx, drillCutout, realToCanvasMat) {
|
|
|
73555
73603
|
}
|
|
73556
73604
|
function appendCirclePath(ctx, params2) {
|
|
73557
73605
|
const { x: x4, y: y4, radius, realToCanvasMat } = params2;
|
|
73558
|
-
const [cx3, cy3] =
|
|
73606
|
+
const [cx3, cy3] = applyToPoint152(realToCanvasMat, [x4, y4]);
|
|
73559
73607
|
const scaledRadius = radius * Math.abs(realToCanvasMat.a);
|
|
73560
73608
|
ctx.moveTo(cx3 + scaledRadius, cy3);
|
|
73561
73609
|
ctx.arc(cx3, cy3, scaledRadius, 0, Math.PI * 2);
|
|
@@ -73563,7 +73611,7 @@ function appendCirclePath(ctx, params2) {
|
|
|
73563
73611
|
}
|
|
73564
73612
|
function appendOvalPath(ctx, params2) {
|
|
73565
73613
|
const { x: x4, y: y4, radiusX, radiusY, rotation: rotation11 = 0, realToCanvasMat } = params2;
|
|
73566
|
-
const [cx3, cy3] =
|
|
73614
|
+
const [cx3, cy3] = applyToPoint152(realToCanvasMat, [x4, y4]);
|
|
73567
73615
|
const scaledRadiusX = radiusX * Math.abs(realToCanvasMat.a);
|
|
73568
73616
|
const scaledRadiusY = radiusY * Math.abs(realToCanvasMat.a);
|
|
73569
73617
|
ctx.save();
|
|
@@ -73586,7 +73634,7 @@ function appendRectPath(ctx, params2) {
|
|
|
73586
73634
|
rotation: rotation11 = 0,
|
|
73587
73635
|
realToCanvasMat
|
|
73588
73636
|
} = params2;
|
|
73589
|
-
const [cx3, cy3] =
|
|
73637
|
+
const [cx3, cy3] = applyToPoint152(realToCanvasMat, [x4, y4]);
|
|
73590
73638
|
const scaledWidth = width * Math.abs(realToCanvasMat.a);
|
|
73591
73639
|
const scaledHeight = height * Math.abs(realToCanvasMat.a);
|
|
73592
73640
|
const scaledRadius = radius * Math.abs(realToCanvasMat.a);
|
|
@@ -73616,7 +73664,7 @@ function appendRectPath(ctx, params2) {
|
|
|
73616
73664
|
}
|
|
73617
73665
|
function appendPillPath(ctx, params2) {
|
|
73618
73666
|
const { x: x4, y: y4, width, height, rotation: rotation11 = 0, realToCanvasMat } = params2;
|
|
73619
|
-
const [cx3, cy3] =
|
|
73667
|
+
const [cx3, cy3] = applyToPoint152(realToCanvasMat, [x4, y4]);
|
|
73620
73668
|
const scaledWidth = width * Math.abs(realToCanvasMat.a);
|
|
73621
73669
|
const scaledHeight = height * Math.abs(realToCanvasMat.a);
|
|
73622
73670
|
ctx.save();
|
|
@@ -73651,7 +73699,7 @@ function appendPolygonPath(ctx, points, realToCanvasMat) {
|
|
|
73651
73699
|
const firstPoint = points[0];
|
|
73652
73700
|
if (!firstPoint)
|
|
73653
73701
|
return;
|
|
73654
|
-
const [firstX, firstY] =
|
|
73702
|
+
const [firstX, firstY] = applyToPoint152(realToCanvasMat, [
|
|
73655
73703
|
firstPoint.x,
|
|
73656
73704
|
firstPoint.y
|
|
73657
73705
|
]);
|
|
@@ -73660,7 +73708,7 @@ function appendPolygonPath(ctx, points, realToCanvasMat) {
|
|
|
73660
73708
|
const point9 = points[i4];
|
|
73661
73709
|
if (!point9)
|
|
73662
73710
|
continue;
|
|
73663
|
-
const [x4, y4] =
|
|
73711
|
+
const [x4, y4] = applyToPoint152(realToCanvasMat, [point9.x, point9.y]);
|
|
73664
73712
|
ctx.lineTo(x4, y4);
|
|
73665
73713
|
}
|
|
73666
73714
|
ctx.closePath();
|
|
@@ -74000,7 +74048,7 @@ function drawPcbKeepout(params2) {
|
|
|
74000
74048
|
const hatchSpacing = 1 * scale22;
|
|
74001
74049
|
const hatchWidth = 0.15 * scale22;
|
|
74002
74050
|
if (keepout.shape === "rect") {
|
|
74003
|
-
const [cx3, cy3] =
|
|
74051
|
+
const [cx3, cy3] = applyToPoint162(realToCanvasMat, [
|
|
74004
74052
|
keepout.center.x,
|
|
74005
74053
|
keepout.center.y
|
|
74006
74054
|
]);
|
|
@@ -74044,7 +74092,7 @@ function drawPcbKeepout(params2) {
|
|
|
74044
74092
|
return;
|
|
74045
74093
|
}
|
|
74046
74094
|
if (keepout.shape === "circle") {
|
|
74047
|
-
const [cx3, cy3] =
|
|
74095
|
+
const [cx3, cy3] = applyToPoint162(realToCanvasMat, [
|
|
74048
74096
|
keepout.center.x,
|
|
74049
74097
|
keepout.center.y
|
|
74050
74098
|
]);
|
|
@@ -74104,8 +74152,8 @@ function drawPcbNoteLine(params2) {
|
|
|
74104
74152
|
const color = line2.color ?? defaultColor;
|
|
74105
74153
|
const strokeWidth = line2.stroke_width ?? 0.1;
|
|
74106
74154
|
const isDashed = line2.is_dashed ?? false;
|
|
74107
|
-
const [x12, y12] =
|
|
74108
|
-
const [x22, y22] =
|
|
74155
|
+
const [x12, y12] = applyToPoint172(realToCanvasMat, [line2.x1, line2.y1]);
|
|
74156
|
+
const [x22, y22] = applyToPoint172(realToCanvasMat, [line2.x2, line2.y2]);
|
|
74109
74157
|
const scaledStrokeWidth = strokeWidth * Math.abs(realToCanvasMat.a);
|
|
74110
74158
|
ctx.save();
|
|
74111
74159
|
if (isDashed) {
|
|
@@ -74565,6 +74613,14 @@ function drawPcbSilkscreenCircle(params2) {
|
|
|
74565
74613
|
realToCanvasMat
|
|
74566
74614
|
});
|
|
74567
74615
|
}
|
|
74616
|
+
function drawPcbSilkscreenGraphic(params2) {
|
|
74617
|
+
const { ctx, graphic, realToCanvasMat, colorMap: colorMap2 } = params2;
|
|
74618
|
+
const color = graphic.layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
74619
|
+
ctx.beginPath();
|
|
74620
|
+
addBrepShapeToPath({ ctx, shape: graphic.brep_shape, realToCanvasMat });
|
|
74621
|
+
ctx.fillStyle = color;
|
|
74622
|
+
ctx.fill("evenodd");
|
|
74623
|
+
}
|
|
74568
74624
|
function layerToSilkscreenColor2(layer, colorMap2) {
|
|
74569
74625
|
return layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
74570
74626
|
}
|
|
@@ -74779,54 +74835,68 @@ function drawPcbSmtPad(params2) {
|
|
|
74779
74835
|
return;
|
|
74780
74836
|
}
|
|
74781
74837
|
}
|
|
74782
|
-
function
|
|
74783
|
-
const { ctx,
|
|
74784
|
-
const {
|
|
74785
|
-
if (
|
|
74786
|
-
|
|
74787
|
-
|
|
74788
|
-
|
|
74838
|
+
function drawPcbSolderPaste(params2) {
|
|
74839
|
+
const { ctx, solderPaste, realToCanvasMat } = params2;
|
|
74840
|
+
const center2 = { x: solderPaste.x, y: solderPaste.y };
|
|
74841
|
+
if (solderPaste.shape === "rect") {
|
|
74842
|
+
drawRect({
|
|
74843
|
+
ctx,
|
|
74844
|
+
center: center2,
|
|
74845
|
+
width: solderPaste.width,
|
|
74846
|
+
height: solderPaste.height,
|
|
74847
|
+
fill: SOLDER_PASTE_COLOR,
|
|
74848
|
+
realToCanvasMat
|
|
74789
74849
|
});
|
|
74790
|
-
ctx.beginPath();
|
|
74791
|
-
drawPolygonPath({ ctx, points: canvasPoints });
|
|
74792
|
-
ctx.fillStyle = soldermaskColor;
|
|
74793
|
-
ctx.fill();
|
|
74794
|
-
} else if (width !== undefined && height !== undefined && center2) {
|
|
74795
|
-
const [cx3, cy3] = applyToPoint182(realToCanvasMat, [center2.x, center2.y]);
|
|
74796
|
-
const scaledWidth = width * Math.abs(realToCanvasMat.a);
|
|
74797
|
-
const scaledHeight = height * Math.abs(realToCanvasMat.a);
|
|
74798
|
-
ctx.fillStyle = soldermaskColor;
|
|
74799
|
-
ctx.fillRect(cx3 - scaledWidth / 2, cy3 - scaledHeight / 2, scaledWidth, scaledHeight);
|
|
74800
|
-
}
|
|
74801
|
-
}
|
|
74802
|
-
function isPatternCapableContext(ctx) {
|
|
74803
|
-
return "createPattern" in ctx && typeof Reflect.get(ctx, "createPattern") === "function";
|
|
74804
|
-
}
|
|
74805
|
-
function mergeSoldermaskLayer(baseCtx, soldermaskCtx) {
|
|
74806
|
-
if (baseCtx === soldermaskCtx)
|
|
74807
|
-
return;
|
|
74808
|
-
if (soldermaskCtx.canvas.width <= 0 || soldermaskCtx.canvas.height <= 0)
|
|
74809
74850
|
return;
|
|
74810
|
-
|
|
74851
|
+
}
|
|
74852
|
+
if (solderPaste.shape === "rotated_rect") {
|
|
74853
|
+
drawRect({
|
|
74854
|
+
ctx,
|
|
74855
|
+
center: center2,
|
|
74856
|
+
width: solderPaste.width,
|
|
74857
|
+
height: solderPaste.height,
|
|
74858
|
+
fill: SOLDER_PASTE_COLOR,
|
|
74859
|
+
realToCanvasMat,
|
|
74860
|
+
ccwRotationDegrees: solderPaste.ccw_rotation
|
|
74861
|
+
});
|
|
74811
74862
|
return;
|
|
74812
|
-
|
|
74813
|
-
|
|
74814
|
-
|
|
74815
|
-
|
|
74863
|
+
}
|
|
74864
|
+
if (solderPaste.shape === "pill") {
|
|
74865
|
+
drawPill({
|
|
74866
|
+
ctx,
|
|
74867
|
+
center: center2,
|
|
74868
|
+
width: solderPaste.width,
|
|
74869
|
+
height: solderPaste.height,
|
|
74870
|
+
fill: SOLDER_PASTE_COLOR,
|
|
74871
|
+
realToCanvasMat
|
|
74872
|
+
});
|
|
74816
74873
|
return;
|
|
74817
74874
|
}
|
|
74818
|
-
if (
|
|
74875
|
+
if (solderPaste.shape === "oval") {
|
|
74876
|
+
drawOval({
|
|
74877
|
+
ctx,
|
|
74878
|
+
center: center2,
|
|
74879
|
+
radius_x: solderPaste.width / 2,
|
|
74880
|
+
radius_y: solderPaste.height / 2,
|
|
74881
|
+
fill: SOLDER_PASTE_COLOR,
|
|
74882
|
+
realToCanvasMat
|
|
74883
|
+
});
|
|
74819
74884
|
return;
|
|
74820
|
-
|
|
74821
|
-
|
|
74822
|
-
|
|
74823
|
-
|
|
74824
|
-
|
|
74885
|
+
}
|
|
74886
|
+
if (solderPaste.shape === "circle") {
|
|
74887
|
+
drawCircle({
|
|
74888
|
+
ctx,
|
|
74889
|
+
center: center2,
|
|
74890
|
+
radius: solderPaste.radius,
|
|
74891
|
+
fill: SOLDER_PASTE_COLOR,
|
|
74892
|
+
realToCanvasMat
|
|
74893
|
+
});
|
|
74894
|
+
}
|
|
74825
74895
|
}
|
|
74826
74896
|
function isCanvasConstructor(value) {
|
|
74827
74897
|
return typeof value === "function";
|
|
74828
74898
|
}
|
|
74829
|
-
function
|
|
74899
|
+
function createDrawingLayerContext(baseCtx, width, height) {
|
|
74830
74900
|
if (width <= 0 || height <= 0)
|
|
74831
74901
|
return null;
|
|
74832
74902
|
const g6 = globalThis;
|
|
@@ -74852,12 +74922,57 @@ function createSoldermaskLayerContext(baseCtx, width, height) {
|
|
|
74852
74922
|
return null;
|
|
74853
74923
|
return layerCanvas.getContext("2d");
|
|
74854
74924
|
}
|
|
74925
|
+
function isPatternCapableContext(ctx) {
|
|
74926
|
+
return "createPattern" in ctx && typeof Reflect.get(ctx, "createPattern") === "function";
|
|
74927
|
+
}
|
|
74928
|
+
function mergeDrawingLayer(baseCtx, layerCtx) {
|
|
74929
|
+
if (baseCtx === layerCtx)
|
|
74930
|
+
return false;
|
|
74931
|
+
if (layerCtx.canvas.width <= 0 || layerCtx.canvas.height <= 0)
|
|
74932
|
+
return false;
|
|
74933
|
+
if (!isPatternCapableContext(baseCtx))
|
|
74934
|
+
return false;
|
|
74935
|
+
let pattern = null;
|
|
74936
|
+
try {
|
|
74937
|
+
pattern = baseCtx.createPattern(layerCtx.canvas, "no-repeat");
|
|
74938
|
+
} catch {
|
|
74939
|
+
return false;
|
|
74940
|
+
}
|
|
74941
|
+
if (!pattern)
|
|
74942
|
+
return false;
|
|
74943
|
+
baseCtx.save();
|
|
74944
|
+
baseCtx.globalCompositeOperation = "source-over";
|
|
74945
|
+
baseCtx.fillStyle = pattern;
|
|
74946
|
+
baseCtx.fillRect(0, 0, layerCtx.canvas.width, layerCtx.canvas.height);
|
|
74947
|
+
baseCtx.restore();
|
|
74948
|
+
return true;
|
|
74949
|
+
}
|
|
74950
|
+
function drawBoardSoldermask(params2) {
|
|
74951
|
+
const { ctx, board, realToCanvasMat, soldermaskColor } = params2;
|
|
74952
|
+
const { width, height, center: center2, outline } = board;
|
|
74953
|
+
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
74954
|
+
const canvasPoints = outline.map((p3) => {
|
|
74955
|
+
const [x4, y4] = applyToPoint192(realToCanvasMat, [p3.x, p3.y]);
|
|
74956
|
+
return { x: x4, y: y4 };
|
|
74957
|
+
});
|
|
74958
|
+
ctx.beginPath();
|
|
74959
|
+
drawPolygonPath({ ctx, points: canvasPoints });
|
|
74960
|
+
ctx.fillStyle = soldermaskColor;
|
|
74961
|
+
ctx.fill();
|
|
74962
|
+
} else if (width !== undefined && height !== undefined && center2) {
|
|
74963
|
+
const [cx3, cy3] = applyToPoint192(realToCanvasMat, [center2.x, center2.y]);
|
|
74964
|
+
const scaledWidth = width * Math.abs(realToCanvasMat.a);
|
|
74965
|
+
const scaledHeight = height * Math.abs(realToCanvasMat.a);
|
|
74966
|
+
ctx.fillStyle = soldermaskColor;
|
|
74967
|
+
ctx.fillRect(cx3 - scaledWidth / 2, cy3 - scaledHeight / 2, scaledWidth, scaledHeight);
|
|
74968
|
+
}
|
|
74969
|
+
}
|
|
74855
74970
|
function drawPanelSoldermask(params2) {
|
|
74856
74971
|
const { ctx, panel, realToCanvasMat, soldermaskColor } = params2;
|
|
74857
74972
|
const { width, height, center: center2 } = panel;
|
|
74858
74973
|
if (width === undefined || height === undefined || !center2)
|
|
74859
74974
|
return;
|
|
74860
|
-
const [cx3, cy3] =
|
|
74975
|
+
const [cx3, cy3] = applyToPoint202(realToCanvasMat, [center2.x, center2.y]);
|
|
74861
74976
|
const scaledWidth = width * Math.abs(realToCanvasMat.a);
|
|
74862
74977
|
const scaledHeight = height * Math.abs(realToCanvasMat.a);
|
|
74863
74978
|
ctx.fillStyle = soldermaskColor;
|
|
@@ -74872,7 +74987,7 @@ function cutPathFromSoldermask(ctx) {
|
|
|
74872
74987
|
function processCutoutSoldermask(params2) {
|
|
74873
74988
|
const { ctx, cutout, realToCanvasMat } = params2;
|
|
74874
74989
|
if (cutout.shape === "rect") {
|
|
74875
|
-
const [cx3, cy3] =
|
|
74990
|
+
const [cx3, cy3] = applyToPoint212(realToCanvasMat, [
|
|
74876
74991
|
cutout.center?.x ?? 0,
|
|
74877
74992
|
cutout.center?.y ?? 0
|
|
74878
74993
|
]);
|
|
@@ -74896,7 +75011,7 @@ function processCutoutSoldermask(params2) {
|
|
|
74896
75011
|
ctx.restore();
|
|
74897
75012
|
cutPathFromSoldermask(ctx);
|
|
74898
75013
|
} else if (cutout.shape === "circle") {
|
|
74899
|
-
const [cx3, cy3] =
|
|
75014
|
+
const [cx3, cy3] = applyToPoint212(realToCanvasMat, [
|
|
74900
75015
|
cutout.center?.x ?? 0,
|
|
74901
75016
|
cutout.center?.y ?? 0
|
|
74902
75017
|
]);
|
|
@@ -74907,7 +75022,7 @@ function processCutoutSoldermask(params2) {
|
|
|
74907
75022
|
cutPathFromSoldermask(ctx);
|
|
74908
75023
|
} else if (cutout.shape === "polygon" && cutout.points && cutout.points.length >= 3) {
|
|
74909
75024
|
const canvasPoints = cutout.points.map((p3) => {
|
|
74910
|
-
const [x4, y4] =
|
|
75025
|
+
const [x4, y4] = applyToPoint212(realToCanvasMat, [p3.x, p3.y]);
|
|
74911
75026
|
return { x: x4, y: y4 };
|
|
74912
75027
|
});
|
|
74913
75028
|
ctx.beginPath();
|
|
@@ -75184,27 +75299,27 @@ function computeArcFromBulge2(startX, startY, endX, endY, bulge) {
|
|
|
75184
75299
|
radius
|
|
75185
75300
|
};
|
|
75186
75301
|
}
|
|
75187
|
-
function
|
|
75302
|
+
function drawArcFromBulge(ctx, realStartX, realStartY, realEndX, realEndY, bulge, realToCanvasMat) {
|
|
75188
75303
|
if (Math.abs(bulge) < 0.0000000001) {
|
|
75189
|
-
const [endX, endY] =
|
|
75304
|
+
const [endX, endY] = applyToPoint222(realToCanvasMat, [realEndX, realEndY]);
|
|
75190
75305
|
ctx.lineTo(endX, endY);
|
|
75191
75306
|
return;
|
|
75192
75307
|
}
|
|
75193
75308
|
const arc2 = computeArcFromBulge2(realStartX, realStartY, realEndX, realEndY, bulge);
|
|
75194
75309
|
if (!arc2) {
|
|
75195
|
-
const [endX, endY] =
|
|
75310
|
+
const [endX, endY] = applyToPoint222(realToCanvasMat, [realEndX, realEndY]);
|
|
75196
75311
|
ctx.lineTo(endX, endY);
|
|
75197
75312
|
return;
|
|
75198
75313
|
}
|
|
75199
|
-
const [canvasStartX, canvasStartY] =
|
|
75314
|
+
const [canvasStartX, canvasStartY] = applyToPoint222(realToCanvasMat, [
|
|
75200
75315
|
realStartX,
|
|
75201
75316
|
realStartY
|
|
75202
75317
|
]);
|
|
75203
|
-
const [canvasEndX, canvasEndY] =
|
|
75318
|
+
const [canvasEndX, canvasEndY] = applyToPoint222(realToCanvasMat, [
|
|
75204
75319
|
realEndX,
|
|
75205
75320
|
realEndY
|
|
75206
75321
|
]);
|
|
75207
|
-
const [canvasCenterX, canvasCenterY] =
|
|
75322
|
+
const [canvasCenterX, canvasCenterY] = applyToPoint222(realToCanvasMat, [
|
|
75208
75323
|
arc2.centerX,
|
|
75209
75324
|
arc2.centerY
|
|
75210
75325
|
]);
|
|
@@ -75216,24 +75331,24 @@ function drawArcFromBulge2(ctx, realStartX, realStartY, realEndX, realEndY, bulg
|
|
|
75216
75331
|
const counterclockwise = bulge > 0 ? !isFlipped : isFlipped;
|
|
75217
75332
|
ctx.arc(canvasCenterX, canvasCenterY, canvasRadius, startAngle, endAngle, counterclockwise);
|
|
75218
75333
|
}
|
|
75219
|
-
function
|
|
75334
|
+
function drawRing(ctx, ring, realToCanvasMat) {
|
|
75220
75335
|
if (ring.vertices.length < 2)
|
|
75221
75336
|
return;
|
|
75222
75337
|
if (ring.vertices.length === 2) {
|
|
75223
75338
|
const v02 = ring.vertices[0];
|
|
75224
75339
|
const v12 = ring.vertices[1];
|
|
75225
75340
|
if (v02 && v12 && Math.abs((v02.bulge ?? 0) - 1) < 0.0000000001 && Math.abs((v12.bulge ?? 0) - 1) < 0.0000000001) {
|
|
75226
|
-
const [x02, y02] =
|
|
75341
|
+
const [x02, y02] = applyToPoint232(realToCanvasMat, [v02.x, v02.y]);
|
|
75227
75342
|
ctx.moveTo(x02, y02);
|
|
75228
|
-
|
|
75229
|
-
|
|
75343
|
+
drawArcFromBulge(ctx, v02.x, v02.y, v12.x, v12.y, 1, realToCanvasMat);
|
|
75344
|
+
drawArcFromBulge(ctx, v12.x, v12.y, v02.x, v02.y, 1, realToCanvasMat);
|
|
75230
75345
|
return;
|
|
75231
75346
|
}
|
|
75232
75347
|
}
|
|
75233
75348
|
const firstVertex = ring.vertices[0];
|
|
75234
75349
|
if (!firstVertex)
|
|
75235
75350
|
return;
|
|
75236
|
-
const [firstX, firstY] =
|
|
75351
|
+
const [firstX, firstY] = applyToPoint232(realToCanvasMat, [
|
|
75237
75352
|
firstVertex.x,
|
|
75238
75353
|
firstVertex.y
|
|
75239
75354
|
]);
|
|
@@ -75245,13 +75360,13 @@ function drawRing2(ctx, ring, realToCanvasMat) {
|
|
|
75245
75360
|
continue;
|
|
75246
75361
|
const bulge = currentVertex.bulge ?? 0;
|
|
75247
75362
|
if (Math.abs(bulge) < 0.0000000001) {
|
|
75248
|
-
const [nextX, nextY] =
|
|
75363
|
+
const [nextX, nextY] = applyToPoint232(realToCanvasMat, [
|
|
75249
75364
|
nextVertex.x,
|
|
75250
75365
|
nextVertex.y
|
|
75251
75366
|
]);
|
|
75252
75367
|
ctx.lineTo(nextX, nextY);
|
|
75253
75368
|
} else {
|
|
75254
|
-
|
|
75369
|
+
drawArcFromBulge(ctx, currentVertex.x, currentVertex.y, nextVertex.x, nextVertex.y, bulge, realToCanvasMat);
|
|
75255
75370
|
}
|
|
75256
75371
|
}
|
|
75257
75372
|
}
|
|
@@ -75271,7 +75386,7 @@ function processCopperPourSoldermask(params2) {
|
|
|
75271
75386
|
ctx.save();
|
|
75272
75387
|
ctx.fillStyle = soldermaskOverCopperColor;
|
|
75273
75388
|
if (pour.shape === "rect") {
|
|
75274
|
-
const [cx3, cy3] =
|
|
75389
|
+
const [cx3, cy3] = applyToPoint242(realToCanvasMat, [
|
|
75275
75390
|
pour.center.x,
|
|
75276
75391
|
pour.center.y
|
|
75277
75392
|
]);
|
|
@@ -75295,7 +75410,7 @@ function processCopperPourSoldermask(params2) {
|
|
|
75295
75410
|
}
|
|
75296
75411
|
if (pour.shape === "polygon") {
|
|
75297
75412
|
if (pour.points && pour.points.length >= 3) {
|
|
75298
|
-
const canvasPoints = pour.points.map((p3) =>
|
|
75413
|
+
const canvasPoints = pour.points.map((p3) => applyToPoint242(realToCanvasMat, [p3.x, p3.y]));
|
|
75299
75414
|
const firstPoint = canvasPoints[0];
|
|
75300
75415
|
if (firstPoint) {
|
|
75301
75416
|
ctx.beginPath();
|
|
@@ -75323,10 +75438,10 @@ function processCopperPourSoldermask(params2) {
|
|
|
75323
75438
|
}
|
|
75324
75439
|
if (pour.shape === "brep") {
|
|
75325
75440
|
ctx.beginPath();
|
|
75326
|
-
|
|
75441
|
+
drawRing(ctx, pour.brep_shape.outer_ring, realToCanvasMat);
|
|
75327
75442
|
if (pour.brep_shape.inner_rings) {
|
|
75328
75443
|
for (const innerRing of pour.brep_shape.inner_rings) {
|
|
75329
|
-
|
|
75444
|
+
drawRing(ctx, innerRing, realToCanvasMat);
|
|
75330
75445
|
}
|
|
75331
75446
|
}
|
|
75332
75447
|
ctx.fill("evenodd");
|
|
@@ -75377,13 +75492,13 @@ function drawHoleShapePath(params2) {
|
|
|
75377
75492
|
const { ctx, hole, realToCanvasMat, margin } = params2;
|
|
75378
75493
|
const rotation11 = getHoleRotation2(hole);
|
|
75379
75494
|
if (hole.hole_shape === "circle") {
|
|
75380
|
-
const [cx3, cy3] =
|
|
75495
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75381
75496
|
const scaledRadius = (hole.hole_diameter / 2 + margin) * Math.abs(realToCanvasMat.a);
|
|
75382
75497
|
ctx.beginPath();
|
|
75383
75498
|
ctx.arc(cx3, cy3, scaledRadius, 0, Math.PI * 2);
|
|
75384
75499
|
ctx.closePath();
|
|
75385
75500
|
} else if (hole.hole_shape === "square") {
|
|
75386
|
-
const [cx3, cy3] =
|
|
75501
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75387
75502
|
const scaledSize = (hole.hole_diameter + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75388
75503
|
ctx.save();
|
|
75389
75504
|
ctx.translate(cx3, cy3);
|
|
@@ -75395,7 +75510,7 @@ function drawHoleShapePath(params2) {
|
|
|
75395
75510
|
ctx.closePath();
|
|
75396
75511
|
ctx.restore();
|
|
75397
75512
|
} else if (hole.hole_shape === "oval") {
|
|
75398
|
-
const [cx3, cy3] =
|
|
75513
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75399
75514
|
const scaledRadiusX = (hole.hole_width / 2 + margin) * Math.abs(realToCanvasMat.a);
|
|
75400
75515
|
const scaledRadiusY = (hole.hole_height / 2 + margin) * Math.abs(realToCanvasMat.a);
|
|
75401
75516
|
ctx.save();
|
|
@@ -75408,7 +75523,7 @@ function drawHoleShapePath(params2) {
|
|
|
75408
75523
|
ctx.closePath();
|
|
75409
75524
|
ctx.restore();
|
|
75410
75525
|
} else if (hole.hole_shape === "rect") {
|
|
75411
|
-
const [cx3, cy3] =
|
|
75526
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75412
75527
|
const scaledWidth = (hole.hole_width + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75413
75528
|
const scaledHeight = (hole.hole_height + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75414
75529
|
ctx.save();
|
|
@@ -75421,7 +75536,7 @@ function drawHoleShapePath(params2) {
|
|
|
75421
75536
|
ctx.closePath();
|
|
75422
75537
|
ctx.restore();
|
|
75423
75538
|
} else if (hole.hole_shape === "pill" || hole.hole_shape === "rotated_pill") {
|
|
75424
|
-
const [cx3, cy3] =
|
|
75539
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75425
75540
|
const scaledWidth = (hole.hole_width + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75426
75541
|
const scaledHeight = (hole.hole_height + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75427
75542
|
ctx.save();
|
|
@@ -75446,7 +75561,7 @@ function drawNegativeMarginRingForHole(params2) {
|
|
|
75446
75561
|
const rotation11 = getHoleRotation2(hole);
|
|
75447
75562
|
ctx.fillStyle = soldermaskOverCopperColor;
|
|
75448
75563
|
if (hole.hole_shape === "circle") {
|
|
75449
|
-
const [cx3, cy3] =
|
|
75564
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75450
75565
|
const scaledRadius = hole.hole_diameter / 2 * Math.abs(realToCanvasMat.a);
|
|
75451
75566
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
75452
75567
|
const innerRadius = Math.max(0, scaledRadius - scaledThickness);
|
|
@@ -75459,7 +75574,7 @@ function drawNegativeMarginRingForHole(params2) {
|
|
|
75459
75574
|
ctx.fill("evenodd");
|
|
75460
75575
|
ctx.restore();
|
|
75461
75576
|
} else if (hole.hole_shape === "square") {
|
|
75462
|
-
const [cx3, cy3] =
|
|
75577
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75463
75578
|
const scaledSize = hole.hole_diameter * Math.abs(realToCanvasMat.a);
|
|
75464
75579
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
75465
75580
|
const innerSize = Math.max(0, scaledSize - scaledThickness * 2);
|
|
@@ -75476,7 +75591,7 @@ function drawNegativeMarginRingForHole(params2) {
|
|
|
75476
75591
|
ctx.fill("evenodd");
|
|
75477
75592
|
ctx.restore();
|
|
75478
75593
|
} else if (hole.hole_shape === "oval") {
|
|
75479
|
-
const [cx3, cy3] =
|
|
75594
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75480
75595
|
const scaledRadiusX = hole.hole_width / 2 * Math.abs(realToCanvasMat.a);
|
|
75481
75596
|
const scaledRadiusY = hole.hole_height / 2 * Math.abs(realToCanvasMat.a);
|
|
75482
75597
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75496,7 +75611,7 @@ function drawNegativeMarginRingForHole(params2) {
|
|
|
75496
75611
|
ctx.fill("evenodd");
|
|
75497
75612
|
ctx.restore();
|
|
75498
75613
|
} else if (hole.hole_shape === "rect") {
|
|
75499
|
-
const [cx3, cy3] =
|
|
75614
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75500
75615
|
const scaledWidth = hole.hole_width * Math.abs(realToCanvasMat.a);
|
|
75501
75616
|
const scaledHeight = hole.hole_height * Math.abs(realToCanvasMat.a);
|
|
75502
75617
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75515,7 +75630,7 @@ function drawNegativeMarginRingForHole(params2) {
|
|
|
75515
75630
|
ctx.fill("evenodd");
|
|
75516
75631
|
ctx.restore();
|
|
75517
75632
|
} else if (hole.hole_shape === "pill" || hole.hole_shape === "rotated_pill") {
|
|
75518
|
-
const [cx3, cy3] =
|
|
75633
|
+
const [cx3, cy3] = applyToPoint252(realToCanvasMat, [hole.x, hole.y]);
|
|
75519
75634
|
const scaledWidth = hole.hole_width * Math.abs(realToCanvasMat.a);
|
|
75520
75635
|
const scaledHeight = hole.hole_height * Math.abs(realToCanvasMat.a);
|
|
75521
75636
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75578,20 +75693,20 @@ function processPlatedHoleSoldermask(params2) {
|
|
|
75578
75693
|
function drawPlatedHoleShapePath(params2) {
|
|
75579
75694
|
const { ctx, hole, realToCanvasMat, margin } = params2;
|
|
75580
75695
|
if (hole.shape === "circle") {
|
|
75581
|
-
const [centerX, centerY] =
|
|
75696
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75582
75697
|
const radius = (hole.outer_diameter / 2 + margin) * Math.abs(realToCanvasMat.a);
|
|
75583
75698
|
ctx.beginPath();
|
|
75584
75699
|
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
|
|
75585
75700
|
ctx.closePath();
|
|
75586
75701
|
} else if (hole.shape === "oval") {
|
|
75587
|
-
const [centerX, centerY] =
|
|
75702
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75588
75703
|
const ovalRadiusX = (hole.outer_width / 2 + margin) * Math.abs(realToCanvasMat.a);
|
|
75589
75704
|
const ovalRadiusY = (hole.outer_height / 2 + margin) * Math.abs(realToCanvasMat.a);
|
|
75590
75705
|
ctx.beginPath();
|
|
75591
75706
|
ctx.ellipse(centerX, centerY, ovalRadiusX, ovalRadiusY, -((hole.ccw_rotation ?? 0) * Math.PI) / 180, 0, Math.PI * 2);
|
|
75592
75707
|
ctx.closePath();
|
|
75593
75708
|
} else if (hole.shape === "pill") {
|
|
75594
|
-
const [centerX, centerY] =
|
|
75709
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75595
75710
|
const pillWidth = (hole.outer_width + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75596
75711
|
const pillHeight = (hole.outer_height + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75597
75712
|
ctx.beginPath();
|
|
@@ -75604,7 +75719,7 @@ function drawPlatedHoleShapePath(params2) {
|
|
|
75604
75719
|
ccwRotationDegrees: hole.ccw_rotation
|
|
75605
75720
|
});
|
|
75606
75721
|
} else if (hole.shape === "circular_hole_with_rect_pad") {
|
|
75607
|
-
const [centerX, centerY] =
|
|
75722
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75608
75723
|
const rectPadWidth = (hole.rect_pad_width + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75609
75724
|
const rectPadHeight = (hole.rect_pad_height + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75610
75725
|
const rectPadCornerRadius = (hole.rect_border_radius ?? 0) * Math.abs(realToCanvasMat.a);
|
|
@@ -75619,7 +75734,7 @@ function drawPlatedHoleShapePath(params2) {
|
|
|
75619
75734
|
ccwRotationDegrees: hole.rect_ccw_rotation
|
|
75620
75735
|
});
|
|
75621
75736
|
} else if (hole.shape === "pill_hole_with_rect_pad") {
|
|
75622
|
-
const [centerX, centerY] =
|
|
75737
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75623
75738
|
const rectPadWidth = (hole.rect_pad_width + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75624
75739
|
const rectPadHeight = (hole.rect_pad_height + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75625
75740
|
const rectPadCornerRadius = (hole.rect_border_radius ?? 0) * Math.abs(realToCanvasMat.a);
|
|
@@ -75633,7 +75748,7 @@ function drawPlatedHoleShapePath(params2) {
|
|
|
75633
75748
|
radius: rectPadCornerRadius
|
|
75634
75749
|
});
|
|
75635
75750
|
} else if (hole.shape === "rotated_pill_hole_with_rect_pad") {
|
|
75636
|
-
const [centerX, centerY] =
|
|
75751
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75637
75752
|
const rectPadWidth = (hole.rect_pad_width + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75638
75753
|
const rectPadHeight = (hole.rect_pad_height + margin * 2) * Math.abs(realToCanvasMat.a);
|
|
75639
75754
|
const rectPadCornerRadius = (hole.rect_border_radius ?? 0) * Math.abs(realToCanvasMat.a);
|
|
@@ -75654,7 +75769,7 @@ function drawPlatedHoleShapePath(params2) {
|
|
|
75654
75769
|
}));
|
|
75655
75770
|
const marginPoints = margin !== 0 ? offsetPolygonPoints(padPoints, margin) : padPoints;
|
|
75656
75771
|
const canvasPoints = marginPoints.map((p3) => {
|
|
75657
|
-
const [x4, y4] =
|
|
75772
|
+
const [x4, y4] = applyToPoint262(realToCanvasMat, [p3.x, p3.y]);
|
|
75658
75773
|
return { x: x4, y: y4 };
|
|
75659
75774
|
});
|
|
75660
75775
|
ctx.beginPath();
|
|
@@ -75666,7 +75781,7 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75666
75781
|
const marginThickness = Math.abs(margin);
|
|
75667
75782
|
ctx.fillStyle = soldermaskOverCopperColor;
|
|
75668
75783
|
if (hole.shape === "circle") {
|
|
75669
|
-
const [centerX, centerY] =
|
|
75784
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75670
75785
|
const outerRadius = hole.outer_diameter / 2 * Math.abs(realToCanvasMat.a);
|
|
75671
75786
|
const marginMagnitude = marginThickness * Math.abs(realToCanvasMat.a);
|
|
75672
75787
|
const innerRadius = Math.max(0, outerRadius - marginMagnitude);
|
|
@@ -75677,7 +75792,7 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75677
75792
|
}
|
|
75678
75793
|
ctx.fill("evenodd");
|
|
75679
75794
|
} else if (hole.shape === "oval") {
|
|
75680
|
-
const [centerX, centerY] =
|
|
75795
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75681
75796
|
const padRadiusX = hole.outer_width / 2 * Math.abs(realToCanvasMat.a);
|
|
75682
75797
|
const padRadiusY = hole.outer_height / 2 * Math.abs(realToCanvasMat.a);
|
|
75683
75798
|
const marginMagnitude = marginThickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75694,7 +75809,7 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75694
75809
|
}
|
|
75695
75810
|
ctx.fill("evenodd");
|
|
75696
75811
|
} else if (hole.shape === "pill") {
|
|
75697
|
-
const [centerX, centerY] =
|
|
75812
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75698
75813
|
const padWidth = hole.outer_width * Math.abs(realToCanvasMat.a);
|
|
75699
75814
|
const padHeight = hole.outer_height * Math.abs(realToCanvasMat.a);
|
|
75700
75815
|
const marginMagnitude = marginThickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75721,7 +75836,7 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75721
75836
|
}
|
|
75722
75837
|
ctx.fill("evenodd");
|
|
75723
75838
|
} else if (hole.shape === "circular_hole_with_rect_pad") {
|
|
75724
|
-
const [centerX, centerY] =
|
|
75839
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75725
75840
|
const padWidth = hole.rect_pad_width * Math.abs(realToCanvasMat.a);
|
|
75726
75841
|
const padHeight = hole.rect_pad_height * Math.abs(realToCanvasMat.a);
|
|
75727
75842
|
const marginMagnitude = marginThickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75752,7 +75867,7 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75752
75867
|
}
|
|
75753
75868
|
ctx.fill("evenodd");
|
|
75754
75869
|
} else if (hole.shape === "pill_hole_with_rect_pad") {
|
|
75755
|
-
const [centerX, centerY] =
|
|
75870
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75756
75871
|
const padWidth = hole.rect_pad_width * Math.abs(realToCanvasMat.a);
|
|
75757
75872
|
const padHeight = hole.rect_pad_height * Math.abs(realToCanvasMat.a);
|
|
75758
75873
|
const marginMagnitude = marginThickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75781,7 +75896,7 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75781
75896
|
}
|
|
75782
75897
|
ctx.fill("evenodd");
|
|
75783
75898
|
} else if (hole.shape === "rotated_pill_hole_with_rect_pad") {
|
|
75784
|
-
const [centerX, centerY] =
|
|
75899
|
+
const [centerX, centerY] = applyToPoint262(realToCanvasMat, [hole.x, hole.y]);
|
|
75785
75900
|
const padWidth = hole.rect_pad_width * Math.abs(realToCanvasMat.a);
|
|
75786
75901
|
const padHeight = hole.rect_pad_height * Math.abs(realToCanvasMat.a);
|
|
75787
75902
|
const marginMagnitude = marginThickness * Math.abs(realToCanvasMat.a);
|
|
@@ -75818,14 +75933,14 @@ function drawNegativeMarginRingForPlatedHole(params2) {
|
|
|
75818
75933
|
}));
|
|
75819
75934
|
ctx.beginPath();
|
|
75820
75935
|
const outerPoints = padPoints.map((p3) => {
|
|
75821
|
-
const [x4, y4] =
|
|
75936
|
+
const [x4, y4] = applyToPoint262(realToCanvasMat, [p3.x, p3.y]);
|
|
75822
75937
|
return { x: x4, y: y4 };
|
|
75823
75938
|
});
|
|
75824
75939
|
drawPolygonPath({ ctx, points: outerPoints });
|
|
75825
75940
|
const innerMarginPoints = offsetPolygonPoints(padPoints, -marginThickness);
|
|
75826
75941
|
if (innerMarginPoints.length >= 3) {
|
|
75827
75942
|
const innerPoints = innerMarginPoints.map((p3) => {
|
|
75828
|
-
const [x4, y4] =
|
|
75943
|
+
const [x4, y4] = applyToPoint262(realToCanvasMat, [p3.x, p3.y]);
|
|
75829
75944
|
return { x: x4, y: y4 };
|
|
75830
75945
|
});
|
|
75831
75946
|
drawPolygonPath({ ctx, points: innerPoints });
|
|
@@ -75884,7 +75999,7 @@ function drawPadShapePath(params2) {
|
|
|
75884
75999
|
const dyLocal = (mt3 - mb3) / 2;
|
|
75885
76000
|
const dxGlobal = dxLocal * Math.cos(radians) - dyLocal * Math.sin(radians);
|
|
75886
76001
|
const dyGlobal = dxLocal * Math.sin(radians) + dyLocal * Math.cos(radians);
|
|
75887
|
-
const [cx3, cy3] =
|
|
76002
|
+
const [cx3, cy3] = applyToPoint272(realToCanvasMat, [
|
|
75888
76003
|
pad2.x + dxGlobal,
|
|
75889
76004
|
pad2.y + dyGlobal
|
|
75890
76005
|
]);
|
|
@@ -75908,14 +76023,14 @@ function drawPadShapePath(params2) {
|
|
|
75908
76023
|
ctx.restore();
|
|
75909
76024
|
} else if (pad2.shape === "circle") {
|
|
75910
76025
|
const avgMargin = (ml2 + mr3 + mt3 + mb3) / 4;
|
|
75911
|
-
const [cx3, cy3] =
|
|
76026
|
+
const [cx3, cy3] = applyToPoint272(realToCanvasMat, [pad2.x, pad2.y]);
|
|
75912
76027
|
const scaledRadius = (pad2.radius + avgMargin) * Math.abs(realToCanvasMat.a);
|
|
75913
76028
|
ctx.beginPath();
|
|
75914
76029
|
ctx.arc(cx3, cy3, scaledRadius, 0, Math.PI * 2);
|
|
75915
76030
|
ctx.closePath();
|
|
75916
76031
|
} else if (pad2.shape === "pill" || pad2.shape === "rotated_pill") {
|
|
75917
76032
|
const avgMargin = (ml2 + mr3) / 2;
|
|
75918
|
-
const [cx3, cy3] =
|
|
76033
|
+
const [cx3, cy3] = applyToPoint272(realToCanvasMat, [pad2.x, pad2.y]);
|
|
75919
76034
|
const scaledWidth = (pad2.width + avgMargin * 2) * Math.abs(realToCanvasMat.a);
|
|
75920
76035
|
const scaledHeight = (pad2.height + avgMargin * 2) * Math.abs(realToCanvasMat.a);
|
|
75921
76036
|
ctx.save();
|
|
@@ -75936,7 +76051,7 @@ function drawPadShapePath(params2) {
|
|
|
75936
76051
|
const avgMargin = (ml2 + mr3 + mt3 + mb3) / 4;
|
|
75937
76052
|
const points = avgMargin !== 0 ? offsetPolygonPoints(pad2.points, avgMargin) : pad2.points;
|
|
75938
76053
|
const canvasPoints = points.map((p3) => {
|
|
75939
|
-
const [x4, y4] =
|
|
76054
|
+
const [x4, y4] = applyToPoint272(realToCanvasMat, [p3.x, p3.y]);
|
|
75940
76055
|
return { x: x4, y: y4 };
|
|
75941
76056
|
});
|
|
75942
76057
|
ctx.beginPath();
|
|
@@ -75962,7 +76077,7 @@ function drawNegativeMarginRingForPad(params2) {
|
|
|
75962
76077
|
ctx.fillStyle = soldermaskOverCopperColor;
|
|
75963
76078
|
if (pad2.shape === "rect" || pad2.shape === "rotated_rect") {
|
|
75964
76079
|
const borderRadius = pad2.corner_radius ?? pad2.rect_border_radius ?? 0;
|
|
75965
|
-
const [cx3, cy3] =
|
|
76080
|
+
const [cx3, cy3] = applyToPoint272(realToCanvasMat, [pad2.x, pad2.y]);
|
|
75966
76081
|
const scaledWidth = pad2.width * Math.abs(realToCanvasMat.a);
|
|
75967
76082
|
const scaledHeight = pad2.height * Math.abs(realToCanvasMat.a);
|
|
75968
76083
|
const scaledRadius = borderRadius * Math.abs(realToCanvasMat.a);
|
|
@@ -76003,7 +76118,7 @@ function drawNegativeMarginRingForPad(params2) {
|
|
|
76003
76118
|
ctx.restore();
|
|
76004
76119
|
} else if (pad2.shape === "circle") {
|
|
76005
76120
|
const thickness = Math.max(thicknessL, thicknessR, thicknessT, thicknessB);
|
|
76006
|
-
const [cx3, cy3] =
|
|
76121
|
+
const [cx3, cy3] = applyToPoint272(realToCanvasMat, [pad2.x, pad2.y]);
|
|
76007
76122
|
const scaledRadius = pad2.radius * Math.abs(realToCanvasMat.a);
|
|
76008
76123
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
76009
76124
|
const innerRadius = Math.max(0, scaledRadius - scaledThickness);
|
|
@@ -76017,7 +76132,7 @@ function drawNegativeMarginRingForPad(params2) {
|
|
|
76017
76132
|
ctx.restore();
|
|
76018
76133
|
} else if (pad2.shape === "pill" || pad2.shape === "rotated_pill") {
|
|
76019
76134
|
const thickness = Math.max(thicknessL, thicknessR, thicknessT, thicknessB);
|
|
76020
|
-
const [cx3, cy3] =
|
|
76135
|
+
const [cx3, cy3] = applyToPoint272(realToCanvasMat, [pad2.x, pad2.y]);
|
|
76021
76136
|
const scaledWidth = pad2.width * Math.abs(realToCanvasMat.a);
|
|
76022
76137
|
const scaledHeight = pad2.height * Math.abs(realToCanvasMat.a);
|
|
76023
76138
|
const scaledThickness = thickness * Math.abs(realToCanvasMat.a);
|
|
@@ -76052,14 +76167,14 @@ function drawNegativeMarginRingForPad(params2) {
|
|
|
76052
76167
|
ctx.save();
|
|
76053
76168
|
ctx.beginPath();
|
|
76054
76169
|
const canvasPoints = pad2.points.map((p3) => {
|
|
76055
|
-
const [x4, y4] =
|
|
76170
|
+
const [x4, y4] = applyToPoint272(realToCanvasMat, [p3.x, p3.y]);
|
|
76056
76171
|
return { x: x4, y: y4 };
|
|
76057
76172
|
});
|
|
76058
76173
|
drawPolygonPath({ ctx, points: canvasPoints });
|
|
76059
76174
|
const innerPoints = offsetPolygonPoints(pad2.points, -thickness);
|
|
76060
76175
|
if (innerPoints.length >= 3) {
|
|
76061
76176
|
const innerCanvasPoints = innerPoints.map((p3) => {
|
|
76062
|
-
const [x4, y4] =
|
|
76177
|
+
const [x4, y4] = applyToPoint272(realToCanvasMat, [p3.x, p3.y]);
|
|
76063
76178
|
return { x: x4, y: y4 };
|
|
76064
76179
|
});
|
|
76065
76180
|
drawPolygonPath({ ctx, points: innerCanvasPoints });
|
|
@@ -76377,14 +76492,6 @@ function getCutoutKey(cutout) {
|
|
|
76377
76492
|
}
|
|
76378
76493
|
return `pill:${cutout.x}:${cutout.y}:${cutout.width}:${cutout.height}:${cutout.rotation ?? 0}`;
|
|
76379
76494
|
}
|
|
76380
|
-
function hasVariableWidth(points) {
|
|
76381
|
-
if (points.length < 2)
|
|
76382
|
-
return false;
|
|
76383
|
-
const baseWidth = points[0]?.width;
|
|
76384
|
-
if (typeof baseWidth !== "number")
|
|
76385
|
-
return false;
|
|
76386
|
-
return points.some((point9) => Math.abs(point9.width - baseWidth) > Number.EPSILON);
|
|
76387
|
-
}
|
|
76388
76495
|
function processTraceSoldermask(params2) {
|
|
76389
76496
|
const { ctx, trace, realToCanvasMat, soldermaskOverCopperColor, layer } = params2;
|
|
76390
76497
|
if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2) {
|
|
@@ -76395,11 +76502,10 @@ function processTraceSoldermask(params2) {
|
|
|
76395
76502
|
const segmentLayer = segment2[0]?.layer;
|
|
76396
76503
|
if (segmentLayer !== layer)
|
|
76397
76504
|
continue;
|
|
76398
|
-
if (
|
|
76399
|
-
const polygonPoints = buildTracePolygon(segment2);
|
|
76505
|
+
if (trace.route_thickness_mode === "interpolated") {
|
|
76400
76506
|
drawPolygon({
|
|
76401
76507
|
ctx,
|
|
76402
|
-
points:
|
|
76508
|
+
points: buildTracePolygon(segment2),
|
|
76403
76509
|
fill: soldermaskOverCopperColor,
|
|
76404
76510
|
realToCanvasMat
|
|
76405
76511
|
});
|
|
@@ -76432,7 +76538,7 @@ function processTraceSoldermask(params2) {
|
|
|
76432
76538
|
}
|
|
76433
76539
|
function processViaSoldermask(params2) {
|
|
76434
76540
|
const { ctx, via, realToCanvasMat } = params2;
|
|
76435
|
-
const [cx3, cy3] =
|
|
76541
|
+
const [cx3, cy3] = applyToPoint282(realToCanvasMat, [via.x, via.y]);
|
|
76436
76542
|
const scaledRadius = via.outer_diameter / 2 * Math.abs(realToCanvasMat.a);
|
|
76437
76543
|
ctx.beginPath();
|
|
76438
76544
|
ctx.arc(cx3, cy3, scaledRadius, 0, Math.PI * 2);
|
|
@@ -76453,7 +76559,7 @@ function drawPcbSoldermask(params2) {
|
|
|
76453
76559
|
const soldermaskOverCopperColor = colorMap2.soldermaskOverCopper[layer] ?? colorMap2.soldermaskOverCopper.top;
|
|
76454
76560
|
const vias = elements.filter((el3) => el3.type === "pcb_via");
|
|
76455
76561
|
const platedHoles = elements.filter((el3) => el3.type === "pcb_plated_hole");
|
|
76456
|
-
const soldermaskCtx =
|
|
76562
|
+
const soldermaskCtx = createDrawingLayerContext(ctx, ctx.canvas.width, ctx.canvas.height) ?? ctx;
|
|
76457
76563
|
if (panel) {
|
|
76458
76564
|
drawPanelSoldermask({
|
|
76459
76565
|
ctx: soldermaskCtx,
|
|
@@ -76514,7 +76620,7 @@ function drawPcbSoldermask(params2) {
|
|
|
76514
76620
|
layer
|
|
76515
76621
|
});
|
|
76516
76622
|
}
|
|
76517
|
-
|
|
76623
|
+
mergeDrawingLayer(ctx, soldermaskCtx);
|
|
76518
76624
|
}
|
|
76519
76625
|
function processElementSoldermask(params2) {
|
|
76520
76626
|
const { ctx, element, realToCanvasMat, soldermaskOverCopperColor, layer } = params2;
|
|
@@ -76563,7 +76669,7 @@ function layerToColor4(layer, colorMap2) {
|
|
|
76563
76669
|
return colorMap2.copper[layer] ?? colorMap2.copper.top;
|
|
76564
76670
|
}
|
|
76565
76671
|
function drawPcbTrace(params2) {
|
|
76566
|
-
const { ctx, trace, realToCanvasMat, colorMap: colorMap2 } = params2;
|
|
76672
|
+
const { ctx, trace, realToCanvasMat, colorMap: colorMap2, layer: layerFilter } = params2;
|
|
76567
76673
|
if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2) {
|
|
76568
76674
|
return;
|
|
76569
76675
|
}
|
|
@@ -76572,12 +76678,13 @@ function drawPcbTrace(params2) {
|
|
|
76572
76678
|
const layer = segment2[0]?.layer;
|
|
76573
76679
|
if (!layer)
|
|
76574
76680
|
continue;
|
|
76681
|
+
if (layerFilter && layer !== layerFilter)
|
|
76682
|
+
continue;
|
|
76575
76683
|
const color = layerToColor4(layer, colorMap2);
|
|
76576
|
-
if (
|
|
76577
|
-
const polygonPoints = buildTracePolygon(segment2);
|
|
76684
|
+
if (trace.route_thickness_mode === "interpolated") {
|
|
76578
76685
|
drawPolygon({
|
|
76579
76686
|
ctx,
|
|
76580
|
-
points:
|
|
76687
|
+
points: buildTracePolygon(segment2),
|
|
76581
76688
|
fill: color,
|
|
76582
76689
|
realToCanvasMat
|
|
76583
76690
|
});
|
|
@@ -76607,9 +76714,125 @@ function drawPcbTrace(params2) {
|
|
|
76607
76714
|
trace,
|
|
76608
76715
|
realToCanvasMat,
|
|
76609
76716
|
vias: params2.vias ?? [],
|
|
76610
|
-
platedHoles: params2.platedHoles ?? []
|
|
76717
|
+
platedHoles: params2.platedHoles ?? [],
|
|
76718
|
+
layer: layerFilter
|
|
76611
76719
|
});
|
|
76612
76720
|
}
|
|
76721
|
+
function drawPcbTracesClippedToCopperPours(params2) {
|
|
76722
|
+
const {
|
|
76723
|
+
ctx,
|
|
76724
|
+
traces,
|
|
76725
|
+
copperPours,
|
|
76726
|
+
realToCanvasMat,
|
|
76727
|
+
colorMap: colorMap2,
|
|
76728
|
+
vias,
|
|
76729
|
+
platedHoles,
|
|
76730
|
+
renderLayers
|
|
76731
|
+
} = params2;
|
|
76732
|
+
for (const layer of getTraceLayers(traces, renderLayers)) {
|
|
76733
|
+
const layerCopperPours = copperPours.filter((pour) => pour.layer === layer);
|
|
76734
|
+
if (layerCopperPours.length === 0) {
|
|
76735
|
+
drawTracesOnLayer({
|
|
76736
|
+
ctx,
|
|
76737
|
+
traces,
|
|
76738
|
+
layer,
|
|
76739
|
+
realToCanvasMat,
|
|
76740
|
+
colorMap: colorMap2,
|
|
76741
|
+
vias,
|
|
76742
|
+
platedHoles
|
|
76743
|
+
});
|
|
76744
|
+
continue;
|
|
76745
|
+
}
|
|
76746
|
+
const traceLayerCtx = createDrawingLayerContext(ctx, ctx.canvas.width, ctx.canvas.height);
|
|
76747
|
+
if (traceLayerCtx) {
|
|
76748
|
+
drawTracesOnLayer({
|
|
76749
|
+
ctx: traceLayerCtx,
|
|
76750
|
+
traces,
|
|
76751
|
+
layer,
|
|
76752
|
+
realToCanvasMat,
|
|
76753
|
+
colorMap: colorMap2,
|
|
76754
|
+
vias,
|
|
76755
|
+
platedHoles
|
|
76756
|
+
});
|
|
76757
|
+
eraseCopperPoursFromTraceLayer({
|
|
76758
|
+
ctx: traceLayerCtx,
|
|
76759
|
+
copperPours: layerCopperPours,
|
|
76760
|
+
realToCanvasMat
|
|
76761
|
+
});
|
|
76762
|
+
if (mergeDrawingLayer(ctx, traceLayerCtx))
|
|
76763
|
+
continue;
|
|
76764
|
+
}
|
|
76765
|
+
ctx.save();
|
|
76766
|
+
clipToOutsideCopperPours({
|
|
76767
|
+
ctx,
|
|
76768
|
+
copperPours: layerCopperPours,
|
|
76769
|
+
realToCanvasMat
|
|
76770
|
+
});
|
|
76771
|
+
drawTracesOnLayer({
|
|
76772
|
+
ctx,
|
|
76773
|
+
traces,
|
|
76774
|
+
layer,
|
|
76775
|
+
realToCanvasMat,
|
|
76776
|
+
colorMap: colorMap2,
|
|
76777
|
+
vias,
|
|
76778
|
+
platedHoles
|
|
76779
|
+
});
|
|
76780
|
+
ctx.restore();
|
|
76781
|
+
}
|
|
76782
|
+
}
|
|
76783
|
+
function drawTracesOnLayer(params2) {
|
|
76784
|
+
const { ctx, traces, layer, realToCanvasMat, colorMap: colorMap2, vias, platedHoles } = params2;
|
|
76785
|
+
for (const trace of traces) {
|
|
76786
|
+
drawPcbTrace({
|
|
76787
|
+
ctx,
|
|
76788
|
+
trace,
|
|
76789
|
+
realToCanvasMat,
|
|
76790
|
+
colorMap: colorMap2,
|
|
76791
|
+
vias,
|
|
76792
|
+
platedHoles,
|
|
76793
|
+
layer
|
|
76794
|
+
});
|
|
76795
|
+
}
|
|
76796
|
+
}
|
|
76797
|
+
function eraseCopperPoursFromTraceLayer(params2) {
|
|
76798
|
+
const { ctx, copperPours, realToCanvasMat } = params2;
|
|
76799
|
+
if (copperPours.length === 0)
|
|
76800
|
+
return;
|
|
76801
|
+
ctx.save();
|
|
76802
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
76803
|
+
ctx.fillStyle = "#000";
|
|
76804
|
+
for (const pour of copperPours) {
|
|
76805
|
+
ctx.beginPath();
|
|
76806
|
+
appendPcbCopperPourPath({ ctx, pour, realToCanvasMat });
|
|
76807
|
+
ctx.fill(pour.shape === "brep" ? "evenodd" : "nonzero");
|
|
76808
|
+
}
|
|
76809
|
+
ctx.restore();
|
|
76810
|
+
}
|
|
76811
|
+
function getTraceLayers(traces, renderLayers) {
|
|
76812
|
+
const layers = /* @__PURE__ */ new Set;
|
|
76813
|
+
for (const trace of traces) {
|
|
76814
|
+
for (const point9 of trace.route ?? []) {
|
|
76815
|
+
if (point9.route_type !== "wire" || !point9.layer)
|
|
76816
|
+
continue;
|
|
76817
|
+
if (renderLayers?.length && !renderLayers.includes(`${point9.layer}_copper`)) {
|
|
76818
|
+
continue;
|
|
76819
|
+
}
|
|
76820
|
+
layers.add(point9.layer);
|
|
76821
|
+
}
|
|
76822
|
+
}
|
|
76823
|
+
return [...layers];
|
|
76824
|
+
}
|
|
76825
|
+
function clipToOutsideCopperPours(params2) {
|
|
76826
|
+
const { ctx, copperPours, realToCanvasMat } = params2;
|
|
76827
|
+
if (copperPours.length === 0)
|
|
76828
|
+
return;
|
|
76829
|
+
ctx.beginPath();
|
|
76830
|
+
ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
76831
|
+
for (const pour of copperPours) {
|
|
76832
|
+
appendPcbCopperPourPath({ ctx, pour, realToCanvasMat });
|
|
76833
|
+
}
|
|
76834
|
+
ctx.clip("evenodd");
|
|
76835
|
+
}
|
|
76613
76836
|
function drawPcbVia(params2) {
|
|
76614
76837
|
const { ctx, via, realToCanvasMat, colorMap: colorMap2, layer } = params2;
|
|
76615
76838
|
drawCircle({
|
|
@@ -76641,6 +76864,9 @@ function shouldDrawElement(element, options) {
|
|
|
76641
76864
|
if (!options.layers || options.layers.length === 0) {
|
|
76642
76865
|
return true;
|
|
76643
76866
|
}
|
|
76867
|
+
if (element.type === "pcb_silkscreen_graphic") {
|
|
76868
|
+
return options.layers.some((layer) => layer === `${element.layer}_silkscreen`);
|
|
76869
|
+
}
|
|
76644
76870
|
const elementLayers = getElementRenderLayers(element);
|
|
76645
76871
|
if (elementLayers.length === 0) {
|
|
76646
76872
|
return true;
|
|
@@ -76650,10 +76876,10 @@ function shouldDrawElement(element, options) {
|
|
|
76650
76876
|
function getCopperLayer(layers) {
|
|
76651
76877
|
if (!layers || layers.length === 0)
|
|
76652
76878
|
return "top";
|
|
76653
|
-
const
|
|
76654
|
-
return
|
|
76879
|
+
const renderLayer = layers.find((candidate) => candidate.endsWith("_copper")) ?? layers[0] ?? "top_copper";
|
|
76880
|
+
return renderLayer.split("_")[0];
|
|
76655
76881
|
}
|
|
76656
|
-
var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textMetrics.spaceWidthRatio : textMetrics.glyphWidthRatio), getGlyphLines = (char) => glyphLineAlphabet[char], DEFAULT_KNOCKOUT_PADDING, TEXT_OFFSET_MULTIPLIER2 = 1.5, CHARACTER_WIDTH_MULTIPLIER2 = 0.6, TEXT_INTERSECTION_PADDING_MULTIPLIER2 = 0.3, DEFAULT_NOTE_COLOR = "rgba(255,255,255,0.5)", DEFAULT_NOTE_TEXT_COLOR = "rgb(89, 148, 220)", CUTOUT_MASK_COLOR = "rgba(255, 255, 255, 1)", COORD_EPSILON = 0.000001, DEFAULT_PCB_COLOR_MAP2, CircuitToCanvasDrawer = class {
|
|
76882
|
+
var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textMetrics.spaceWidthRatio : textMetrics.glyphWidthRatio), getGlyphLines = (char) => glyphLineAlphabet[char], DEFAULT_KNOCKOUT_PADDING, TEXT_OFFSET_MULTIPLIER2 = 1.5, CHARACTER_WIDTH_MULTIPLIER2 = 0.6, TEXT_INTERSECTION_PADDING_MULTIPLIER2 = 0.3, DEFAULT_NOTE_COLOR = "rgba(255,255,255,0.5)", DEFAULT_NOTE_TEXT_COLOR = "rgb(89, 148, 220)", SOLDER_PASTE_COLOR = "rgb(105, 105, 105)", CUTOUT_MASK_COLOR = "rgba(255, 255, 255, 1)", COORD_EPSILON = 0.000001, DEFAULT_PCB_COLOR_MAP2, isOnCopperLayer = (element, layer) => element.layers?.includes(layer) ?? true, CircuitToCanvasDrawer = class _CircuitToCanvasDrawer {
|
|
76657
76883
|
ctx;
|
|
76658
76884
|
colorMap;
|
|
76659
76885
|
realToCanvasMat;
|
|
@@ -76730,13 +76956,20 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76730
76956
|
}
|
|
76731
76957
|
const drawBoardMaterial = options.drawBoardMaterial ?? false;
|
|
76732
76958
|
const drawSoldermask = options.drawSoldermask ?? false;
|
|
76959
|
+
const drawSolderPaste = options.drawSolderPaste ?? false;
|
|
76733
76960
|
const hasExplicitSoldermaskLayers = options.drawSoldermaskTop !== undefined || options.drawSoldermaskBottom !== undefined;
|
|
76961
|
+
const hasExplicitSolderPasteLayers = options.drawSolderPasteTop !== undefined || options.drawSolderPasteBottom !== undefined;
|
|
76734
76962
|
const renderTopSoldermask = drawSoldermask && (board !== undefined || panel !== undefined) && (options.drawSoldermaskTop ?? !hasExplicitSoldermaskLayers);
|
|
76735
76963
|
const renderBottomSoldermask = drawSoldermask && (board !== undefined || panel !== undefined) && (options.drawSoldermaskBottom ?? false);
|
|
76736
|
-
const
|
|
76964
|
+
const renderTopSolderPaste = drawSolderPaste && (options.drawSolderPasteTop ?? !hasExplicitSolderPasteLayers) && elements.some((element) => element.type === "pcb_solder_paste" && element.layer === "top");
|
|
76965
|
+
const renderBottomSolderPaste = drawSolderPaste && (options.drawSolderPasteBottom ?? false) && elements.some((element) => element.type === "pcb_solder_paste" && element.layer === "bottom");
|
|
76966
|
+
const renderTopLayerOverlay = renderTopSoldermask || renderTopSolderPaste;
|
|
76967
|
+
const drawableVias = elements.filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_via" && isOnCopperLayer(el3, layer));
|
|
76737
76968
|
const drawableHoles = elements.filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_hole");
|
|
76738
|
-
const drawablePlatedHoles = elements.filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_plated_hole");
|
|
76969
|
+
const drawablePlatedHoles = elements.filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_plated_hole" && isOnCopperLayer(el3, layer));
|
|
76739
76970
|
const drawableCutouts = elements.filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_cutout");
|
|
76971
|
+
const drawableCopperPours = (options.clipContextElements ?? elements).filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_copper_pour");
|
|
76972
|
+
const drawableTraces = elements.filter((el3) => shouldDrawElement(el3, options) && el3.type === "pcb_trace");
|
|
76740
76973
|
if (board) {
|
|
76741
76974
|
drawPcbBoard({
|
|
76742
76975
|
ctx: this.ctx,
|
|
@@ -76783,21 +77016,17 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76783
77016
|
});
|
|
76784
77017
|
}
|
|
76785
77018
|
}
|
|
76786
|
-
if (
|
|
76787
|
-
|
|
76788
|
-
|
|
76789
|
-
|
|
76790
|
-
|
|
76791
|
-
|
|
76792
|
-
|
|
76793
|
-
|
|
76794
|
-
|
|
76795
|
-
|
|
76796
|
-
|
|
76797
|
-
platedHoles: drawablePlatedHoles
|
|
76798
|
-
});
|
|
76799
|
-
}
|
|
76800
|
-
}
|
|
77019
|
+
if (renderTopLayerOverlay) {
|
|
77020
|
+
drawPcbTracesClippedToCopperPours({
|
|
77021
|
+
ctx: this.ctx,
|
|
77022
|
+
traces: drawableTraces,
|
|
77023
|
+
copperPours: drawableCopperPours,
|
|
77024
|
+
realToCanvasMat: this.realToCanvasMat,
|
|
77025
|
+
colorMap: this.colorMap,
|
|
77026
|
+
vias: drawableVias,
|
|
77027
|
+
platedHoles: drawablePlatedHoles,
|
|
77028
|
+
renderLayers: options.layers
|
|
77029
|
+
});
|
|
76801
77030
|
for (const element of elements) {
|
|
76802
77031
|
if (!shouldDrawElement(element, options))
|
|
76803
77032
|
continue;
|
|
@@ -76807,22 +77036,22 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76807
77036
|
hole: element,
|
|
76808
77037
|
realToCanvasMat: this.realToCanvasMat,
|
|
76809
77038
|
colorMap: this.colorMap,
|
|
76810
|
-
soldermaskMargin: element.soldermask_margin,
|
|
77039
|
+
soldermaskMargin: renderTopSoldermask ? element.soldermask_margin : undefined,
|
|
76811
77040
|
drawSoldermask: renderTopSoldermask
|
|
76812
77041
|
});
|
|
76813
77042
|
}
|
|
76814
|
-
if (element.type === "pcb_plated_hole") {
|
|
77043
|
+
if (element.type === "pcb_plated_hole" && isOnCopperLayer(element, layer)) {
|
|
76815
77044
|
drawPcbPlatedHole({
|
|
76816
77045
|
ctx: this.ctx,
|
|
76817
77046
|
hole: element,
|
|
76818
77047
|
realToCanvasMat: this.realToCanvasMat,
|
|
76819
77048
|
colorMap: this.colorMap,
|
|
76820
|
-
soldermaskMargin: element.soldermask_margin,
|
|
77049
|
+
soldermaskMargin: renderTopSoldermask ? element.soldermask_margin : undefined,
|
|
76821
77050
|
drawSoldermask: renderTopSoldermask,
|
|
76822
77051
|
layer
|
|
76823
77052
|
});
|
|
76824
77053
|
}
|
|
76825
|
-
if (element.type === "pcb_via") {
|
|
77054
|
+
if (element.type === "pcb_via" && isOnCopperLayer(element, layer)) {
|
|
76826
77055
|
drawPcbVia({
|
|
76827
77056
|
ctx: this.ctx,
|
|
76828
77057
|
via: element,
|
|
@@ -76843,6 +77072,18 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76843
77072
|
drawSoldermask: true
|
|
76844
77073
|
});
|
|
76845
77074
|
}
|
|
77075
|
+
if (renderTopSolderPaste) {
|
|
77076
|
+
for (const element of elements) {
|
|
77077
|
+
if (element.type !== "pcb_solder_paste" || element.layer !== "top") {
|
|
77078
|
+
continue;
|
|
77079
|
+
}
|
|
77080
|
+
drawPcbSolderPaste({
|
|
77081
|
+
ctx: this.ctx,
|
|
77082
|
+
solderPaste: element,
|
|
77083
|
+
realToCanvasMat: this.realToCanvasMat
|
|
77084
|
+
});
|
|
77085
|
+
}
|
|
77086
|
+
}
|
|
76846
77087
|
for (const element of elements) {
|
|
76847
77088
|
if (!shouldDrawElement(element, options))
|
|
76848
77089
|
continue;
|
|
@@ -76902,25 +77143,31 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76902
77143
|
colorMap: this.colorMap
|
|
76903
77144
|
});
|
|
76904
77145
|
}
|
|
76905
|
-
|
|
76906
|
-
|
|
76907
|
-
if (!shouldDrawElement(element, options))
|
|
76908
|
-
continue;
|
|
76909
|
-
if (element.type === "pcb_trace" && !renderTopSoldermask) {
|
|
76910
|
-
drawPcbTrace({
|
|
77146
|
+
if (element.type === "pcb_silkscreen_graphic") {
|
|
77147
|
+
drawPcbSilkscreenGraphic({
|
|
76911
77148
|
ctx: this.ctx,
|
|
76912
|
-
|
|
77149
|
+
graphic: element,
|
|
76913
77150
|
realToCanvasMat: this.realToCanvasMat,
|
|
76914
|
-
colorMap: this.colorMap
|
|
76915
|
-
vias: drawableVias,
|
|
76916
|
-
platedHoles: drawablePlatedHoles
|
|
77151
|
+
colorMap: this.colorMap
|
|
76917
77152
|
});
|
|
76918
77153
|
}
|
|
76919
77154
|
}
|
|
77155
|
+
if (!renderTopLayerOverlay) {
|
|
77156
|
+
drawPcbTracesClippedToCopperPours({
|
|
77157
|
+
ctx: this.ctx,
|
|
77158
|
+
traces: drawableTraces,
|
|
77159
|
+
copperPours: drawableCopperPours,
|
|
77160
|
+
realToCanvasMat: this.realToCanvasMat,
|
|
77161
|
+
colorMap: this.colorMap,
|
|
77162
|
+
vias: drawableVias,
|
|
77163
|
+
platedHoles: drawablePlatedHoles,
|
|
77164
|
+
renderLayers: options.layers
|
|
77165
|
+
});
|
|
77166
|
+
}
|
|
76920
77167
|
for (const element of elements) {
|
|
76921
77168
|
if (!shouldDrawElement(element, options))
|
|
76922
77169
|
continue;
|
|
76923
|
-
if (element.type === "pcb_hole" && !
|
|
77170
|
+
if (element.type === "pcb_hole" && !renderTopLayerOverlay) {
|
|
76924
77171
|
drawPcbHole({
|
|
76925
77172
|
ctx: this.ctx,
|
|
76926
77173
|
hole: element,
|
|
@@ -76934,7 +77181,7 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76934
77181
|
for (const element of elements) {
|
|
76935
77182
|
if (!shouldDrawElement(element, options))
|
|
76936
77183
|
continue;
|
|
76937
|
-
if (element.type === "pcb_plated_hole" && !
|
|
77184
|
+
if (element.type === "pcb_plated_hole" && !renderTopLayerOverlay && isOnCopperLayer(element, layer)) {
|
|
76938
77185
|
drawPcbPlatedHole({
|
|
76939
77186
|
ctx: this.ctx,
|
|
76940
77187
|
hole: element,
|
|
@@ -76945,7 +77192,7 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76945
77192
|
layer
|
|
76946
77193
|
});
|
|
76947
77194
|
}
|
|
76948
|
-
if (element.type === "pcb_via" && !
|
|
77195
|
+
if (element.type === "pcb_via" && !renderTopLayerOverlay && isOnCopperLayer(element, layer)) {
|
|
76949
77196
|
drawPcbVia({
|
|
76950
77197
|
ctx: this.ctx,
|
|
76951
77198
|
via: element,
|
|
@@ -76965,6 +77212,18 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
76965
77212
|
drawSoldermask: true
|
|
76966
77213
|
});
|
|
76967
77214
|
}
|
|
77215
|
+
if (renderBottomSolderPaste) {
|
|
77216
|
+
for (const element of elements) {
|
|
77217
|
+
if (element.type !== "pcb_solder_paste" || element.layer !== "bottom") {
|
|
77218
|
+
continue;
|
|
77219
|
+
}
|
|
77220
|
+
drawPcbSolderPaste({
|
|
77221
|
+
ctx: this.ctx,
|
|
77222
|
+
solderPaste: element,
|
|
77223
|
+
realToCanvasMat: this.realToCanvasMat
|
|
77224
|
+
});
|
|
77225
|
+
}
|
|
77226
|
+
}
|
|
76968
77227
|
for (const element of elements) {
|
|
76969
77228
|
if (!shouldDrawElement(element, options))
|
|
76970
77229
|
continue;
|
|
@@ -77086,6 +77345,41 @@ var getAdvanceRatio = (char) => glyphAdvanceRatio[char] ?? (char === " " ? textM
|
|
|
77086
77345
|
});
|
|
77087
77346
|
}
|
|
77088
77347
|
}
|
|
77348
|
+
if (options.clearDrillHoles) {
|
|
77349
|
+
this.clearDrillHoles(elements, layer);
|
|
77350
|
+
}
|
|
77351
|
+
}
|
|
77352
|
+
clearDrillHoles(elements, layer) {
|
|
77353
|
+
const apertures = elements.filter((element) => element.type === "pcb_hole" || element.type === "pcb_plated_hole" || element.type === "pcb_via" || element.type === "pcb_cutout");
|
|
77354
|
+
if (apertures.length === 0)
|
|
77355
|
+
return;
|
|
77356
|
+
const transparent = "rgba(0,0,0,0)";
|
|
77357
|
+
const apertureDrawer = new _CircuitToCanvasDrawer(this.ctx);
|
|
77358
|
+
apertureDrawer.realToCanvasMat = this.realToCanvasMat;
|
|
77359
|
+
apertureDrawer.configure({
|
|
77360
|
+
colorOverrides: {
|
|
77361
|
+
copper: {
|
|
77362
|
+
top: transparent,
|
|
77363
|
+
bottom: transparent,
|
|
77364
|
+
inner1: transparent,
|
|
77365
|
+
inner2: transparent,
|
|
77366
|
+
inner3: transparent,
|
|
77367
|
+
inner4: transparent,
|
|
77368
|
+
inner5: transparent,
|
|
77369
|
+
inner6: transparent,
|
|
77370
|
+
inner7: transparent,
|
|
77371
|
+
inner8: transparent
|
|
77372
|
+
},
|
|
77373
|
+
drill: "#000"
|
|
77374
|
+
}
|
|
77375
|
+
});
|
|
77376
|
+
this.ctx.save();
|
|
77377
|
+
this.ctx.globalCompositeOperation = "destination-out";
|
|
77378
|
+
apertureDrawer.drawElements(apertures, {
|
|
77379
|
+
layers: [`${layer}_copper`],
|
|
77380
|
+
showPcbNotes: false
|
|
77381
|
+
});
|
|
77382
|
+
this.ctx.restore();
|
|
77089
77383
|
}
|
|
77090
77384
|
};
|
|
77091
77385
|
var init_dist2 = __esm(() => {
|
|
@@ -77104,6 +77398,8 @@ var init_dist2 = __esm(() => {
|
|
|
77104
77398
|
inner4: "rgb(64, 224, 208)",
|
|
77105
77399
|
inner5: "rgb(138, 43, 226)",
|
|
77106
77400
|
inner6: "rgb(255, 105, 180)",
|
|
77401
|
+
inner7: "rgb(232, 178, 167)",
|
|
77402
|
+
inner8: "rgb(242, 237, 161)",
|
|
77107
77403
|
bottom: "rgb(77, 127, 196)"
|
|
77108
77404
|
},
|
|
77109
77405
|
copperPour: {
|
|
@@ -135146,7 +135442,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
135146
135442
|
// lib/getVersion.ts
|
|
135147
135443
|
import { createRequire as createRequire2 } from "node:module";
|
|
135148
135444
|
// package.json
|
|
135149
|
-
var version = "0.1.
|
|
135445
|
+
var version = "0.1.1894";
|
|
135150
135446
|
var package_default = {
|
|
135151
135447
|
name: "@tscircuit/cli",
|
|
135152
135448
|
version,
|
|
@@ -135197,7 +135493,7 @@ var package_default = {
|
|
|
135197
135493
|
"circuit-json-to-step": "^0.0.38",
|
|
135198
135494
|
"circuit-json-to-tscircuit": "^0.0.42",
|
|
135199
135495
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
135200
|
-
"circuit-to-canvas": "^0.0.
|
|
135496
|
+
"circuit-to-canvas": "^0.0.123",
|
|
135201
135497
|
"circuit-to-svg": "^0.0.393",
|
|
135202
135498
|
commander: "^14.0.0",
|
|
135203
135499
|
conf: "^13.1.0",
|