Skip to content

Commit 8a12951

Browse files
authored
Merge pull request #24 from veillette/claude/carousel-lens-icons-UmNMc
Redesign lens carousel icons to better match actual lens shapes
2 parents ce5451f + d50a651 commit 8a12951

1 file changed

Lines changed: 49 additions & 29 deletions

File tree

src/common/view/carousel/CarouselIcons.ts

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,35 @@ export function biconvexLensIcon(): Node {
548548

549549
export function biconcaveLensIcon(): Node {
550550
const node = new Node();
551-
const lensCenterOffsetX = 18;
552-
const surfaceArcRadius = 12;
553-
const arcHalfAngle = Math.PI / 2.5;
551+
const halfHeight = 12;
552+
const cornerX = 8;
553+
const apexX = 4;
554554
const outlineWidth = 1.5;
555555

556+
// Compute arc center so the arc passes through (±cornerX, ±halfHeight) and (apexX, 0).
557+
const arcCenterX = (apexX * apexX - cornerX * cornerX - halfHeight * halfHeight) / (2 * (apexX - cornerX));
558+
const arcRadius = Math.abs(apexX - arcCenterX);
559+
556560
const shape = new Shape()
557-
.arc(lensCenterOffsetX, 0, surfaceArcRadius, Math.PI - arcHalfAngle, Math.PI + arcHalfAngle)
558-
.arc(-lensCenterOffsetX, 0, surfaceArcRadius, -arcHalfAngle, arcHalfAngle)
561+
.moveTo(-cornerX, -halfHeight)
562+
.lineTo(cornerX, -halfHeight)
563+
.arc(
564+
arcCenterX,
565+
0,
566+
arcRadius,
567+
Math.atan2(-halfHeight, cornerX - arcCenterX),
568+
Math.atan2(halfHeight, cornerX - arcCenterX),
569+
true,
570+
)
571+
.lineTo(-cornerX, halfHeight)
572+
.arc(
573+
-arcCenterX,
574+
0,
575+
arcRadius,
576+
Math.atan2(halfHeight, -cornerX + arcCenterX),
577+
Math.atan2(-halfHeight, -cornerX + arcCenterX),
578+
true,
579+
)
559580
.close();
560581
node.addChild(
561582
new Path(shape, {
@@ -570,23 +591,14 @@ export function biconcaveLensIcon(): Node {
570591
export function planoConvexLensIcon(): Node {
571592
const node = new Node();
572593
const halfHeight = 12;
573-
const flatEdgeX = 10;
574-
const convexArcCenterX = 16;
575-
const convexDepth = 20;
576594
const outlineWidth = 1.5;
577595

578-
const shape = new Shape()
579-
.moveTo(flatEdgeX, -halfHeight)
580-
.arc(
581-
convexArcCenterX,
582-
0,
583-
Math.hypot(convexDepth, halfHeight),
584-
-Math.atan2(halfHeight, convexDepth),
585-
+Math.atan2(halfHeight, convexDepth),
586-
false,
587-
)
588-
.lineTo(flatEdgeX, halfHeight)
589-
.close();
596+
// Plano-convex: flat left side, convex right side.
597+
// Drawn as a D-shape: the convex arc sweeps from bottom-left to top-left through
598+
// the rightmost apex, then close() draws the flat left edge.
599+
// Arc center at x = -halfHeight/2 places the apex at x = +halfHeight/2.
600+
const arcCenterX = -halfHeight / 2;
601+
const shape = new Shape().arc(arcCenterX, 0, halfHeight, -Math.PI / 2, Math.PI / 2, false).close();
590602
node.addChild(
591603
new Path(shape, {
592604
fill: OpticsLabColors.glassFillProperty,
@@ -600,21 +612,29 @@ export function planoConvexLensIcon(): Node {
600612
export function planoConcaveLensIcon(): Node {
601613
const node = new Node();
602614
const halfHeight = 12;
603-
const flatEdgeX = -4;
604-
const concaveArcCenterX = 16;
605-
const concaveDepth = 10;
615+
const flatEdgeX = -6;
616+
const cornerX = 6;
617+
const concaveApexX = 0;
606618
const outlineWidth = 1.5;
607619

620+
// Plano-concave: flat left side, concave right side (curves inward toward center).
621+
// Concave arc passes through (cornerX, ±halfHeight) and (concaveApexX, 0).
622+
const arcCenterX =
623+
(concaveApexX * concaveApexX - cornerX * cornerX - halfHeight * halfHeight) / (2 * (concaveApexX - cornerX));
624+
const arcRadius = Math.abs(concaveApexX - arcCenterX);
625+
608626
const shape = new Shape()
609-
.moveTo(flatEdgeX, halfHeight)
627+
.moveTo(flatEdgeX, -halfHeight)
628+
.lineTo(cornerX, -halfHeight)
610629
.arc(
611-
concaveArcCenterX,
630+
arcCenterX,
612631
0,
613-
Math.hypot(concaveDepth, halfHeight),
614-
Math.PI - Math.atan2(halfHeight, concaveDepth),
615-
Math.PI + Math.atan2(halfHeight, concaveDepth),
632+
arcRadius,
633+
Math.atan2(-halfHeight, cornerX - arcCenterX),
634+
Math.atan2(halfHeight, cornerX - arcCenterX),
635+
true,
616636
)
617-
.lineTo(flatEdgeX, -halfHeight)
637+
.lineTo(flatEdgeX, halfHeight)
618638
.close();
619639
node.addChild(
620640
new Path(shape, {

0 commit comments

Comments
 (0)