use graphicility::{Color, Vec2};
fn main() {
let mut box_pos = Vec2 { x: 100, y: 100 };
let box_size = Vec2 { x: 50, y: 50 };
graphicility::run( move |ctx| {
let (g, input) = ctx.split();
g.clear(Color::BLACK);
let mouse = input.mouse_pos();
let mut color = Color::BLUE;
if let Some(m) = mouse {
let x = m.0.floor() as i32;
let y = m.1.floor() as i32;
if x >= box_pos.x && x <= box_pos.x + box_size.x &&
y >= box_pos.y && y <= box_pos.y + box_size.y {
color = Color::RED;
if input.mouse_down(graphicility::MouseButton::Left) {
box_pos.x = x - box_size.x / 2;
box_pos.y = y - box_size.y / 2;
}
}
}
g.rect(box_pos, box_size, color);
g.text((10, 10), "Hover to highlight, Click to drag", Color::WHITE);
});
}