MCPcopy
hub / github.com/midrender/revideo / getElementStyle

Method getElementStyle

packages/2d/src/lib/components/SVG.ts:579–606  ·  view source on GitHub ↗

* Convert the SVG element's style to a Motion Canvas Shape properties. * @param element - An SVG element whose style should be converted. * @param inheritedStyle - The parent style that should be inherited.

(
    element: SVGGraphicsElement,
    inheritedStyle: ShapeProps,
  )

Source from the content-addressed store, hash-verified

577 * @param inheritedStyle - The parent style that should be inherited.
578 */
579 private static getElementStyle(
580 element: SVGGraphicsElement,
581 inheritedStyle: ShapeProps,
582 ): ShapeProps {
583 return {
584 fill: element.getAttribute('fill') ?? inheritedStyle.fill,
585 stroke: element.getAttribute('stroke') ?? inheritedStyle.stroke,
586 lineWidth: element.hasAttribute('stroke-width')
587 ? parseFloat(element.getAttribute('stroke-width')!)
588 : inheritedStyle.lineWidth,
589 lineCap:
590 this.parseLineCap(element.getAttribute('stroke-linecap')) ??
591 inheritedStyle.lineCap,
592 lineJoin:
593 this.parseLineJoin(element.getAttribute('stroke-linejoin')) ??
594 inheritedStyle.lineJoin,
595 lineDash:
596 this.parseLineDash(element.getAttribute('stroke-dasharray')) ??
597 inheritedStyle.lineDash,
598 lineDashOffset:
599 this.parseDashOffset(element.getAttribute('stroke-dashoffset')) ??
600 inheritedStyle.lineDashOffset,
601 opacity:
602 this.parseOpacity(element.getAttribute('opacity')) ??
603 inheritedStyle.opacity,
604 layout: false,
605 };
606 }
607
608 /**
609 * Extract `SVGShapeData` list from the SVG element's children.

Callers 1

extractElementNodesMethod · 0.80

Calls 5

parseLineCapMethod · 0.95
parseLineJoinMethod · 0.95
parseLineDashMethod · 0.95
parseDashOffsetMethod · 0.95
parseOpacityMethod · 0.95

Tested by

no test coverage detected