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