author | unc0rr |
Tue, 06 Nov 2018 00:02:23 +0100 | |
changeset 14161 | 3078123e84ea |
parent 14158 | 3119d665d3c6 |
child 14165 | 165e43c3ed59 |
permissions | -rw-r--r-- |
13957 | 1 |
extern crate integral_geometry; |
13938 | 2 |
extern crate vec2d; |
3 |
||
13967 | 4 |
use std::cmp; |
13938 | 5 |
|
14158
3119d665d3c6
collapse rectangle types back together with consistent usage of size
alfadur
parents:
14156
diff
changeset
|
6 |
use integral_geometry::{ArcPoints, EquidistantPoints, Line, Point, Rect, Size, SizeMask}; |
13959
1fa905aa4cdb
move point struct into integral-geometry and use it to refactor a bit
alfadur
parents:
13957
diff
changeset
|
7 |
|
13938 | 8 |
pub struct Land2D<T> { |
9 |
pixels: vec2d::Vec2D<T>, |
|
14158
3119d665d3c6
collapse rectangle types back together with consistent usage of size
alfadur
parents:
14156
diff
changeset
|
10 |
play_box: Rect, |
14099 | 11 |
mask: SizeMask, |
13938 | 12 |
} |
13 |
||
13952 | 14 |
impl<T: Copy + PartialEq> Land2D<T> { |
14073 | 15 |
pub fn new(play_size: Size, fill_value: T) -> Self { |
16 |
let real_size = play_size.next_power_of_two(); |
|
14099 | 17 |
let top_left = Point::new( |
14122 | 18 |
((real_size.width - play_size.width) / 2) as i32, |
14099 | 19 |
(real_size.height - play_size.height) as i32, |
20 |
); |
|
14158
3119d665d3c6
collapse rectangle types back together with consistent usage of size
alfadur
parents:
14156
diff
changeset
|
21 |
let play_box = Rect::from_size(top_left, play_size); |
13938 | 22 |
Self { |
14099 | 23 |
play_box, |
14073 | 24 |
pixels: vec2d::Vec2D::new(real_size, fill_value), |
14099 | 25 |
mask: real_size.to_mask(), |
13938 | 26 |
} |
27 |
} |
|
28 |
||
14142 | 29 |
pub fn raw_pixels(&self) -> &[T] { |
30 |
&self.pixels.raw_data() |
|
31 |
} |
|
32 |
||
13938 | 33 |
#[inline] |
13945 | 34 |
pub fn width(&self) -> usize { |
35 |
self.pixels.width() |
|
36 |
} |
|
37 |
||
38 |
#[inline] |
|
39 |
pub fn height(&self) -> usize { |
|
40 |
self.pixels.height() |
|
41 |
} |
|
42 |
||
43 |
#[inline] |
|
14073 | 44 |
pub fn size(&self) -> Size { |
45 |
self.pixels.size() |
|
46 |
} |
|
47 |
||
48 |
#[inline] |
|
14071
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
49 |
pub fn play_width(&self) -> usize { |
14156
7f5a591e1c43
separate rectangle types based on right/bottom edge inclusivity
alfadur
parents:
14142
diff
changeset
|
50 |
self.play_box.width() |
14071
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
51 |
} |
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
52 |
|
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
53 |
#[inline] |
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
54 |
pub fn play_height(&self) -> usize { |
14156
7f5a591e1c43
separate rectangle types based on right/bottom edge inclusivity
alfadur
parents:
14142
diff
changeset
|
55 |
self.play_box.height() |
14073 | 56 |
} |
57 |
||
58 |
#[inline] |
|
59 |
pub fn play_size(&self) -> Size { |
|
14156
7f5a591e1c43
separate rectangle types based on right/bottom edge inclusivity
alfadur
parents:
14142
diff
changeset
|
60 |
self.play_box.size() |
14071
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
61 |
} |
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
62 |
|
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
63 |
#[inline] |
14158
3119d665d3c6
collapse rectangle types back together with consistent usage of size
alfadur
parents:
14156
diff
changeset
|
64 |
pub fn play_box(&self) -> Rect { |
14099 | 65 |
self.play_box |
66 |
} |
|
67 |
||
68 |
#[inline] |
|
13952 | 69 |
pub fn is_valid_x(&self, x: i32) -> bool { |
14053 | 70 |
self.mask.contains_x(x as usize) |
13952 | 71 |
} |
72 |
||
73 |
#[inline] |
|
74 |
pub fn is_valid_y(&self, y: i32) -> bool { |
|
14053 | 75 |
self.mask.contains_y(y as usize) |
13952 | 76 |
} |
77 |
||
78 |
#[inline] |
|
13945 | 79 |
pub fn is_valid_coordinate(&self, x: i32, y: i32) -> bool { |
13952 | 80 |
self.is_valid_x(x) && self.is_valid_y(y) |
13938 | 81 |
} |
82 |
||
83 |
#[inline] |
|
14051 | 84 |
pub fn rows(&self) -> impl Iterator<Item = &[T]> { |
85 |
self.pixels.rows() |
|
86 |
} |
|
87 |
||
88 |
#[inline] |
|
13961
1c30793b1cea
put back land2d.map accidentally replaced by testing code
alfadur
parents:
13959
diff
changeset
|
89 |
pub fn map<U: Default, F: FnOnce(&mut T) -> U>(&mut self, y: i32, x: i32, f: F) -> U { |
13938 | 90 |
if self.is_valid_coordinate(x, y) { |
13955
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
91 |
unsafe { |
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
92 |
// hey, I just checked that coordinates are valid! |
13961
1c30793b1cea
put back land2d.map accidentally replaced by testing code
alfadur
parents:
13959
diff
changeset
|
93 |
f(self.pixels.get_unchecked_mut(y as usize, x as usize)) |
13952 | 94 |
} |
13955
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
95 |
} else { |
13961
1c30793b1cea
put back land2d.map accidentally replaced by testing code
alfadur
parents:
13959
diff
changeset
|
96 |
U::default() |
13938 | 97 |
} |
98 |
} |
|
99 |
||
13965
4162ea9ae333
Use integral-geometry iterators to implement Land2D::draw_thick_line, remove no longer unused functions from Land2D
unc0rr
parents:
13964
diff
changeset
|
100 |
#[inline] |
4162ea9ae333
Use integral-geometry iterators to implement Land2D::draw_thick_line, remove no longer unused functions from Land2D
unc0rr
parents:
13964
diff
changeset
|
101 |
pub fn map_point<U: Default, F: FnOnce(&mut T) -> U>(&mut self, point: Point, f: F) -> U { |
4162ea9ae333
Use integral-geometry iterators to implement Land2D::draw_thick_line, remove no longer unused functions from Land2D
unc0rr
parents:
13964
diff
changeset
|
102 |
self.map(point.y, point.x, f) |
13955
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
103 |
} |
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
104 |
|
13959
1fa905aa4cdb
move point struct into integral-geometry and use it to refactor a bit
alfadur
parents:
13957
diff
changeset
|
105 |
pub fn fill_from_iter<I>(&mut self, i: I, value: T) -> usize |
13964
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
106 |
where |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
107 |
I: std::iter::Iterator<Item = Point>, |
13959
1fa905aa4cdb
move point struct into integral-geometry and use it to refactor a bit
alfadur
parents:
13957
diff
changeset
|
108 |
{ |
13964
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
109 |
i.map(|p| { |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
110 |
self.map(p.y, p.x, |v| { |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
111 |
*v = value; |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
112 |
1 |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
113 |
}) |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
114 |
}).count() |
13959
1fa905aa4cdb
move point struct into integral-geometry and use it to refactor a bit
alfadur
parents:
13957
diff
changeset
|
115 |
} |
1fa905aa4cdb
move point struct into integral-geometry and use it to refactor a bit
alfadur
parents:
13957
diff
changeset
|
116 |
|
14097
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
117 |
pub fn draw_line(&mut self, line: Line, value: T) -> usize { |
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
118 |
self.fill_from_iter(line.into_iter(), value) |
13938 | 119 |
} |
13945 | 120 |
|
13969 | 121 |
pub fn fill(&mut self, start_point: Point, border_value: T, fill_value: T) { |
122 |
debug_assert!(self.is_valid_coordinate(start_point.x - 1, start_point.y)); |
|
123 |
debug_assert!(self.is_valid_coordinate(start_point.x, start_point.y)); |
|
13945 | 124 |
|
125 |
let mut stack: Vec<(usize, usize, usize, isize)> = Vec::new(); |
|
13952 | 126 |
fn push<T: Copy + PartialEq>( |
13945 | 127 |
land: &Land2D<T>, |
128 |
stack: &mut Vec<(usize, usize, usize, isize)>, |
|
129 |
xl: usize, |
|
130 |
xr: usize, |
|
131 |
y: usize, |
|
132 |
dir: isize, |
|
133 |
) { |
|
134 |
let yd = y as isize + dir; |
|
135 |
||
14161 | 136 |
if land.is_valid_y(yd as i32) { |
13945 | 137 |
stack.push((xl, xr, yd as usize, dir)); |
138 |
} |
|
139 |
}; |
|
140 |
||
13969 | 141 |
let start_x_l = (start_point.x - 1) as usize; |
142 |
let start_x_r = start_point.x as usize; |
|
143 |
push( |
|
144 |
self, |
|
145 |
&mut stack, |
|
146 |
start_x_l, |
|
147 |
start_x_r, |
|
148 |
start_point.y as usize, |
|
149 |
-1, |
|
150 |
); |
|
151 |
push( |
|
152 |
self, |
|
153 |
&mut stack, |
|
154 |
start_x_l, |
|
155 |
start_x_r, |
|
156 |
start_point.y as usize, |
|
157 |
1, |
|
158 |
); |
|
13945 | 159 |
|
13972 | 160 |
while let Some(a) = stack.pop() { |
161 |
let (mut xl, mut xr, y, mut dir) = a; |
|
13945 | 162 |
|
13972 | 163 |
while xl > 0 && self |
164 |
.pixels |
|
165 |
.get(y, xl) |
|
166 |
.map_or(false, |v| *v != border_value && *v != fill_value) |
|
167 |
{ |
|
168 |
xl -= 1; |
|
169 |
} |
|
13945 | 170 |
|
13972 | 171 |
while xr < self.width() - 1 && self |
172 |
.pixels |
|
173 |
.get(y, xr) |
|
174 |
.map_or(false, |v| *v != border_value && *v != fill_value) |
|
175 |
{ |
|
176 |
xr += 1; |
|
177 |
} |
|
13945 | 178 |
|
13972 | 179 |
while xl < xr { |
180 |
while xl <= xr |
|
181 |
&& (self.pixels[y][xl] == border_value || self.pixels[y][xl] == fill_value) |
|
182 |
{ |
|
183 |
xl += 1; |
|
184 |
} |
|
13945 | 185 |
|
13972 | 186 |
let mut x = xl; |
13945 | 187 |
|
13972 | 188 |
while xl <= xr |
189 |
&& (self.pixels[y][xl] != border_value && self.pixels[y][xl] != fill_value) |
|
190 |
{ |
|
191 |
self.pixels[y][xl] = fill_value; |
|
13945 | 192 |
|
13972 | 193 |
xl += 1; |
194 |
} |
|
13945 | 195 |
|
13972 | 196 |
if x < xl { |
197 |
push(self, &mut stack, x, xl - 1, y, dir); |
|
198 |
push(self, &mut stack, x, xl - 1, y, -dir); |
|
13945 | 199 |
} |
200 |
} |
|
201 |
} |
|
202 |
} |
|
13952 | 203 |
|
204 |
#[inline] |
|
205 |
fn fill_circle_line<F: Fn(&mut T) -> usize>( |
|
206 |
&mut self, |
|
207 |
y: i32, |
|
208 |
x_from: i32, |
|
209 |
x_to: i32, |
|
210 |
f: &F, |
|
211 |
) -> usize { |
|
212 |
let mut result = 0; |
|
213 |
||
214 |
if self.is_valid_y(y) { |
|
215 |
for i in cmp::min(x_from, 0) as usize..cmp::max(x_to as usize, self.width() - 1) { |
|
13955
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
216 |
unsafe { |
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
217 |
// coordinates are valid at this point |
13952 | 218 |
result += f(self.pixels.get_unchecked_mut(y as usize, i)); |
219 |
} |
|
220 |
} |
|
221 |
} |
|
222 |
||
223 |
result |
|
224 |
} |
|
225 |
||
226 |
#[inline] |
|
227 |
fn fill_circle_lines<F: Fn(&mut T) -> usize>( |
|
228 |
&mut self, |
|
229 |
x: i32, |
|
230 |
y: i32, |
|
231 |
dx: i32, |
|
232 |
dy: i32, |
|
233 |
f: &F, |
|
234 |
) -> usize { |
|
235 |
self.fill_circle_line(y + dy, x - dx, x + dx, f) |
|
236 |
+ self.fill_circle_line(y - dy, x - dx, x + dx, f) |
|
237 |
+ self.fill_circle_line(y + dx, x - dy, x + dy, f) |
|
238 |
+ self.fill_circle_line(y - dx, x - dy, x + dy, f) |
|
239 |
} |
|
240 |
||
241 |
pub fn change_round<F: Fn(&mut T) -> usize>( |
|
242 |
&mut self, |
|
243 |
x: i32, |
|
244 |
y: i32, |
|
245 |
radius: i32, |
|
246 |
f: F, |
|
247 |
) -> usize { |
|
13964
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
248 |
ArcPoints::new(radius) |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
249 |
.map(&mut |p: Point| self.fill_circle_lines(x, y, p.x, p.y, &f)) |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
250 |
.sum() |
13955
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
251 |
} |
13952 | 252 |
|
14052 | 253 |
fn fill_row(&mut self, center: Point, offset: Point, value: T) -> usize { |
254 |
let row_index = center.y + offset.y; |
|
255 |
if self.is_valid_y(row_index) { |
|
256 |
let from_x = cmp::max(0, center.x - offset.x) as usize; |
|
257 |
let to_x = cmp::min(self.width() - 1, (center.x + offset.x) as usize); |
|
258 |
self.pixels[row_index as usize][from_x..=to_x] |
|
14099 | 259 |
.iter_mut() |
260 |
.for_each(|v| *v = value); |
|
14052 | 261 |
to_x - from_x + 1 |
262 |
} else { |
|
263 |
0 |
|
264 |
} |
|
265 |
} |
|
266 |
||
267 |
pub fn fill_circle(&mut self, center: Point, radius: i32, value: T) -> usize { |
|
14099 | 268 |
let transforms = [[0, 1, 1, 0], [0, 1, -1, 0], [1, 0, 0, 1], [1, 0, 0, -1]]; |
269 |
ArcPoints::new(radius) |
|
270 |
.map(|vector| { |
|
271 |
transforms |
|
272 |
.iter() |
|
273 |
.map(|m| self.fill_row(center, vector.transform(m), value)) |
|
274 |
.sum::<usize>() |
|
275 |
}).sum() |
|
14052 | 276 |
} |
277 |
||
14097
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
278 |
pub fn draw_thick_line(&mut self, line: Line, radius: i32, value: T) -> usize { |
13965
4162ea9ae333
Use integral-geometry iterators to implement Land2D::draw_thick_line, remove no longer unused functions from Land2D
unc0rr
parents:
13964
diff
changeset
|
279 |
let mut result = 0; |
13952 | 280 |
|
13970
a1895019bb94
change draw_thick_line iteration order to benchmark winner
alfadur
parents:
13969
diff
changeset
|
281 |
for vector in ArcPoints::new(radius) { |
a1895019bb94
change draw_thick_line iteration order to benchmark winner
alfadur
parents:
13969
diff
changeset
|
282 |
for delta in EquidistantPoints::new(vector) { |
14097
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
283 |
for point in line.into_iter() { |
13967 | 284 |
self.map_point(point + delta, |p| { |
285 |
if *p != value { |
|
286 |
*p = value; |
|
287 |
result += 1; |
|
288 |
} |
|
289 |
}) |
|
13965
4162ea9ae333
Use integral-geometry iterators to implement Land2D::draw_thick_line, remove no longer unused functions from Land2D
unc0rr
parents:
13964
diff
changeset
|
290 |
} |
13964
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
291 |
} |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
292 |
} |
a325ed57ebfe
Don't generate unnecessary duplication in case of equal coordinates
unc0rr
parents:
13961
diff
changeset
|
293 |
|
13965
4162ea9ae333
Use integral-geometry iterators to implement Land2D::draw_thick_line, remove no longer unused functions from Land2D
unc0rr
parents:
13964
diff
changeset
|
294 |
result |
13955
9c112f2ae02d
Raise levels of abstraction to implement draw_thick_line() avoiding code duplication
unc0rr
parents:
13952
diff
changeset
|
295 |
} |
13938 | 296 |
} |
297 |
||
298 |
#[cfg(test)] |
|
299 |
mod tests { |
|
300 |
use super::*; |
|
301 |
||
302 |
#[test] |
|
303 |
fn basics() { |
|
14073 | 304 |
let l: Land2D<u8> = Land2D::new(Size::new(30, 50), 0); |
14071
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
305 |
|
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
306 |
assert_eq!(l.play_width(), 30); |
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
307 |
assert_eq!(l.play_height(), 50); |
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
308 |
assert_eq!(l.width(), 32); |
4b40bdd214df
Use next_power_of_two() just like hedgewars engine does, expose original and real dimensions
unc0rr
parents:
13972
diff
changeset
|
309 |
assert_eq!(l.height(), 64); |
13938 | 310 |
|
311 |
assert!(l.is_valid_coordinate(0, 0)); |
|
312 |
assert!(!l.is_valid_coordinate(-1, -1)); |
|
313 |
||
314 |
assert!(l.is_valid_coordinate(31, 63)); |
|
315 |
assert!(!l.is_valid_coordinate(32, 63)); |
|
316 |
assert!(!l.is_valid_coordinate(31, 64)); |
|
317 |
} |
|
318 |
||
13945 | 319 |
#[test] |
320 |
fn fill() { |
|
14053 | 321 |
let mut l: Land2D<u8> = Land2D::new(Size::square(128), 0); |
13945 | 322 |
|
14097
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
323 |
l.draw_line(Line::new(Point::new(0, 0), Point::new(32, 96)), 1); |
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
324 |
l.draw_line(Line::new(Point::new(32, 96), Point::new(64, 32)), 1); |
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
325 |
l.draw_line(Line::new(Point::new(64, 32), Point::new(96, 80)), 1); |
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
326 |
l.draw_line(Line::new(Point::new(96, 80), Point::new(128, 0)), 1); |
13945 | 327 |
|
14097
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
328 |
l.draw_line(Line::new(Point::new(0, 128), Point::new(64, 96)), 1); |
e5904ead4864
Introduce OutlineSegmentsIterator, some refactoring
unC0Rr
parents:
14073
diff
changeset
|
329 |
l.draw_line(Line::new(Point::new(128, 128), Point::new(64, 96)), 1); |
13945 | 330 |
|
13969 | 331 |
l.fill(Point::new(32, 32), 1, 2); |
332 |
l.fill(Point::new(16, 96), 1, 3); |
|
333 |
l.fill(Point::new(60, 100), 1, 4); |
|
13945 | 334 |
|
335 |
assert_eq!(l.pixels[0][0], 1); |
|
336 |
assert_eq!(l.pixels[96][64], 1); |
|
337 |
||
338 |
assert_eq!(l.pixels[40][32], 2); |
|
339 |
assert_eq!(l.pixels[40][96], 2); |
|
340 |
assert_eq!(l.pixels[5][0], 3); |
|
341 |
assert_eq!(l.pixels[120][0], 3); |
|
342 |
assert_eq!(l.pixels[5][127], 3); |
|
343 |
assert_eq!(l.pixels[120][127], 3); |
|
344 |
assert_eq!(l.pixels[35][64], 3); |
|
345 |
assert_eq!(l.pixels[120][20], 4); |
|
346 |
assert_eq!(l.pixels[120][100], 4); |
|
347 |
assert_eq!(l.pixels[100][64], 4); |
|
348 |
} |
|
13938 | 349 |
} |