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

Method setupDrawFromCache

packages/2d/src/lib/components/Node.ts:1496–1522  ·  view source on GitHub ↗

* Prepare the given context for drawing a cached node onto it. * * @remarks * This method is called before the contents of the cache canvas are drawn * on the screen. It can be used to apply effects to the entire node together * with its children, instead of applying them individually

(context: CanvasRenderingContext2D)

Source from the content-addressed store, hash-verified

1494 * @param context - The context using which the cache will be drawn.
1495 */
1496 protected setupDrawFromCache(context: CanvasRenderingContext2D) {
1497 context.globalCompositeOperation = this.compositeOperation();
1498 context.globalAlpha *= this.opacity();
1499 if (this.hasFilters()) {
1500 context.filter = this.filterString();
1501 }
1502 if (this.hasShadow()) {
1503 const matrix = this.compositeToWorld();
1504 const offset = transformVector(this.shadowOffset(), matrix);
1505 const blur = transformScalar(this.shadowBlur(), matrix);
1506
1507 context.shadowColor = this.shadowColor().serialize();
1508 context.shadowBlur = blur;
1509 context.shadowOffsetX = offset.x;
1510 context.shadowOffsetY = offset.y;
1511 }
1512
1513 const matrix = this.worldToLocal();
1514 context.transform(
1515 matrix.a,
1516 matrix.b,
1517 matrix.c,
1518 matrix.d,
1519 matrix.e,
1520 matrix.f,
1521 );
1522 }
1523
1524 protected renderFromSource(
1525 context: CanvasRenderingContext2D,

Callers 1

renderFromSourceMethod · 0.95

Calls 9

hasFiltersMethod · 0.95
filterStringMethod · 0.95
hasShadowMethod · 0.95
compositeToWorldMethod · 0.95
worldToLocalMethod · 0.95
transformVectorFunction · 0.90
transformScalarFunction · 0.90
transformMethod · 0.80
serializeMethod · 0.65

Tested by

no test coverage detected