1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
//! # Embedded graphics simulator //! //! ![It can display all sorts of embedded-graphics test code.](https://raw.githubusercontent.com/jamwaffles/embedded-graphics/master/assets/simulator-demo.png) //! //! The simulator can be used to test and debug //! [embedded-graphics](https://crates.io/crates/embedded-graphics) code, or produce snazzy examples //! for people to try drivers out without needing physical hardware to run on. //! //! # Setup //! //! The simulator uses SDL and its development libraries which must be installed to build and run //! it. //! //! ## Linux (`apt`) //! //! ```bash //! sudo apt install libsdl2-dev //! ``` //! //! ## macOS (`brew`) //! //! ```bash //! brew install sdl2 //! ``` //! //! ## Windows //! //! The Windows install process is a bit more involved, but it _does_ work. See [the SDL2 //! wiki](https://wiki.libsdl.org/Installation#WinRT.2FWindows_8.2FWinPhone) for instructions. //! //! # Examples //! //! ## Simulate a 128x64 SSD1306 OLED //! //! ```rust,no_run //! use embedded_graphics::pixelcolor::BinaryColor; //! use embedded_graphics::prelude::*; //! use embedded_graphics::{egcircle, egline, egtext, primitive_style, text_style}; //! use embedded_graphics::fonts::Font6x8; //! use embedded_graphics_simulator::{ //! BinaryColorTheme, SimulatorDisplay, SimulatorEvent, WindowBuilder, //! }; //! use std::thread; //! use std::time::Duration; //! //! fn main() { //! let mut display = SimulatorDisplay::new(Size::new(128, 64)); //! let mut window = WindowBuilder::new(&display) //! .theme(BinaryColorTheme::OledBlue) //! .build(); //! //! egtext!(text = "Hello World!", top_left = Point::zero(), style = text_style!(font = Font6x8)).draw(&mut display); //! //! egcircle!(center = (96, 32), radius = 31, style = primitive_style!(stroke_color = BinaryColor::On)).draw(&mut display); //! //! egline!(start = (32, 32), end = (1, 32), style = primitive_style!(stroke_color = BinaryColor::On)) //! .translate(Point::new(64, 0)) //! .draw(&mut display); //! egline!(start = (32, 32), end = (40, 40), style = primitive_style!(stroke_color = BinaryColor::On)) //! .translate(Point::new(64, 0)) //! .draw(&mut display); //! //! 'running: loop { //! window.update(&display); //! //! for event in window.events() { //! match event { //! SimulatorEvent::MouseButtonUp { point, .. } => { //! println!("Click event at ({}, {})", point.x, point.y); //! } //! SimulatorEvent::Quit => break 'running, //! _ => {} //! } //! //! thread::sleep(Duration::from_millis(200)); //! } //! } //! } //! ``` #![deny(missing_docs)] mod check_readme; mod display; mod theme; mod window; mod window_builder; pub use crate::{ display::SimulatorDisplay, theme::BinaryColorTheme, window::{SimulatorEvent, Window}, window_builder::WindowBuilder, };