Start fixes for the gasket example
The image is inverted for reasons I don't entirely understand yet
This commit is contained in:
@@ -5,8 +5,8 @@ use enkou_shaders::camera::entry::main_image_render;
|
||||
use enkou_shaders::chaos_game::entry::main_chaos_game;
|
||||
use enkou_shaders::transform::Transform;
|
||||
use enkou_shaders::variation::Variation;
|
||||
use glam::{Affine2, UVec2, Vec2, Vec4, uvec2, vec2};
|
||||
use image::{Rgba, Rgba32FImage};
|
||||
use glam::{Affine2, UVec2, Vec2, Vec2Swizzles, Vec4, uvec2, vec2};
|
||||
use image::{Rgba, RgbaImage};
|
||||
use std::mem;
|
||||
use std::process::Command;
|
||||
use tempfile::NamedTempFile;
|
||||
@@ -65,7 +65,7 @@ pub fn main() -> Result<()> {
|
||||
let palette = &[Vec4::ONE; 2];
|
||||
|
||||
let mut output_points_pixel = Vec::new();
|
||||
output_points_pixel.resize(ITERATIONS as usize, Vec4::ZERO);
|
||||
output_points_pixel.resize(IMAGE_DIMENSION.xy().element_product() as usize, Vec4::ZERO);
|
||||
|
||||
main_image_render(
|
||||
&camera,
|
||||
@@ -74,11 +74,16 @@ pub fn main() -> Result<()> {
|
||||
&mut output_points_pixel,
|
||||
);
|
||||
|
||||
let mut image = Rgba32FImage::new(IMAGE_DIMENSION.x, IMAGE_DIMENSION.y);
|
||||
for x in 0..image.dimensions().0 {
|
||||
for y in 0..image.dimensions().1 {
|
||||
let mut image = RgbaImage::new(IMAGE_DIMENSION.x, IMAGE_DIMENSION.y);
|
||||
for y in 0..image.dimensions().1 {
|
||||
for x in 0..image.dimensions().0 {
|
||||
let pixel_index = y * IMAGE_DIMENSION.x + x;
|
||||
let pixel = output_points_pixel[pixel_index as usize];
|
||||
let pixel = pixel.to_array().map(|channel| {
|
||||
let channel = if channel.is_nan() { 0.0 } else { channel };
|
||||
let channel = channel * u8::MAX as f32;
|
||||
channel as u8
|
||||
});
|
||||
image.put_pixel(x, y, Rgba(pixel.into()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user