sprite sheet capability
Hi, your library is indeed simple and lacks an important simple feature, being able to draw a rectangle portion of an image. Your draw_image code seems to allow setting the (x,y) of the rendering rectangle, but not the (w,h). I thought (SDL2 canvas)[https://docs.rs/sdl2/0.34.5/sdl2/render/struct.Canvas.html#method.copy] went more like:
// the frame of the image on the sprite sheet
let frame = Rect {
x:64,
y:0,
w:64,
h:64,
};
// the screen size
let (width, height) = canvas.output_size()?
let screen_rectangle = Rect {
x:0,
y:0,
w:width,
h:height,
};
canvas.copy(&texture, frame, screen_rectangle);
However in your (code)[https://github.com/alexandercampbell/simple/blob/master/src/window.rs#L224] is looks like
// copy the texture onto the drawer()
self.canvas
.copy(
&(image.texture),
Some(shape::Rect::new(
// I think this is not what you intend to do
x,
y,
// this should be editable
image.get_width() as u32,
image.get_height() as u32,
)),
// this should be different I think
None,
)
.unwrap();
Hey, I dont prefer using this library cuz its not the only feature unavailable in the library there are many more,u could try using ggez or macroquad (or sdl2),now to your problem: u could try modifying the function to take width and height as parameters this will solve your problem
@zealouscarrot I have played with macroquad and it has some serious issues on linux (audio is a big issue) UI theming is not complete. I may look back at ggez again, but there was a reason I wanted to use this one. I suppose I could just make my own fixed version of this, but it would seem to be better if this dev was involved, and I could just PR a fix, or at least understand what the code was trying to do....