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