moving files

This commit is contained in:
2019-06-12 20:41:40 -07:00
parent e001f252eb
commit c139121acb
14 changed files with 186 additions and 431 deletions

View File

@@ -2,35 +2,32 @@
#![allow(unused_variables)]
#![allow(unused_mut)]
extern crate quick_xml;
extern crate sfml;
extern crate cgmath;
extern crate image;
extern crate nalgebra as na;
extern crate quick_xml;
extern crate rand;
extern crate sfml;
use image::{DynamicImage, GenericImage, GenericImageView, Pixel, SubImage};
use sfml::graphics::*;
use sfml::graphics::{
Color, RenderTarget, RenderWindow,
};
use sfml::system::*;
use sfml::system::Vector2 as sfVec2;
use sfml::window::*;
use sfml::window::{Event, Key, Style};
use crate::input::Input;
use crate::slider::Slider;
use crate::timer::Timer;
mod slider;
mod timer;
mod input;
mod util;
use sfml::graphics::*;
use sfml::system::*;
use sfml::window::*;
use crate::timer::Timer;
use crate::input::Input;
use crate::slider::Slider;
extern crate nalgebra as na;
use image::{GenericImageView, GenericImage, DynamicImage, Pixel, SubImage};
use sfml::graphics::{
Color, RenderTarget, RenderWindow,
};
use sfml::window::{ Event, Key, Style};
use sfml::system::Vector2 as sfVec2;
// The container trait for all the shaders
trait Effect: Drawable {
fn update(&mut self, t: f32, x: f32, y: f32);
@@ -138,39 +135,18 @@ fn surrounding_pixels(x: u32, y: u32, img: &DynamicImage) -> Vec<image::Rgba<u8>
fn main() {
let mut img = image::open("test.jpg").unwrap();
let mut img = image::open("resources/funky-bird.jpg").unwrap();
let xy = img.dimensions();
println!("Starting");
for x in 0..xy.0 {
for y in 0..xy.1 {
let mut pixel = img.get_pixel(x, y);
let v = surrounding_pixels(x, y, &img);
let mut avg = v.first().unwrap().clone();
for p in v {
let r: u16 = (avg.data[0] as u16 + p.data[0] as u16);
let g: u16 = (avg.data[1] as u16 + p.data[1] as u16);
let b: u16 = (avg.data[2] as u16 + p.data[2] as u16);
let a: u16 = (avg.data[3] as u16 + p.data[3] as u16);
avg.data[0] = (r/2) as u8;
avg.data[1] = (g/2) as u8;
avg.data[2] = (b/2) as u8;
avg.data[3] = (a/2) as u8;
}
pixel.data[0] = avg.data[0];
pixel.data[1] = avg.data[1];
pixel.data[2] = avg.data[2];
pixel.data[3] = avg.data[3];
img.put_pixel(x, y, pixel);
}
}
println!("Ending");
img.save("fractal.png").unwrap();
// for x in 0..xy.0 {
// for y in 0..xy.1 {
// let mut pixel = img.get_pixel(x, y);
// img.put_pixel(x, y, pixel);
// }
// }
// println!("Ending");
// img.save("fractal.png").unwrap();
let mut window = RenderWindow::new(
(512, 512),
@@ -202,7 +178,6 @@ fn main() {
text_bg.set_color(&Color::rgba(255, 255, 255, 200));
//==========================================
let mut slider = Slider::new(40.0, None);
let step_size: f32 = 0.005;
@@ -249,7 +224,7 @@ fn main() {
let x = window.mouse_position().x as f32 / window.size().x as f32;
let y = window.mouse_position().y as f32 / window.size().y as f32;
effects[current].update(elapsed_time*1000.0, x, y);
effects[current].update(elapsed_time*1.0, x, y);
window.clear(&Color::BLACK);
@@ -259,5 +234,4 @@ fn main() {
window.display();
}
}