Skip to content

Instantly share code, notes, and snippets.

@xTibor
Created February 11, 2017 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xTibor/ff1b1a040a0716338d73655ff85d1229 to your computer and use it in GitHub Desktop.
Save xTibor/ff1b1a040a0716338d73655ff85d1229 to your computer and use it in GitHub Desktop.
Gradient Test Application
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