Compare commits
2 Commits
52494022f6
...
cc2addf7e2
Author | SHA1 | Date | |
---|---|---|---|
cc2addf7e2 | |||
cc72cd1171 |
@ -30,6 +30,7 @@ func perlinLerp(t, a, b float64) float64 { return a + t*(b-a) }
|
||||
|
||||
func perlinAt2D(q [2]float64, rx, ry float64) float64 { return rx*q[0] + ry*q[1] }
|
||||
|
||||
// noise2d generates 2-dimensional noise. The result is in range [-sqrt(1/4),sqrt(1/4)].
|
||||
func (p *Perlin) noise1d(x float64) float64 {
|
||||
tx := x + perlinN
|
||||
bx0 := int(tx) & perlinBM
|
||||
@ -44,6 +45,7 @@ func (p *Perlin) noise1d(x float64) float64 {
|
||||
return perlinLerp(sx, u, v)
|
||||
}
|
||||
|
||||
// noise2d generates 2-dimensional noise. The result is in range [-sqrt(1/2),sqrt(1/2)].
|
||||
func (p *Perlin) noise2d(x, y float64) float64 {
|
||||
tx := x + perlinN
|
||||
bx0 := int(tx) & perlinBM
|
||||
|
@ -16,6 +16,11 @@ func Rect(x0, y0, x1, y1 int) Rectangle {
|
||||
return Rectangle{Point{x0, y0}, Point{x1, y1}}
|
||||
}
|
||||
|
||||
// RectRel is a shorthand function to create a rectangle specifying its width and height instead of a second coordinate.
|
||||
func RectRel(x, y, w, h int) Rectangle {
|
||||
return Rectangle{Point{x, y}, Point{x + w, y + h}}
|
||||
}
|
||||
|
||||
// Add translates rectangle r by point p.
|
||||
func (r Rectangle) Add(p Point) Rectangle {
|
||||
return Rectangle{
|
||||
|
@ -17,6 +17,11 @@ func RectF(x0, y0, x1, y1 float64) RectangleF {
|
||||
return RectangleF{PtF(x0, y0), PtF(x1, y1)}
|
||||
}
|
||||
|
||||
// RectRelF is a shorthand function to create a rectangle specifying its width and height instead of a second coordinate.
|
||||
func RectRelF(x, y, w, h float64) RectangleF {
|
||||
return RectangleF{PointF{x, y}, PointF{x + w, y + h}}
|
||||
}
|
||||
|
||||
// Add translates rectangle r by point p.
|
||||
func (r RectangleF) Add(p PointF) RectangleF {
|
||||
return RectangleF{
|
||||
|
@ -17,6 +17,11 @@ func RectF32(x0, y0, x1, y1 float32) RectangleF32 {
|
||||
return RectangleF32{PtF32(x0, y0), PtF32(x1, y1)}
|
||||
}
|
||||
|
||||
// RectRelF32 is a shorthand function to create a rectangle specifying its width and height instead of a second coordinate.
|
||||
func RectRelF32(x, y, w, h float32) RectangleF32 {
|
||||
return RectangleF32{PointF32{x, y}, PointF32{x + w, y + h}}
|
||||
}
|
||||
|
||||
// Add translates rectangle r by point p.
|
||||
func (r RectangleF32) Add(p PointF32) RectangleF32 {
|
||||
return RectangleF32{
|
||||
|
Loading…
Reference in New Issue
Block a user