FXGL
FXGL copied to clipboard
Images.kt map() does not check sizes of given images
In Images.kt file, fun Image.map(overlay: Image, f: (Pixel, Pixel) -> Pixel): Image
combines overlay
and this
to produce a new Image
using the function f
to map pixels from the two images. The call, as of now, will fail if overlay
width or height is smaller than this
.
I'm not sure what the expected (most intuitive?) behaviour should be. It appears we have the following options:
- Resize
overlay
to matchthis
- Use
overlay
"as is", then the returned image size has the highest width / height of the two (e.g.max(this.width, overlay.width)
). Non-existent pixels are substituted with transparent color pixels.
Suggestions are welcome.
I think, another option it is to add to map function third parameter (let's say mapType enum), which will define the type of mapping: STRICT - as it is; CENTER - overlay will be applied to center of the image; HORIZONTAL_FILL - overlay will be resized without change of proportions to match width of the image; VERTICAL_FILL - same as horizontal, though with height matching; STRETCH - resize overlay to fully fit the image; STRETCH_PROPORTINAL - resize to fully fit the image, saving proprtions; TILE - tile overlay over image;
well, maybe it is better to have them as different functions.