Skip to content

Commit dca4fd7

Browse files
committed
Use generic PointGenerator in Geometrify.
1 parent a2dc29a commit dca4fd7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use rand::Rng;
1212
use rayon::prelude::*;
1313

1414
#[derive(Clone, Copy, Debug)]
15-
struct Point {
15+
pub struct Point {
1616
x: i32,
1717
y: i32,
1818
}
1919

2020
impl Point {
21-
fn cross_product(&self, b: Point) -> i32 {
21+
pub fn cross_product(&self, b: Point) -> i32 {
2222
self.x * b.y - self.y * b.x
2323
}
2424
}
@@ -125,7 +125,7 @@ impl Primitive for Triangle {
125125
}
126126
}
127127

128-
trait PointGenerator {
128+
pub trait PointGenerator {
129129
fn next_point(&mut self, width: u32, height: u32) -> Point;
130130
}
131131

@@ -149,13 +149,13 @@ impl PointGenerator for RandomPointGenerator {
149149
}
150150

151151
pub struct Geometrify {
152-
point_gen: Box<RandomPointGenerator>,
152+
point_gen: Box<PointGenerator>,
153153
iterations: u32,
154154
samples: u32,
155155
}
156156

157157
impl Geometrify {
158-
pub fn new(point_gen: Box<RandomPointGenerator>, iterations: u32, samples: u32) -> Geometrify {
158+
pub fn new(point_gen: Box<PointGenerator>, iterations: u32, samples: u32) -> Geometrify {
159159
Geometrify {
160160
point_gen: point_gen,
161161
iterations: iterations,

0 commit comments

Comments
 (0)