Browse Source

textium: geometry: conversion from rusttype Rects

master
Erin 8 years ago
parent
commit
dbd0e4bc03
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      textium/src/geometry.rs

+ 12
- 1
textium/src/geometry.rs View File

@ -1,8 +1,9 @@
//! Some generic geometry routines used in atlas packing.
use std::ops::{Add, Sub, Mul};
use std::convert::From;
use num_traits::cast::NumCast;
use rusttype;
/// A rectangle.
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
@ -66,6 +67,16 @@ impl<T> Rect<T>
}
}
impl<T> From<rusttype::Rect<T>> for Rect<T> where T: Sub<Output=T> + Copy {
fn from(rect: rusttype::Rect<T>) -> Self {
Rect {
x: rect.min.x,
y: rect.min.y,
w: rect.width(),
h: rect.height(),
}
}
}
/// A 2D vector
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub struct Vec2<T> {


Loading…
Cancel
Save