Skip to content

Commit 7b20907

Browse files
committed
Fixed warnings.
1 parent 4cf2720 commit 7b20907

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/lib.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct Triangle {
4343
c: Point,
4444
color: Option<Rgba<u8>>,
4545

46-
spanDiv: Option<f32>,
46+
span_div: Option<f32>,
4747
}
4848

4949
impl Triangle {
@@ -53,36 +53,36 @@ impl Triangle {
5353
b: b,
5454
c: c,
5555
color: None,
56-
spanDiv: None,
56+
span_div: None,
5757
}
5858
}
5959

60-
fn spanDivSave(&mut self) {
61-
self.spanDiv = Some(self.spanDiv());
60+
fn span_div_save(&mut self) {
61+
self.span_div = Some(self.span_div());
6262
}
6363

64-
fn spanDiv(&self) -> f32 {
65-
match self.spanDiv {
64+
fn span_div(&self) -> f32 {
65+
match self.span_div {
6666
Some(div) => div,
6767
None => {
68-
let spanA = Point { x: self.b.x - self.a.x, y: self.b.y - self.a.y };
69-
let spanB = Point { x: self.c.x - self.a.x, y: self.c.y - self.a.y };
68+
let span_a = Point { x: self.b.x - self.a.x, y: self.b.y - self.a.y };
69+
let span_b = Point { x: self.c.x - self.a.x, y: self.c.y - self.a.y };
7070

71-
1.0 / spanA.cross_product(spanB) as f32
71+
1.0 / span_a.cross_product(span_b) as f32
7272
}
7373
}
7474
}
7575
}
7676

7777
impl Primitive for Triangle {
7878
fn is_inside_primitive(&self, p: Point) -> bool {
79-
let spanA = Point { x: self.b.x - self.a.x, y: self.b.y - self.a.y };
80-
let spanB = Point { x: self.c.x - self.a.x, y: self.c.y - self.a.y };
79+
let span_a = Point { x: self.b.x - self.a.x, y: self.b.y - self.a.y };
80+
let span_b = Point { x: self.c.x - self.a.x, y: self.c.y - self.a.y };
8181

8282
let q = Point { x: p.x - self.a.x, y: p.y - self.a.y };
8383

84-
let s = q.cross_product(spanB) as f32 * self.spanDiv();
85-
let t = spanA.cross_product(q) as f32 * self.spanDiv();
84+
let s = q.cross_product(span_b) as f32 * self.span_div();
85+
let t = span_a.cross_product(q) as f32 * self.span_div();
8686

8787
(s >= 0.0) && (t >= 0.0) && ((s + t) <= 1.0)
8888
}
@@ -189,13 +189,13 @@ impl Geometrify {
189189
// for x in 0..image.width() {
190190
let p = Point {x: x as i32, y: y as i32};
191191
if primitive.is_inside_primitive(p) {
192-
*image.get_pixel_mut(x as u32, y as u32) = Geometrify::mixColor(primitive.get_color().expect("color of triangle not set"), *image.get_pixel(x as u32, y as u32));
192+
*image.get_pixel_mut(x as u32, y as u32) = Geometrify::mix_color(primitive.get_color().expect("color of triangle not set"), *image.get_pixel(x as u32, y as u32));
193193
}
194194
}
195195
}
196196
}
197197

198-
fn mixColor(first: Rgba<u8>, second: Rgba<u8>) -> Rgba<u8> {
198+
fn mix_color(first: Rgba<u8>, second: Rgba<u8>) -> Rgba<u8> {
199199
let (r1, g1, b1, a1) = first.channels4();
200200
let (r2, g2, b2, a2) = second.channels4();
201201

@@ -241,16 +241,16 @@ impl Geometrify {
241241

242242
for y in bb.top_left.y..bb.bottom_right.y {
243243
for x in bb.top_left.x..bb.bottom_right.x {
244-
let originalRgb = original.get_pixel(x as u32, y as u32);
245-
let resultRgb = if (bb.top_left.x as u32 <= x as u32) && (x as u32 <= bb.bottom_right.x as u32)
244+
let original_rgb = original.get_pixel(x as u32, y as u32);
245+
let result_rgb = if (bb.top_left.x as u32 <= x as u32) && (x as u32 <= bb.bottom_right.x as u32)
246246
&& (bb.top_left.y as u32 <= y as u32) && (y as u32 <= bb.bottom_right.y as u32)
247247
&& (primitive.is_inside_primitive(Point { x: x as i32, y: y as i32 })) {
248-
Geometrify::mixColor(*current.get_pixel(x as u32, y as u32), primitive.get_color().expect("triangle color not "))
248+
Geometrify::mix_color(*current.get_pixel(x as u32, y as u32), primitive.get_color().expect("triangle color not "))
249249
} else {
250250
*current.get_pixel(x as u32, y as u32)
251251
};
252252

253-
d += Geometrify::difference(*originalRgb, resultRgb) as u64;
253+
d += Geometrify::difference(*original_rgb, result_rgb) as u64;
254254
}
255255
}
256256

@@ -280,32 +280,32 @@ impl Geometrify {
280280
result
281281
}
282282

283-
pub fn apply(&mut self, image: RgbaImage, numberOfIterations: i32, numberOfSamples: i32) -> RgbaImage {
284-
let mut progress = ProgressBar::new(numberOfIterations as u64);
283+
pub fn apply(&mut self, image: RgbaImage, number_of_iterations: i32, number_of_samples: i32) -> RgbaImage {
284+
let mut progress = ProgressBar::new(number_of_iterations as u64);
285285
progress.format("|#--|");
286286

287287
let mut destination = RgbaImage::new(image.width(), image.height());
288288

289-
for _ in 0..numberOfIterations {
289+
for _ in 0..number_of_iterations {
290290
let difference_lut = Geometrify::calculate_difference_lut(&image, &destination);
291291

292-
let primitives = (0..numberOfSamples)
292+
let primitives = (0..number_of_samples)
293293
.map(|_| {
294294
self.generate_primitive()
295295
})
296296
.map(|mut p| {
297-
p.spanDivSave();
297+
p.span_div_save();
298298
p
299299
}).collect::<Vec<Triangle>>();
300-
let minPrimitive = primitives.par_iter()
300+
let min_primitive = primitives.par_iter()
301301
.map(|primitive| {
302302
let mut prim = *primitive;
303303
prim.color = Some(Geometrify::calculate_color(&image, &prim));
304304
(prim, Geometrify::calculate_difference(&image, &destination, &difference_lut, &prim))
305305
})
306306
.min_by_key(|tup| tup.1);
307307

308-
Geometrify::add_to_image(&mut destination, &minPrimitive.expect("no fitting triangle found").0);
308+
Geometrify::add_to_image(&mut destination, &min_primitive.expect("no fitting triangle found").0);
309309
progress.inc();
310310
}
311311
progress.finish_print("done");

0 commit comments

Comments
 (0)