From dbd0e4bc033c7d1a39c110c2f90022edb60a7b7d Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 5 Nov 2017 20:39:55 -0600 Subject: [PATCH] textium: geometry: conversion from rusttype Rects --- textium/src/geometry.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/textium/src/geometry.rs b/textium/src/geometry.rs index 0df44c5..b58a789 100644 --- a/textium/src/geometry.rs +++ b/textium/src/geometry.rs @@ -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 Rect } } +impl From> for Rect where T: Sub + Copy { + fn from(rect: rusttype::Rect) -> 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 {