added color swatch picking. Need to align it to the slewed image
This commit is contained in:
35
src/main.rs
35
src/main.rs
@@ -46,12 +46,17 @@ mod timer;
|
||||
mod input;
|
||||
mod vkprocessor;
|
||||
|
||||
// What next?
|
||||
|
||||
// Second sprite for rendering paths at x10 or so resolution
|
||||
// color bucketing
|
||||
|
||||
fn main() {
|
||||
|
||||
let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap();
|
||||
let mut processor = vkprocessor::VkProcessor::new(&instance);
|
||||
processor.compile_kernel(String::from("simple-edge.compute"));
|
||||
processor.load_buffers(String::from("test2.png"));
|
||||
processor.load_buffers(String::from("funky-bird.jpg"));
|
||||
processor.run_kernel();
|
||||
processor.read_image();
|
||||
processor.save_image();
|
||||
@@ -78,7 +83,7 @@ fn main() {
|
||||
let mut slider = Slider::new(40.0, None);
|
||||
|
||||
let mut selected_colors = Vec::new();
|
||||
selected_colors.push(RectangleShape::with_size(Vector2f::new(30.0, 30.0)));
|
||||
|
||||
|
||||
let step_size: f32 = 0.005;
|
||||
let mut elapsed_time: f32;
|
||||
@@ -98,8 +103,23 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
},
|
||||
Event::MouseButtonPressed { button, x, y } => {
|
||||
Event::MouseButtonPressed { button, x, y} => {
|
||||
let x = x as u32;
|
||||
let y = y as u32;
|
||||
mouse_xy = mouse::desktop_position();
|
||||
let r = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 0) as usize] as u8;
|
||||
let g = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 1) as usize] as u8;
|
||||
let b = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 2) as usize] as u8;
|
||||
let a = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 3) as usize] as u8;
|
||||
|
||||
selected_colors.push(
|
||||
RectangleShape::with_size(Vector2f::new(30.0, 30.0))
|
||||
);
|
||||
|
||||
let mut x_position = 45.0 * selected_colors.len() as f32;
|
||||
|
||||
selected_colors.last_mut().unwrap().set_position(Vector2f::new(x_position, 80.0));
|
||||
selected_colors.last_mut().unwrap().set_fill_color(&Color::rgba(r,g,b,a));
|
||||
},
|
||||
Event::MouseWheelScrolled { wheel, delta, x, y } => {
|
||||
if delta > 0.0 {
|
||||
@@ -113,12 +133,10 @@ fn main() {
|
||||
input.ingest(&event)
|
||||
}
|
||||
|
||||
if input.is_mousebutton_held(Button::Left) {
|
||||
|
||||
// Dragging by middle click
|
||||
if input.is_mousebutton_held(Button::Middle) {
|
||||
let delta = mouse_xy - mouse::desktop_position();
|
||||
mouse_xy = mouse::desktop_position();
|
||||
|
||||
println!("{:?}", delta);
|
||||
background_sprite.set_position(
|
||||
background_sprite.position() - Vector2f::new(delta.x as f32, delta.y as f32)
|
||||
);
|
||||
@@ -142,6 +160,9 @@ fn main() {
|
||||
|
||||
window.draw(&slider);
|
||||
|
||||
for i in &selected_colors {
|
||||
window.draw(i);
|
||||
}
|
||||
|
||||
window.display();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user