// Copyright (c) 2026 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT // Up to 4 black letterbox/pillarbox bars sized from Screen.scanX/Y/ // scanWidth/scanHeight vs Screen.width/height. Recomputed every tick, // unconditionally -- cheap (four rectangle field writes), and a no-op // when the scan area already covers the full viewport (Rectangle // already skips rendering at width/height <= 0). class Crop extends UIElement { init() { this.top = new Rectangle(); this.bottom = new Rectangle(); this.left = new Rectangle(); this.right = new Rectangle(); this.top.color = Crop.COLOR_BARS; this.bottom.color = Crop.COLOR_BARS; this.left.color = Crop.COLOR_BARS; this.right.color = Crop.COLOR_BARS; this.add(this.top); this.add(this.bottom); this.add(this.left); this.add(this.right); } update() { this.updateChildren(); this._refresh(); } _refresh() { const scanX = Screen.scanX; const scanY = Screen.scanY; const scanRight = scanX + Screen.scanWidth; const scanBottom = scanY + Screen.scanHeight; this.top.x = 0; this.top.y = 0; this.top.width = Screen.width; this.top.height = scanY; this.bottom.x = 0; this.bottom.y = scanBottom; this.bottom.width = Screen.width; this.bottom.height = Screen.height - scanBottom; this.left.x = 0; this.left.y = scanY; this.left.width = scanX; this.left.height = Screen.scanHeight; this.right.x = scanRight; this.right.y = scanY; this.right.width = Screen.width - scanRight; this.right.height = Screen.scanHeight; } } Crop.COLOR_BARS = { r: 0, g: 0, b: 0, a: 255 }; module.exports = Crop;