Remove unused `gfx-utils`
This commit is contained in:
parent
39d6b1d9c2
commit
2f497e7f17
|
@ -2,7 +2,6 @@
|
||||||
members = [
|
members = [
|
||||||
"demo3",
|
"demo3",
|
||||||
"geometry",
|
"geometry",
|
||||||
"gfx-utils",
|
|
||||||
"gl",
|
"gl",
|
||||||
"renderer",
|
"renderer",
|
||||||
"simd",
|
"simd",
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "pathfinder_gfx_utils"
|
|
||||||
version = "0.2.0"
|
|
||||||
authors = ["Patrick Walton <pcwalton@mimiga.net>"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
euclid = "0.19"
|
|
|
@ -1,51 +0,0 @@
|
||||||
// pathfinder/gfx-utils/lib.rs
|
|
||||||
//
|
|
||||||
// Copyright © 2018 The Pathfinder Project Developers.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
extern crate euclid;
|
|
||||||
|
|
||||||
use euclid::{Point2D, Size2D, Vector2D};
|
|
||||||
use std::cmp;
|
|
||||||
|
|
||||||
pub struct ShelfBinPacker {
|
|
||||||
next: Point2D<i32>,
|
|
||||||
max_size: Size2D<i32>,
|
|
||||||
padding: Vector2D<i32>,
|
|
||||||
shelf_height: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ShelfBinPacker {
|
|
||||||
pub fn new(max_size: &Size2D<i32>, padding: &Vector2D<i32>) -> ShelfBinPacker {
|
|
||||||
ShelfBinPacker {
|
|
||||||
next: padding.to_point(),
|
|
||||||
max_size: *max_size,
|
|
||||||
padding: *padding,
|
|
||||||
shelf_height: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add(&mut self, size: &Size2D<i32>) -> Result<Point2D<i32>, ()> {
|
|
||||||
let mut next = self.next;
|
|
||||||
let mut lower_right = Point2D::new(next.x + size.width, next.y + size.height) +
|
|
||||||
self.padding;
|
|
||||||
if lower_right.x > self.max_size.width {
|
|
||||||
next = Point2D::new(0, next.y + self.shelf_height);
|
|
||||||
self.shelf_height = 0;
|
|
||||||
lower_right = Point2D::new(size.width, next.y + size.height) + self.padding;
|
|
||||||
}
|
|
||||||
if lower_right.x > self.max_size.width || lower_right.y > self.max_size.height {
|
|
||||||
return Err(())
|
|
||||||
}
|
|
||||||
self.shelf_height = cmp::max(self.shelf_height, size.height);
|
|
||||||
self.next = next + Vector2D::new(size.width + self.padding.x * 2, 0);
|
|
||||||
Ok(next)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue