pub fn make_indexed_image<F: FnOnce(&mut Graphics<'_>)>(
width: usize,
height: usize,
simplify_palette: bool,
method: F,
) -> Result<IndexedImage, GraphicsError>
Expand description
Create an indexed image width
xheight
px and then run drawing commands on it
§Params
simplify_palette
if true and there’s more than 255 colours, this will simplify/merge the palette until there are under 255 colours
§Usage
let image: Result<IndexedImage, GraphicsError> = make_indexed_image(30, 30, true, |g| {
g.clear(BLACK);
g.draw_rect(Rect::new(coord!(0,0), coord!(29,29)), stroke(WHITE))
});
§Errors
GraphicsError::TooManyColors
Over 255 colors have been used andsimplify_palette
was falseGraphicsError::TooBig
Image is bigger than 255x255