diff options
Diffstat (limited to 'svgbob/src/buffer/fragment_buffer/fragment/circle.rs')
-rw-r--r-- | svgbob/src/buffer/fragment_buffer/fragment/circle.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/circle.rs b/svgbob/src/buffer/fragment_buffer/fragment/circle.rs index e3f9717..f43428a 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment/circle.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment/circle.rs @@ -1,4 +1,6 @@ use crate::{fragment::Bounds, util, Cell, Point}; +use ncollide2d::procedural; +use ncollide2d::shape::Polyline; use std::{cmp::Ordering, fmt}; use sauron::{ @@ -104,3 +106,20 @@ impl PartialEq for Circle { self.cmp(other) == Ordering::Equal } } + +impl Into<Polyline<f32>> for Circle { + fn into(self) -> Polyline<f32> { + use nalgebra::Point2; + let pl = procedural::circle(&(self.radius * 2.0), 64); + let mut points = pl.coords().to_vec(); + let orig_len = points.len(); + points.dedup(); + + let adjusted: Vec<Point2<f32>> = points + .into_iter() + .map(|p| *Point::new(p.x + self.center.x, p.y + self.center.y)) + .collect(); + + Polyline::new(adjusted, None) + } +} |