Start fixing the camera; use image width for indexing
This commit is contained in:
parent
221d544a01
commit
a94ab87eab
@ -62,10 +62,11 @@ pub struct CameraConstants {
|
|||||||
|
|
||||||
impl CameraConstants {
|
impl CameraConstants {
|
||||||
pub fn camera(&self, image_width: i32, image_height: i32) -> glam::Affine2 {
|
pub fn camera(&self, image_width: i32, image_height: i32) -> glam::Affine2 {
|
||||||
|
let zoom_factor = 2f32.powf(self.zoom);
|
||||||
let zoom_rotate_offset = glam::Affine2::from_scale_angle_translation(
|
let zoom_rotate_offset = glam::Affine2::from_scale_angle_translation(
|
||||||
glam::Vec2::splat(2f32.powf(self.zoom)),
|
glam::Vec2::splat(zoom_factor),
|
||||||
self.rotate.to_radians(),
|
self.rotate.to_radians(),
|
||||||
-vec2(self.offset_x, self.offset_y),
|
-vec2(self.offset_x, self.offset_y) * zoom_factor,
|
||||||
);
|
);
|
||||||
let ifs_to_pixel = glam::Affine2::from_scale_angle_translation(
|
let ifs_to_pixel = glam::Affine2::from_scale_angle_translation(
|
||||||
glam::Vec2::splat(self.scale),
|
glam::Vec2::splat(self.scale),
|
||||||
@ -262,10 +263,10 @@ pub fn main_cs(
|
|||||||
// Fixed camera, should be provided by a uniform in the future
|
// Fixed camera, should be provided by a uniform in the future
|
||||||
let camera = CameraConstants {
|
let camera = CameraConstants {
|
||||||
scale: max_dimension as f32 / 4.0,
|
scale: max_dimension as f32 / 4.0,
|
||||||
zoom: 0.0,
|
zoom: 2.0,
|
||||||
rotate: 0.0,
|
rotate: 0.0,
|
||||||
offset_x: 0.0,
|
offset_x: 0.5,
|
||||||
offset_y: 0.0,
|
offset_y: 0.5,
|
||||||
}
|
}
|
||||||
.camera(image_constants.accum_width, image_constants.accum_height);
|
.camera(image_constants.accum_width, image_constants.accum_height);
|
||||||
|
|
||||||
@ -285,7 +286,7 @@ pub fn main_cs(
|
|||||||
let ii = image_index(
|
let ii = image_index(
|
||||||
pixel_coordinates.x,
|
pixel_coordinates.x,
|
||||||
pixel_coordinates.y,
|
pixel_coordinates.y,
|
||||||
image_constants.accum_height,
|
image_constants.accum_width,
|
||||||
);
|
);
|
||||||
accum_image[ii as usize] = Color::WHITE;
|
accum_image[ii as usize] = Color::WHITE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user