Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal segments #1201

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/projection/src/horizon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ impl Horizon {
horizon_y + margin < point.y()
}

pub fn horizon_y_maximum(&self) -> f32 {
self.y_at_x(0.0).max(self.y_at_x(640.0))
}

pub fn horizon_y_minimum(&self) -> f32 {
self.y_at_x(0.0).min(self.y_at_x(640.0))
}
Expand Down
7 changes: 7 additions & 0 deletions crates/types/src/image_segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct ImageSegments {
Default, Clone, Debug, Deserialize, Serialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
pub struct ScanGrid {
pub horizontal_scan_lines: Vec<ScanLine>,
pub vertical_scan_lines: Vec<ScanLine>,
}

Expand Down Expand Up @@ -50,3 +51,9 @@ pub enum EdgeType {
ImageBorder,
LimbBorder,
}

#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum Direction {
Horizontal,
Vertical,
}
13 changes: 4 additions & 9 deletions crates/types/src/ycbcr422_image.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{
fmt::Debug,
mem::{size_of, ManuallyDrop},
ops::Index,
path::Path,
sync::Arc,
};
Expand Down Expand Up @@ -218,6 +217,10 @@ impl YCbCr422Image {
}
}

pub fn at_point(&self, point: Point2<Pixel, u32>) -> YCbCr444 {
self.at(point.x(), point.y())
}

pub fn try_at(&self, x: u32, y: u32) -> Option<YCbCr444> {
if x >= self.width() || y >= self.height() {
return None;
Expand All @@ -240,11 +243,3 @@ impl YCbCr422Image {
})
}
}

impl Index<Point2<Pixel, usize>> for YCbCr422Image {
type Output = YCbCr422;

fn index(&self, position: Point2<Pixel, usize>) -> &Self::Output {
&self.buffer[position.y() * self.width_422 as usize + position.x()]
}
}
Loading