本文整理匯總了Golang中github.com/iand/perlin.Noise2D函數的典型用法代碼示例。如果您正苦於以下問題:Golang Noise2D函數的具體用法?Golang Noise2D怎麽用?Golang Noise2D使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Noise2D函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: render
func render() {
base_x += 1.0
base_y += 1.0
alpha = alpha_lerp()
beta = beta_lerp()
r := uint8(r_lerp())
g := uint8(g_lerp())
b := uint8(b_lerp())
for x := 0.0; x < width; x++ {
for y := 0.0; y < height; y++ {
px := base_x + x
py := base_y + y
perlin := perlin.Noise2D(px, py, int64(seed), alpha, beta, octaves)
perlin = (perlin * .5) + .5
perlin = math.Max(0.0, perlin)
perlin = math.Min(1.0, perlin)
color := rog.RGB{r, g, b}
result := rog.Black.Alpha(color, perlin)
rog.Set(int(x), int(y)+1, nil, result, "")
}
}
}
示例2: Feature2
func (self *World) Feature2(x uint16, z uint16) float64 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/4), float64(z-MAP_DIAM)/(NOISE_SCALE/4), self.seed, 3, 5, 7)
if noise > 1.0 {
noise = 1.0
}
if noise < -1.0 {
noise = -1.0
}
return noise
}
示例3: Feature1
func (self *World) Feature1(x uint16, z uint16) float64 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/4), float64(z-MAP_DIAM)/(NOISE_SCALE/4), worldSeed, 6, 8, 14)
if noise > 1.0 {
noise = 1.0
}
if noise < -1.0 {
noise = -1.0
}
return noise
}
示例4: SoilThickness
func (self *World) SoilThickness(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(2*NOISE_SCALE), float64(z-MAP_DIAM)/(2*NOISE_SCALE), self.seed, 1.8, 1.6, 8)
if noise > 1.0 {
noise = 1.0
}
if noise < -1.0 {
noise = -1.0
}
return uint16(noise*2.5 + 2.5)
}
示例5: Copper
func (self *World) Copper(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2.5), float64(z-MAP_DIAM)/(NOISE_SCALE/2.5), self.seed, 3.1, 2.0, 6)
if noise > 1.0 {
noise = 1.0
}
if noise < 0.54 {
noise = 0
}
noise = noise * 3
return uint16(noise)
}
示例6: Iron
func (self *World) Iron(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2.2), float64(z-MAP_DIAM)/(NOISE_SCALE/2.2), self.seed, 2.5, 1.9, 6)
if noise > 1.0 {
noise = 1.0
}
if noise < 0.56 {
noise = 0
}
noise = noise * 3
return uint16(noise)
}
示例7: Coal
func (self *World) Coal(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2), float64(z-MAP_DIAM)/(NOISE_SCALE/2), self.seed, 1.9, 1.2, 12)
if noise > 1.0 {
noise = 1.0
}
if noise < 0.55 {
noise = 0
}
noise = noise * 4
return uint16(noise)
}
示例8: Rocks
func (self *World) Rocks(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2), float64(z-MAP_DIAM)/(NOISE_SCALE/2), self.seed, 1.5, 3.0, 12)
if noise > 1.0 {
noise = 1.0
}
if noise < 0.8 {
noise = 0
}
noise = noise * 5
return uint16(noise)
}
示例9: Ore
func (self *World) Ore(x uint16, z uint16, blockid BlockId, occcurrence float64) uint16 {
xloc := (float64(x) + MAP_DIAM*float64(blockid)) / (NOISE_SCALE / 2)
zloc := (float64(z) + MAP_DIAM*float64(blockid)) / (NOISE_SCALE / 2)
noise := perlin.Noise2D(xloc, zloc, self.seed, 2.4, 1.8, 4)
if noise > 1.0 {
noise = 1.0
}
if noise < occcurrence {
noise = 0
} else {
noise = 5 * (noise - occcurrence) / (1 - occcurrence)
}
return uint16(noise)
}
示例10: GroundLevel
func (self *World) GroundLevel(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(4*NOISE_SCALE), float64(z-MAP_DIAM)/(4*NOISE_SCALE), self.seed, 1.4, 1.2, 4)
if noise > 1.0 {
noise = 1.0
}
if noise < -1.0 {
noise = -1.0
}
if noise < 0.0 {
noise /= 10
}
ground := uint16(SEA_LEVEL + ((CHUNK_HEIGHT-SEA_LEVEL)*0.9)*(noise+0.1)/1.1)
return ground
}
示例11: GroundLevel
func (self *World) GroundLevel(x uint16, z uint16) uint16 {
noise := perlin.Noise2D(float64(x-MAP_DIAM)/(4*NOISE_SCALE), float64(z-MAP_DIAM)/(4*NOISE_SCALE), worldSeed, 1.4, 1.2, 4)
if noise > 0.85 {
noise = noise + (1.0-noise)*0.5
}
if noise > 1.0 {
noise = 1.0
}
if noise < -1.0 {
noise = -1.0
}
if noise < 0 {
noise /= 15
}
ground := uint16((CHUNK_HEIGHT/2)*(noise+0.1)/1.1 + CHUNK_HEIGHT/3.0)
return ground
}
示例12: NewPane
func NewPane(w, h, n int) *Pane {
p := new(Pane)
p.w = w
p.h = h
p.fw = dx * float64(w)
p.fh = dx * float64(h)
p.coat = make([]float64, w*h)
p.dirt = make([]float64, w*h)
p.droplets = make([]Droplet, n)
for i := range p.droplets {
p.droplets[i].init()
}
for i := range p.dirt {
p.dirt[i] = perlin.Noise2D(float64(i%w)/10, float64(i/w)/10, 1, 2, 2, 3)*0.7 + 1
}
return p
}
示例13: Precipitation
func (self *World) Precipitation(x uint16, z uint16) float64 {
return perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE), float64(z-MAP_DIAM)/(NOISE_SCALE), self.seed, 2.0, 0.6, 1)
}