diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9900ac5 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/pmcxs/hexgrid + +go 1.14 diff --git a/layout.go b/layout.go index a7612ca..3669a2b 100644 --- a/layout.go +++ b/layout.go @@ -21,6 +21,40 @@ var orientationPointy orientation = orientation{math.Sqrt(3.), math.Sqrt(3.) / 2 var orientationFlat orientation = orientation{3. / 2., 0., math.Sqrt(3.) / 2., math.Sqrt(3.), 2. / 3., 0., -1. / 3., math.Sqrt(3.) / 3., 0.} +// LayoutFlat returns a layout with flat orientation +func LayoutFlat00(sizex float64, sizey float64) layout { + return layout{ + orientation: orientationFlat, + size: point{ + x: sizex, + y: sizey, + }, + origin: point{ + x: 0, + y: 0, + }, + } +} + +// LayoutPointY00 returns a layout with flat orientation +func LayoutPointY00(sizex float64, sizey float64) layout { + return layout{ + orientation: orientationPointy, + size: point{ + x: sizex, + y: sizey, + }, + origin: point{ + x: 0, + y: 0, + }, + } +} + +func Point(point point) (float64, float64) { + return point.x, point.y +} + // HexToPixel returns the center pixel for a given hexagon an a certain layout func HexToPixel(l layout, h hex) point {