Created
February 11, 2017 23:52
-
-
Save xTibor/ff1b1a040a0716338d73655ff85d1229 to your computer and use it in GitHub Desktop.
Gradient Test Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate orbclient; | |
use orbclient::{Color, Window, Renderer, EventOption}; | |
fn render(window: &mut Window, px: i32, py: i32) { | |
let color_start = Color::rgb(0, 0, 0); | |
let color_end = Color::rgb(255, 255, 255); | |
let color_line = Color::rgb(255, 0, 0); | |
let (cx, cy) = (300, 300); | |
window.rect(0, 0, 600, 300, color_start); | |
window.rect(0, 300, 600, 300, color_end); | |
window.linear_gradient( | |
50, 50, 500, 500, | |
cx, cy, px, py, | |
color_start, color_end | |
); | |
window.line(cx, cy, px, py, color_line); | |
window.sync(); | |
} | |
fn main() { | |
let mut window = Window::new(60, 60, 600, 600, "Gradient Test Application").unwrap(); | |
render(&mut window, 0, 0); | |
'events: loop { | |
for event in window.events() { | |
match event.to_option() { | |
EventOption::Mouse(mouse_event) => { | |
render(&mut window, mouse_event.x, mouse_event.y); | |
} | |
EventOption::Quit(_quit_event) => break 'events, | |
event_option => println!("{:?}", event_option) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment