项目作者: fogleman

项目描述 :
Poisson Disc sampling in Go.
高级语言: Go
项目地址: git://github.com/fogleman/poissondisc.git
创建时间: 2018-08-31T01:29:02Z
项目社区:https://github.com/fogleman/poissondisc

开源协议:MIT License

下载


poissondisc

Poisson Disc sampling in Go.

Installation

  1. $ go get -u github.com/fogleman/poissondisc

Documentation

https://godoc.org/github.com/fogleman/poissondisc

Learn more about Poisson-disc sampling:

https://www.jasondavies.com/poisson-disc/

https://bl.ocks.org/mbostock/dbb02448b0f93e4c82c3

Usage

  1. var x0, y0, x1, y1, r float64
  2. x0 = 0 // bbox min
  3. y0 = 0 // bbox min
  4. x1 = 1000 // bbox max
  5. y1 = 1000 // bbox max
  6. r = 10 // min distance between points
  7. k := 30 // max attempts to add neighboring point
  8. points := poissondisc.Sample(x0, y0, x1, y1, r, k, nil)
  9. for _, p := range points {
  10. fmt.Println(p.X, p.Y)
  11. }

Example

  1. $ go run examples/example.go

Example