fx: debug statement

This commit is contained in:
2026-05-13 13:52:57 +02:00
parent d8ad450553
commit b4b214ebf7

View File

@@ -1,5 +1,5 @@
use image::{DynamicImage, ImageReader};
use log::info;
use log::trace;
use crate::{
objects::{hit::Hit, materials::traits::Material},
@@ -18,8 +18,15 @@ pub struct Texture {
impl Texture {
pub fn new(texture: &str) -> Self {
let img = ImageReader::open(texture).unwrap().decode().unwrap(); // FIXME: unwraps
info!("{} * {} = {} bytes", img.width(), img.height(), img.as_bytes().len());
let stride = match img.color() { // TODO: support other types of image
trace!(
"texture '{}' is {} by {} pixels, with {} bytes total",
texture,
img.width(),
img.height(),
img.as_bytes().len()
);
let stride = match img.color() {
// TODO: support other types of image
image::ColorType::L8 => todo!(),
image::ColorType::La8 => todo!(),
image::ColorType::Rgb8 => 3,
@@ -48,10 +55,14 @@ impl Texture {
}
fn _at(&self, u: f32, v: f32) -> Vec3 {
let b = self.source.as_bytes();
let b = self.source.as_bytes();
let idx = self._idx(u, v);
Vec3::from_u8(b[self.stride * idx], b[self.stride * idx + 2], b[self.stride * idx + 1])
Vec3::from_u8(
b[self.stride * idx],
b[self.stride * idx + 2],
b[self.stride * idx + 1],
)
}
}