@@ -150,11 +150,25 @@ impl PointGenerator for RandomPointGenerator {
150
150
151
151
pub struct Geometrify {
152
152
point_gen : Box < RandomPointGenerator > ,
153
+ iterations : u32 ,
154
+ samples : u32 ,
153
155
}
154
156
155
157
impl Geometrify {
156
- pub fn new ( point_gen : Box < RandomPointGenerator > ) -> Geometrify {
157
- Geometrify { point_gen : point_gen }
158
+ pub fn new ( point_gen : Box < RandomPointGenerator > , iterations : u32 , samples : u32 ) -> Geometrify {
159
+ Geometrify {
160
+ point_gen : point_gen,
161
+ iterations : iterations,
162
+ samples : samples,
163
+ }
164
+ }
165
+
166
+ pub fn set_iterations ( & mut self , iterations : u32 ) {
167
+ self . iterations = iterations
168
+ }
169
+
170
+ pub fn set_samples ( & mut self , samples : u32 ) {
171
+ self . samples = samples
158
172
}
159
173
160
174
fn calculate_color ( image : & RgbaImage , primitive : & Primitive ) -> Rgba < u8 > {
@@ -321,20 +335,16 @@ impl Geometrify {
321
335
result
322
336
}
323
337
324
- pub fn apply ( & mut self ,
325
- image : RgbaImage ,
326
- number_of_iterations : i32 ,
327
- number_of_samples : i32 )
328
- -> RgbaImage {
329
- let mut progress = ProgressBar :: new ( number_of_iterations as u64 ) ;
338
+ pub fn apply ( & mut self , image : RgbaImage ) -> RgbaImage {
339
+ let mut progress = ProgressBar :: new ( self . iterations as u64 ) ;
330
340
progress. format ( "|#--|" ) ;
331
341
332
342
let mut destination = RgbaImage :: new ( image. width ( ) , image. height ( ) ) ;
333
343
334
- for _ in 0 ..number_of_iterations {
344
+ for _ in 0 ..self . iterations {
335
345
let difference_lut = Geometrify :: calculate_difference_lut ( & image, & destination) ;
336
346
337
- let primitives = ( 0 ..number_of_samples )
347
+ let primitives = ( 0 ..self . samples )
338
348
. map ( |_| self . generate_primitive ( image. width ( ) , image. height ( ) ) )
339
349
. map (
340
350
|mut p| {
0 commit comments