MCPcopy Index your code
hub / github.com/rough-stuff/rough-notation / render

Method render

src/rough-notation.ts:206–225  ·  view source on GitHub ↗
(svg: SVGSVGElement, ensureNoAnimation: boolean)

Source from the content-addressed store, hash-verified

204 }
205
206 private render(svg: SVGSVGElement, ensureNoAnimation: boolean) {
207 let config = this._config;
208 if (ensureNoAnimation) {
209 config = JSON.parse(JSON.stringify(this._config));
210 config.animate = false;
211 }
212 const rects = this.rects();
213 let totalWidth = 0;
214 rects.forEach((rect) => totalWidth += rect.w);
215 const totalDuration = (config.animationDuration || DEFAULT_ANIMATION_DURATION);
216 let delay = 0;
217 for (let i = 0; i < rects.length; i++) {
218 const rect = rects[i];
219 const ad = totalDuration * (rect.w / totalWidth);
220 renderAnnotation(svg, rects[i], config, delay + this._animationDelay, ad, this._seed);
221 delay += ad;
222 }
223 this._lastSizes = rects;
224 this._state = 'showing';
225 }
226
227 private rects(): Rect[] {
228 const ret: Rect[] = [];

Callers 1

showMethod · 0.95

Calls 2

rectsMethod · 0.95
renderAnnotationFunction · 0.85

Tested by

no test coverage detected