private mkCrocEnd()

in sim/visuals/ltc.ts [583:632]


        private mkCrocEnd(p: [number, number], top: boolean, clr: string): SVGElAndSize {
            //TODO: merge with mkOpenJumperEnd()
            const PIN_DIST = 7;
            let k = PIN_DIST * 0.24;
            const plasticWidth = k * 4;
            const plasticLength = k * 10.0;
            const metalWidth = k * 3.5;
            const metalHeight = k * 3.5;
            const pointScalar = .15;
            const baseScalar = .3;
            const taperScalar = .7;
            const strokeWidth = PIN_DIST / 4.0;
            let [cx, cy] = p;
            let o = top ? -1 : 1;
            let g = svg.elt("g")

            let el = svg.elt("polygon");
            let h1 = plasticLength;
            let w1 = plasticWidth;
            let x1 = cx - w1 / 2;
            let y1 = cy - (h1 / 2);
            let mkPnt = (xy: Coord) => `${xy[0]},${xy[1]}`;
            let mkPnts = (...xys: Coord[]) => xys.map(xy => mkPnt(xy)).join(" ");
            const topScalar = top ? pointScalar : baseScalar;
            const midScalar = top ? taperScalar : (1 - taperScalar);
            const botScalar = top ? baseScalar : pointScalar;
            svg.hydrate(el, {
                points: mkPnts(
                    [x1 + w1 * topScalar, y1], //TL
                    [x1 + w1 * (1 - topScalar), y1], //TR
                    [x1 + w1, y1 + h1 * midScalar], //MR
                    [x1 + w1 * (1 - botScalar), y1 + h1], //BR
                    [x1 + w1 * botScalar, y1 + h1], //BL
                    [x1, y1 + h1 * midScalar]) //ML
            });
            svg.hydrate(el, { rx: 0.5, ry: 0.5, class: "sim-bb-wire-end" });
            (<any>el).style["stroke-width"] = `${strokeWidth}px`;

            let el2 = svg.elt("rect");
            let h2 = metalWidth;
            let w2 = metalHeight;
            let cy2 = cy + o * (h1 / 2 + h2 / 2);
            let x2 = cx - w2 / 2;
            let y2 = cy2 - (h2 / 2);
            svg.hydrate(el2, { x: x2, y: y2, width: w2, height: h2, class: "sim-bb-wire-bare-end" });

            g.appendChild(el2);
            g.appendChild(el);
            return { el: g, x: x1 - strokeWidth, y: Math.min(y1, y2), w: w1 + strokeWidth * 2, h: h1 + h2 };
        }