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

Method draw

packages/2d/src/lib/components/Code.ts:485–511  ·  view source on GitHub ↗
(
    context: CanvasRenderingContext2D,
  )

Source from the content-addressed store, hash-verified

483 }
484
485 protected override async draw(
486 context: CanvasRenderingContext2D,
487 ): Promise<void> {
488 this.requestFontUpdate();
489 this.applyStyle(context);
490 this.applyText(context);
491 const size = this.computedSize();
492 const drawingInfo = this.drawingInfo();
493
494 context.save();
495 context.translate(
496 -size.width / 2,
497 -size.height / 2 + drawingInfo.verticalOffset,
498 );
499
500 const drawHooks = this.drawHooks();
501 for (const info of drawingInfo.fragments) {
502 context.save();
503 context.globalAlpha *= info.alpha;
504 drawHooks.token(context, info.text, info.position, info.fill, info.time);
505 context.restore();
506 }
507
508 context.restore();
509
510 await this.drawChildren(context);
511 }
512
513 protected override applyText(context: CanvasRenderingContext2D) {
514 super.applyText(context);

Callers

nothing calls this directly

Calls 9

applyTextMethod · 0.95
drawingInfoMethod · 0.95
computedSizeMethod · 0.80
translateMethod · 0.80
tokenMethod · 0.80
restoreMethod · 0.80
drawChildrenMethod · 0.80
saveMethod · 0.65
requestFontUpdateMethod · 0.45

Tested by

no test coverage detected