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

Implement some missing functionalities that would be useful in WebRender. #170

Merged
merged 4 commits into from Dec 9, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add conversion methods between 2d and 3d points.

  • Loading branch information
nical committed Dec 9, 2016
commit 8f6343d93bfeeb4515bd0d8df8392441387b5402
@@ -38,6 +38,12 @@ impl<T: Copy + Zero, U> TypedPoint2D<T, U> {
pub fn zero() -> TypedPoint2D<T, U> {
TypedPoint2D::new(Zero::zero(), Zero::zero())
}

/// Convert into a 3d point.
#[inline]
pub fn to_3d(&self) -> TypedPoint3D<T, U> {
TypedPoint3D::new(self.x, self.y, Zero::zero())
}
}

impl<T: fmt::Debug, U> fmt::Debug for TypedPoint2D<T, U> {
@@ -352,6 +358,12 @@ impl<T: Copy, U> TypedPoint3D<T, U> {
pub fn from_untyped(p: &Point3D<T>) -> TypedPoint3D<T, U> {
TypedPoint3D::new(p.x, p.y, p.z)
}

/// Convert into a 2d point.
#[inline]
pub fn to_2d(&self) -> TypedPoint2D<T, U> {
TypedPoint2D::new(self.x, self.y)
}
}

impl<T: Mul<T, Output=T> +
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.