use flo_draw::*; use flo_canvas::*; /// /// Simple example that displays a canvas window and renders a triangle /// pub fn main() { // 'with_2d_graphics' is used to support operating systems that can't run event loops anywhere other than the main thread with_2d_graphics(|| { // Create a window let canvas = create_drawing_window("Canvas window"); // Render a triangle to it canvas.draw(|gc| { // Clear the canvas and set up the coordinates gc.clear_canvas(Color::Rgba(0.3, 0.2, 0.0, 1.0)); gc.canvas_height(1000.0); gc.center_region(0.0, 0.0, 1000.0, 1000.0); // Draw a rectangle... gc.new_path(); gc.move_to(0.0, 0.0); gc.line_to(1000.0, 0.0); gc.line_to(1000.0, 1000.0); gc.line_to(0.0, 1000.0); gc.line_to(0.0, 0.0); gc.fill_color(Color::Rgba(1.0, 1.0, 0.8, 1.0)); gc.fill(); // Draw a triangle on top gc.new_path(); gc.move_to(200.0, 200.0); gc.line_to(800.0, 200.0); gc.line_to(500.0, 800.0); gc.line_to(200.0, 200.0); gc.fill_color(Color::Rgba(0.0, 0.0, 0.8, 1.0)); gc.fill(); }); }); }