| 1 | module geometry |
| 2 | |
| 3 | const module_name = 'geometry' |
| 4 | |
| 5 | pub enum Shape { |
| 6 | circle |
| 7 | rectangle |
| 8 | triangle |
| 9 | } |
| 10 | |
| 11 | pub type ShapeMap = map[Shape]string |
| 12 | |
| 13 | // used by vlib/v/tests/map_enum_keys_test.v |
| 14 | pub enum Form3D { |
| 15 | sphere |
| 16 | cylinder |
| 17 | cone |
| 18 | cube |
| 19 | invalid |
| 20 | } |
| 21 | |
| 22 | pub struct Point { |
| 23 | pub mut: |
| 24 | x int |
| 25 | y int |
| 26 | } |
| 27 | |
| 28 | pub struct Line { |
| 29 | pub mut: |
| 30 | ps []Point |
| 31 | } |
| 32 | |
| 33 | pub fn (a Point) + (b Point) Point { |
| 34 | return Point{ |
| 35 | x: a.x + b.x |
| 36 | y: a.y + b.y |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | pub fn (a Point) str() string { |
| 41 | return '${a.x} ${a.y}' |
| 42 | } |
| 43 | |
| 44 | pub fn point_str(a Point) string { |
| 45 | return a.str() |
| 46 | } |
| 47 | |
| 48 | pub type PointCond = fn (p Point) bool |
| 49 | |