alexandercampbell / simple Goto Github PK
View Code? Open in Web Editor NEWThe simplest Rust graphics library, inspired by LOVE2D.
Home Page: https://crates.io/crates/simple
The simplest Rust graphics library, inspired by LOVE2D.
Home Page: https://crates.io/crates/simple
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();
This library needs support for text drawing functions.
// use the default font
app.print("Monday", 32, 96);
// load a different font
let font = simple::Font::from_file(Path::new("my_font.ttf"));
app.set_font(font);
app.print("Monday", 64, 96);
// Wrap text inside of a rect.
// this will probably end up looking like
//
// Monday is my
// favorite day
// of the entire
// week!
//
app.print_rect("Monday is my favorite day of the entire week!", simple::Rect{
x: 96,
y: 96,
w: 128,
h: 512,
})
This project should have a TUTORIAL.md
that shows how to make a small game.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.