updated the readme and cmd/recty/main.go

added examples to the readme and updated main.go to give an example of
who one could use the rect package
This commit is contained in:
dm
2016-08-27 22:28:15 -07:00
parent 71f3aede25
commit 0f44030e53
2 changed files with 129 additions and 12 deletions
+44 -11
View File
@@ -13,19 +13,52 @@ func main() {
P3: rect.Point{2, 1},
P4: rect.Point{2, 2},
}
fmt.Println(r.IsRect())
r1 := rect.Rectangle{
P1: rect.Point{0, 0},
P2: rect.Point{0, 1},
P3: rect.Point{1, 0},
P4: rect.Point{1, 1},
P1: rect.Point{1, 1},
P2: rect.Point{1, 2},
P3: rect.Point{2, 1},
P4: rect.Point{2, 2},
}
fmt.Println(r1.IsRect())
r1 := rect.Rectangle{
P1: rect.Point{0, 0},
P2: rect.Point{0, 1},
P3: rect.Point{1, 0},
P4: rect.Point{1, 1},
r2 := rect.Rectangle{
P1: rect.Point{2, 2},
P2: rect.Point{2, 3},
P3: rect.Point{3, 2},
P4: rect.Point{3, 3},
}
fmt.Println(r1.IsRect())
fmt.Println(rect.Intersection(r1, r2))
r3 := rect.Rectangle{
P1: rect.Point{0, 0},
P2: rect.Point{0, 3},
P3: rect.Point{3, 0},
P4: rect.Point{3, 3},
}
r4 := rect.Rectangle{
P1: rect.Point{2, 2},
P2: rect.Point{2, 3},
P3: rect.Point{3, 2},
P4: rect.Point{3, 3},
}
fmt.Println(rect.Adjacency(r3, r4))
r5 := rect.Rectangle{
P1: rect.Point{0, 0},
P2: rect.Point{0, 3},
P3: rect.Point{3, 0},
P4: rect.Point{3, 3},
}
r6 := rect.Rectangle{
P1: rect.Point{1, 1},
P2: rect.Point{1, 2},
P3: rect.Point{2, 1},
P4: rect.Point{2, 2},
}
fmt.Println(rect.Containment(r5, r6))
}