// Example: The Square
// Open a window, and draw a colored square in it
use quicksilver::{
geom::{Rectangle, Vector},
graphics::Color,
run, Graphics, Input, Result, Settings, Window,
};
fn main() {
run(
Settings {
title: "Square Example",
..Settings::default()
},
app,
);
}
async fn app(window: Window, mut gfx: Graphics, mut input: Input) -> Result<()> {
// Clear the screen to a blank, white color
gfx.clear(Color::WHITE);
// Paint a blue square with a red outline in the center of our screen
// It should have a top-left of (350, 100) and a size of (150, 100)
let rect = Rectangle::new(Vector::new(350.0, 100.0), Vector::new(100.0, 100.0));
gfx.fill_rect(&rect, Color::BLUE);
gfx.stroke_rect(&rect, Color::RED);
// Send the data to be drawn
gfx.present(&window)?;
loop {
while let Some(_) = input.next_event().await {}
}
}
Thanks to the magic of WebAssembly, if your browser supports both WebAssembly and WebGL, then you can view the examples online with no plugins required.