* 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)
| 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, |
no test coverage detected