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

Method calculateWrapperScale

packages/2d/src/lib/components/SVG.ts:150–166  ·  view source on GitHub ↗
(
    documentSize: Vector2,
    parentSize: SerializedVector2<number | null>,
  )

Source from the content-addressed store, hash-verified

148 }
149
150 protected calculateWrapperScale(
151 documentSize: Vector2,
152 parentSize: SerializedVector2<number | null>,
153 ) {
154 const result = new Vector2(1, 1);
155 if (parentSize.x && parentSize.y) {
156 result.x = parentSize.x / documentSize.width;
157 result.y = parentSize.y / documentSize.height;
158 } else if (parentSize.x && !parentSize.y) {
159 result.x = parentSize.x / documentSize.width;
160 result.y = result.x;
161 } else if (!parentSize.x && parentSize.y) {
162 result.y = parentSize.y / documentSize.height;
163 result.x = result.y;
164 }
165 return result;
166 }
167
168 /**
169 * Convert `SVGDocumentData` to `SVGDocument`.

Callers 3

desiredSizeMethod · 0.95
tweenSvgMethod · 0.95
wrapperScaleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected