Skip to content

Commit 8ce1a04

Browse files
committed
rename params to match promaster
1 parent baab3e5 commit 8ce1a04

File tree

10 files changed

+97
-43
lines changed

10 files changed

+97
-43
lines changed

packages/abstract-3d/src/renderers/svg/svg-geometries/shared.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ export type ImageDataUri =
1818

1919
export type SvgOptions = {
2020
readonly view: View;
21-
readonly stroke: number;
21+
readonly stroke_thickness: number;
22+
readonly only_stroke: boolean;
23+
readonly gray_scale: boolean;
24+
readonly only_stroke_fill: string;
25+
readonly rotation: number;
26+
2227
readonly scale: { readonly size: number; readonly scaleByWidth: boolean } | undefined;
23-
readonly onlyStroke: boolean;
24-
readonly grayScale: boolean;
25-
readonly onlyStrokeFill: string;
2628
readonly font: string;
2729
readonly imageDataByUrl: Record<string, ImageDataUri>;
28-
readonly rotation: number;
2930
};
3031

3132
export function eulerToSvgMatrix(rot: Vec3, pos: Vec2): string {

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-box.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function box(
2121
opts: SvgOptions,
2222
parentPos: Vec3,
2323
parentRot: Vec3,
24-
factor: number,
24+
factor: number
2525
): ReadonlyArray<zOrderElement> {
2626
const half = vec3Scale(b.size, 0.5);
2727
const pos = vec3TransRot(b.pos, parentPos, parentRot);
@@ -60,9 +60,9 @@ export function box(
6060

6161
const color = material.normal;
6262
const opacity = material.opacity ?? 1.0;
63-
const [strokeColor, fill, strokeUse] = opts.onlyStroke
64-
? [opts.grayScale ? gray : color, opts.onlyStrokeFill, opts.stroke]
65-
: [black, opts.grayScale ? rgbGrayScale(color) : color, 0];
63+
const [strokeColor, fill, strokeUse] = opts.only_stroke
64+
? [opts.gray_scale ? gray : color, opts.only_stroke_fill, opts.stroke_thickness]
65+
: [black, opts.gray_scale ? rgbGrayScale(color) : color, 0];
6666

6767
return [
6868
zElem(svgPolygon(factor, rot, frontBackPoints, fill, opacity, strokeColor, strokeUse, b.holes), frontBackMean),

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-cone.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export function cone(
3030

3131
const color = material.normal;
3232
const opacity = material.opacity ?? 1.0;
33-
const [stroke, fill] = opts.onlyStroke
34-
? [opts.grayScale ? gray : color, opts.onlyStrokeFill]
35-
: [transparent, opts.grayScale ? rgbGrayScale(color) : color];
33+
const [stroke, fill] = opts.only_stroke
34+
? [opts.gray_scale ? gray : color, opts.only_stroke_fill]
35+
: [transparent, opts.gray_scale ? rgbGrayScale(color) : color];
3636
const zOrderComponents = Array<zOrderElement>();
3737

3838
const sides = 8;
@@ -52,7 +52,9 @@ export function cone(
5252
point(topPos.x, topPos.y),
5353
point(topPos.x, topPos.y),
5454
];
55-
zOrderComponents.push(zElem(svgPolygon(factor, rot, points, fill, opacity, stroke, stBW), vec3ZMean(currBot, prevBot, topPos)));
55+
zOrderComponents.push(
56+
zElem(svgPolygon(factor, rot, points, fill, opacity, stroke, stBW), vec3ZMean(currBot, prevBot, topPos))
57+
);
5658
}
5759
currentAngle += angleStep;
5860
}
@@ -62,7 +64,10 @@ export function cone(
6264
const cylBottom = vec3tr(vec3(0, -half.y, 0));
6365
if (equals(cylTop.x, cylBottom.x, 0.1) && equals(cylTop.y, cylBottom.y, 0.1)) {
6466
zOrderComponents.push(
65-
zElem(svgCircle(factor * c.radius, rot, point(cylBottom.x, cylBottom.y), fill, opacity, stroke, stBW, factor), cylBottom.z)
67+
zElem(
68+
svgCircle(factor * c.radius, rot, point(cylBottom.x, cylBottom.y), fill, opacity, stroke, stBW, factor),
69+
cylBottom.z
70+
)
6671
);
6772
}
6873

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-cylinder.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export function cylinder(
3030

3131
const color = material.normal;
3232
const opacity = material.opacity ?? 1.0;
33-
const [stroke, fill] = opts.onlyStroke
34-
? [opts.grayScale ? gray : color, opts.onlyStrokeFill]
35-
: [transparent, opts.grayScale ? rgbGrayScale(color) : color];
33+
const [stroke, fill] = opts.only_stroke
34+
? [opts.gray_scale ? gray : color, opts.only_stroke_fill]
35+
: [transparent, opts.gray_scale ? rgbGrayScale(color) : color];
3636
const zOrderComponents = Array<zOrderElement>();
3737

3838
const sides = 8;
@@ -59,7 +59,10 @@ export function cylinder(
5959
point(currTop.x, currTop.y),
6060
];
6161
zOrderComponents.push(
62-
zElem(svgPolygon(factor, rot, points, fill, opacity, stroke, stBW), vec3ZMean(currBot, prevBot, currTop, prevTop))
62+
zElem(
63+
svgPolygon(factor, rot, points, fill, opacity, stroke, stBW),
64+
vec3ZMean(currBot, prevBot, currTop, prevTop)
65+
)
6366
);
6467
}
6568
currentAngle += angleStep;
@@ -71,7 +74,20 @@ export function cylinder(
7174
if (equals(circleTop.x, circleBottom.x, 0.1) && equals(circleTop.y, circleBottom.y, 0.1)) {
7275
const circlePos = circleTop.z > circleBottom.z ? circleTop : circleBottom;
7376
zOrderComponents.push(
74-
zElem(svgCircle(factor * c.radius, rot, point(circlePos.x, circlePos.y), fill, opacity, stroke, stBW, factor, c.holes), circlePos.z)
77+
zElem(
78+
svgCircle(
79+
factor * c.radius,
80+
rot,
81+
point(circlePos.x, circlePos.y),
82+
fill,
83+
opacity,
84+
stroke,
85+
stBW,
86+
factor,
87+
c.holes
88+
),
89+
circlePos.z
90+
)
7591
);
7692
}
7793
}

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-line.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function line(
1515
const v2 = vec3TransRot(l.end, parentPos, parentRot);
1616
return [
1717
zElem(
18-
svgLine(point(v1.x, v1.y), point(v2.x, v2.y), opts.grayScale ? rgbGrayScale(fill) : fill, l.thickness),
18+
svgLine(point(v1.x, v1.y), point(v2.x, v2.y), opts.gray_scale ? rgbGrayScale(fill) : fill, l.thickness),
1919
vec3ZMean(v1, v2)
2020
),
2121
];

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-plane.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export function plane(
6060

6161
const points = [point(v1.x, v1.y), point(v2.x, v2.y), point(v3.x, v3.y), point(v4.x, v4.y)];
6262

63-
const [strokeColor, fill, strokeThickness] = opts.onlyStroke
64-
? [opts.grayScale ? gray : material.normal, opts.onlyStrokeFill, opts.stroke]
65-
: [black, opts.grayScale ? rgbGrayScale(material.normal) : material.normal, 0];
63+
const [strokeColor, fill, strokeThickness] = opts.only_stroke
64+
? [opts.gray_scale ? gray : material.normal, opts.only_stroke_fill, opts.stroke_thickness]
65+
: [black, opts.gray_scale ? rgbGrayScale(material.normal) : material.normal, 0];
6666
return [
6767
zElem(
6868
svgPolygon(factor, rot, points, fill, material.opacity ?? 1.0, strokeColor, strokeThickness, holes),

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-polygon.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Polygon, vec3ZMean, Vec3, Vec2, vec3TransRot, vec3RotCombine, vec3Zero, Material } from "../../../abstract-3d.js";
1+
import {
2+
Polygon,
3+
vec3ZMean,
4+
Vec3,
5+
Vec2,
6+
vec3TransRot,
7+
vec3RotCombine,
8+
vec3Zero,
9+
Material,
10+
} from "../../../abstract-3d.js";
211
import { gray, zElem, zOrderElement, transparent, SvgOptions } from "./shared.js";
312
import { svgPolygon } from "../svg-encoding.js";
413
import { rgbGrayScale } from "../../shared.js";
@@ -17,8 +26,13 @@ export function polygon(
1726
const rotatedPoints = p.points.map((p) => vec3TransRot(p, pos, rot));
1827
const points = rotatedPoints.map(({ x, y }) => point(x, y));
1928
const color = material.normal;
20-
const [strokeColor, fill, strokeThickness] = opts.onlyStroke
21-
? [opts.grayScale ? gray : color, opts.onlyStrokeFill, opts.stroke]
22-
: [transparent, opts.grayScale ? rgbGrayScale(color) : color, 0];
23-
return [zElem(svgPolygon(factor, rot, points, fill, material.opacity ?? 1.0, strokeColor, strokeThickness), vec3ZMean(...rotatedPoints))];
29+
const [strokeColor, fill, strokeThickness] = opts.only_stroke
30+
? [opts.gray_scale ? gray : color, opts.only_stroke_fill, opts.stroke_thickness]
31+
: [transparent, opts.gray_scale ? rgbGrayScale(color) : color, 0];
32+
return [
33+
zElem(
34+
svgPolygon(factor, rot, points, fill, material.opacity ?? 1.0, strokeColor, strokeThickness),
35+
vec3ZMean(...rotatedPoints)
36+
),
37+
];
2438
}

packages/abstract-3d/src/renderers/svg/svg-geometries/svg-shape.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
import { vec3ZMean, Vec3, Vec2, vec3TransRot, vec3RotCombine, Shape, vec3, vec3Zero, Material } from "../../../abstract-3d.js";
1+
import {
2+
vec3ZMean,
3+
Vec3,
4+
Vec2,
5+
vec3TransRot,
6+
vec3RotCombine,
7+
Shape,
8+
vec3,
9+
vec3Zero,
10+
Material,
11+
} from "../../../abstract-3d.js";
212
import { gray, zElem, zOrderElement, transparent, SvgOptions } from "./shared.js";
313
import { svgPolygon } from "../svg-encoding.js";
414
import { rgbGrayScale } from "../../shared.js";
@@ -17,8 +27,10 @@ export function shape(
1727
const rotatedPoints = s.points.map((p) => vec3TransRot(vec3(p.x, p.y, 0), pos, rot));
1828
const points = rotatedPoints.map(({ x, y }) => point(x, y));
1929
const color = material.normal;
20-
const [strokeColor, fill] = opts.onlyStroke
21-
? [opts.grayScale ? gray : color, opts.onlyStrokeFill]
22-
: [transparent, opts.grayScale ? rgbGrayScale(color) : color];
23-
return [zElem(svgPolygon(factor, rot, points, fill, material.opacity ?? 1.0, strokeColor, 0), vec3ZMean(...rotatedPoints))];
30+
const [strokeColor, fill] = opts.only_stroke
31+
? [opts.gray_scale ? gray : color, opts.only_stroke_fill]
32+
: [transparent, opts.gray_scale ? rgbGrayScale(color) : color];
33+
return [
34+
zElem(svgPolygon(factor, rot, points, fill, material.opacity ?? 1.0, strokeColor, 0), vec3ZMean(...rotatedPoints)),
35+
];
2436
}

packages/abstract-3d/src/renderers/svg/svg.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function renderInternal(
8484
): { readonly elements: ReadonlyArray<zOrderElement>; readonly width: number; readonly height: number } {
8585
const opts: SvgOptions = {
8686
view: options?.view ?? "front",
87-
stroke: options?.stroke ?? 2,
87+
stroke_thickness: options?.stroke_thickness ?? 2,
8888
scale: options?.scale ?? undefined,
89-
onlyStroke: options?.onlyStroke ?? false,
90-
grayScale: options?.grayScale ?? false,
91-
onlyStrokeFill: options?.onlyStrokeFill ?? "rgba(255,255,255,0)",
89+
only_stroke: options?.only_stroke ?? false,
90+
gray_scale: options?.gray_scale ?? false,
91+
only_stroke_fill: options?.only_stroke_fill ?? "rgba(255,255,255,0)",
9292
font: options?.font ?? "",
9393
imageDataByUrl: options?.imageDataByUrl ?? {},
9494
rotation: options?.rotation ?? 0,
@@ -108,10 +108,10 @@ function renderInternal(
108108
const unitRot = opts.rotation ? vec3RotCombine(vec3(0, 0, (opts.rotation * Math.PI) / 180), baseRot) : baseRot;
109109
const unitPos = vec3Rot(scene.center_deprecated ?? vec3Zero, vec3Zero, scene.rotation_deprecated ?? vec3Zero);
110110
const [size, center] = sizeCenterForCameraPos(scene.size_deprecated, unitPos, unitRot, factor);
111-
const width = size.x + 1.5 * opts.stroke;
112-
const height = size.y + 1.5 * opts.stroke;
111+
const width = size.x + 1.5 * opts.stroke_thickness;
112+
const height = size.y + 1.5 * opts.stroke_thickness;
113113
const unitHalfSize = vec3Scale(size, 0.5);
114-
const centerAdj = vec3(center.x - opts.stroke * 0.75, center.y + opts.stroke * 0.75, center.z);
114+
const centerAdj = vec3(center.x - opts.stroke_thickness * 0.75, center.y + opts.stroke_thickness * 0.75, center.z);
115115
const elements = Array<zOrderElement>();
116116
const point = (x: number, y: number): Vec2 =>
117117
vec2(-centerAdj.x + unitHalfSize.x + x * factor + offset.x, centerAdj.y + unitHalfSize.y - y * factor + offset.y);
@@ -121,7 +121,7 @@ function renderInternal(
121121
const rot = vec3RotCombine(unitRot, g.rot ?? vec3Zero);
122122
elements.push(...svgGroup(g, pos, rot, point, factor, opts));
123123
}
124-
const dimOpts: SvgOptions = { ...opts, onlyStroke: false, grayScale: false };
124+
const dimOpts: SvgOptions = { ...opts, only_stroke: false, gray_scale: false };
125125
elements.sort((a, b) => a.zOrder - b.zOrder);
126126
const cameraPos = vec3Rot(vec3(1, 1, 1), vec3Zero, scene.rotation_deprecated ?? vec3Zero);
127127
for (const d of scene.dimensions_deprecated?.dimensions ?? []) {

packages/abstract-visuals-example/src/app/abstract-3d-example.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ export function Abstract3DExample(): React.ReactNode {
3232
onClick={() =>
3333
FileSaver.saveAs(
3434
new Blob(
35-
[Svg.render(systemair, { view: "front", stroke: 2, scale: { size: 180, scaleByWidth: true } }).image],
35+
[
36+
Svg.render(systemair, {
37+
view: "front",
38+
stroke_thickness: 2,
39+
scale: { size: 180, scaleByWidth: true },
40+
}).image,
41+
],
3642
{
3743
type: "text/plain",
3844
}
@@ -49,7 +55,7 @@ export function Abstract3DExample(): React.ReactNode {
4955
dangerouslySetInnerHTML={{
5056
__html: Svg.render(systemair, {
5157
view: "front",
52-
stroke: 1,
58+
stroke_thickness: 1,
5359
scale: { size: 400, scaleByWidth: true },
5460
rotation: 270,
5561
}).image,

0 commit comments

Comments
 (0)