/** Ensures that the canvas image is at least the specified dimensions and cleared to all * transparent pixels. Also creates and adds the image layer to the parent layer if needed. */ public void prepare (Graphics gfx, float width, float height) { CanvasLayer layer = _layer; if (layer == null) { layer = new CanvasLayer(gfx, width, height); if (_depth != null) layer.setDepth(_depth); _parent.add(layer); _layer = layer; } else if (layer.width() < width || layer.height() < height) { // TODO: should we ever shrink it? layer.resize(width, height); } _preparedWidth = width; _preparedHeight = height; }