jalberse / RayTracingInOneWeekendInRust

Ray Tracing In One Weekend, in Rust
1 stars 0 forks source link

Improve Renderer abstractions #48

Open jalberse opened 1 year ago

jalberse commented 1 year ago

I don't like Tile::tile() require passing an image width and height. It would make more sense to have some Image::tile() -> Vec function.

Maybe the ImageColor struct can become that Image class. The process of rendering then becomes properly modifying the Image struct's data to populate the colors. Or something like that, I don't love how that implies we'd make Image mut (though ImageColor already is, so, whatever).

Just some observations about how that could be improved.

Just think about the structure of this module and how we could make it more idiomatic. I just had these thoughts and wanted to write them down

jalberse commented 1 year ago

The Renderer should also, I think, not actually output the image to stdout as it currently is. It should instead return an Image (something like ImageColors). The user can do whatever they want with that, like calling a separate wirte_ppm() function or make a write_png() or whatever they want to do.

jalberse commented 1 year ago

Note that I'm not sure will be useful or not: We could have a Tile enum with variants RenderingTile and RenderedTile following the state/flow pattern where we initialize a tile as a RenderingTile and when all its pixel values are calculated it becomes a RenderedTile. Could potentially be useful but I haven't touched this code in a while.

Also consider that in the future we might want to display these as we render in some image buffer in a GUI.