rgba
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
use image::{ImageBuffer, Rgb, RgbImage};
|
use image::{ImageBuffer, Rgba, RgbaImage};
|
||||||
use std::f64::consts::PI;
|
use std::f64::consts::PI;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ fn chladni(x: f64, y: f64, n: f64, m: f64) -> f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn generate_png(n: u32, m: u32, width: u32, height: u32) {
|
fn generate_png(n: u32, m: u32, width: u32, height: u32) {
|
||||||
let mut img: RgbImage = ImageBuffer::new(width, height);
|
let mut img: RgbaImage = ImageBuffer::new(width, height);
|
||||||
|
|
||||||
for (x, y, pixel) in img.enumerate_pixels_mut() {
|
for (x, y, pixel) in img.enumerate_pixels_mut() {
|
||||||
let xf = (x as f64 / width as f64) * 2.0 - 1.0;
|
let xf = (x as f64 / width as f64) * 2.0 - 1.0;
|
||||||
@ -17,7 +17,8 @@ fn generate_png(n: u32, m: u32, width: u32, height: u32) {
|
|||||||
let intensity = val.abs();
|
let intensity = val.abs();
|
||||||
|
|
||||||
let brigh = (((0.08 - intensity).max(0.0) / 0.08) * 255.0) as u8;
|
let brigh = (((0.08 - intensity).max(0.0) / 0.08) * 255.0) as u8;
|
||||||
*pixel = Rgb([brigh, brigh, brigh]);
|
*pixel = Rgba([0, 0, 0, brigh]);
|
||||||
|
// *pixel = Rgb([brigh, brigh, brigh]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = format!("out/chladni_{}_{}.png", n, m);
|
let filename = format!("out/chladni_{}_{}.png", n, m);
|
||||||
|
|||||||
Reference in New Issue
Block a user