* Draw a TMX tile layer. Default behavior: * - if `layer.canvasRenderer` is set (preRender bake), blit the cached * offscreen canvas in a single `drawImage` call; * - otherwise delegate to the layer's TMX orientation renderer for * the per-tile loop. * * `WebGLRenderer` overr
(layer, rect)
| 568 | * @param {Rect} rect - the visible region in world coords |
| 569 | */ |
| 570 | drawTileLayer(layer, rect) { |
| 571 | if (layer.canvasRenderer) { |
| 572 | // clamp the source rect to the cached canvas bounds — the |
| 573 | // visible region can start inside the layer (camera scrolled |
| 574 | // in from the origin) and extend past the layer's right / |
| 575 | // bottom edge, so the source width must be reduced by |
| 576 | // `rect.pos.*` to avoid reading past the canvas |
| 577 | const width = Math.min(rect.width, layer.width - rect.pos.x); |
| 578 | const height = Math.min(rect.height, layer.height - rect.pos.y); |
| 579 | if (width <= 0 || height <= 0) { |
| 580 | return; |
| 581 | } |
| 582 | this.drawImage( |
| 583 | layer.canvasRenderer.getCanvas(), |
| 584 | rect.pos.x, |
| 585 | rect.pos.y, |
| 586 | width, |
| 587 | height, |
| 588 | rect.pos.x, |
| 589 | rect.pos.y, |
| 590 | width, |
| 591 | height, |
| 592 | ); |
| 593 | return; |
| 594 | } |
| 595 | layer.getRenderer().drawTileLayer(this, layer, rect); |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * Set the current fill & stroke style color. |
no test coverage detected