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