hexagons

package
v0.0.0-...-ee0865d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

https://www.redblobgames.com/grids/hexagons/

Index

Constants

This section is empty.

Variables

View Source
var CubeDirectionMap = map[string]int{
	"(1.0, 0.0, 0.0)":  0,
	"(1.0, -1.0, 0.0)": 1,
	"(0.0, -1.0, 0.0)": 2,
	"(-1.0, 0.0, 0.0)": 3,
	"(-1.0, 1.0, 0.0)": 4,
	"(0.0, 1.0, 0.0)":  5,
}

Functions

func CubeDistance

func CubeDistance(a Cube, b Cube) float64

获取两点之间的距离

func ListDirection

func ListDirection(source, amount int, includeSelf bool, mode ListDirectionMode) (result []int)

获取源方向[source]周围的方向集合

Types

type Cube

type Cube struct {
	// hex q/map x
	X float64
	Y float64
	// hex r/map y
	Z float64
}

/ 六边形坐标系-立体

func CubeAdd

func CubeAdd(a Cube, b Cube) Cube

func CubeDirection

func CubeDirection(direction int) Cube

func CubeNeighbor

func CubeNeighbor(a Cube, direction int) Cube

func CubeNeighbors

func CubeNeighbors(cube Cube) []Cube

func CubeRing

func CubeRing(center Cube, radius int) []Cube

func CubeRound

func CubeRound(cube Cube) Cube

func CubeScale

func CubeScale(a Cube, k int) Cube

func CubeSpiral

func CubeSpiral(center Cube, radius int) []Cube

func Hexa2Cube

func Hexa2Cube(hexa Hexa) Cube

func Pixel2Cube

func Pixel2Cube(point Point, size float64) Cube

func (*Cube) String

func (p *Cube) String() string

type Hexa

type Hexa struct {
	//列 cube x
	Q float64
	//行 cube z
	R float64
}

/ 六边形坐标系-行列

func Cube2Hexa

func Cube2Hexa(cube Cube) Hexa

func HexaRound

func HexaRound(hexa Hexa) Hexa

func Pixel2Hexa

func Pixel2Hexa(point Point, size float64) Hexa

func (*Hexa) String

func (hexa *Hexa) String() string

type ListDirectionMode

type ListDirectionMode int
const (
	ListDirectionMode_左右 ListDirectionMode = iota + 1
	ListDirectionMode_右左
	ListDirectionMode_顺时针
	ListDirectionMode_逆时针
)

type Point

type Point struct {
	// 地图上的坐标
	X float64
	// 地图上的坐标
	Y float64
	// 地图上的坐标
	Z float64
}

func Cube2Pixel

func Cube2Pixel(cube Cube, size float64) Point

func Hexa2Pixel

func Hexa2Pixel(hexa Hexa, size float64) Point

转化成像素坐标 size表示六边形的像素边长

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL