/
OpenSimplexNoise.hx
169 lines (132 loc) · 5.36 KB
/
OpenSimplexNoise.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
This resource allows you to configure and sample a fractal noise space. Here is a brief usage example that configures an OpenSimplexNoise and gets samples at various positions and dimensions:
```
var noise = OpenSimplexNoise.new()
# Configure
noise.seed = randi()
noise.octaves = 4
noise.period = 20.0
noise.persistence = 0.8
# Sample
print("Values:")
print(noise.get_noise_2d(1.0, 1.0))
print(noise.get_noise_3d(0.5, 3.0, 15.0))
print(noise.get_noise_4d(0.5, 1.9, 4.7, 0.0))
```
**/
@:libType
@:csNative
@:native("Godot.OpenSimplexNoise")
@:autoBuild(godot.Godot.buildUserClass())
extern class OpenSimplexNoise extends godot.Resource {
/**
Difference in period between `godot.OpenSimplexNoise.octaves`.
**/
@:native("Lacunarity")
public var lacunarity:Single;
/**
Contribution factor of the different octaves. A `persistence` value of 1 means all the octaves have the same contribution, a value of 0.5 means each octave contributes half as much as the previous one.
**/
@:native("Persistence")
public var persistence:Single;
/**
Period of the base octave. A lower period results in a higher-frequency noise (more value changes across the same distance).
**/
@:native("Period")
public var period:Single;
/**
Number of OpenSimplex noise layers that are sampled to get the fractal noise. Higher values result in more detailed noise but take more time to generate.
Note: The maximum allowed value is 9.
**/
@:native("Octaves")
public var octaves:Int;
/**
Seed used to generate random values, different seeds will generate different noise maps.
**/
@:native("Seed")
public var seed:Int;
@:native("new")
public function new():Void;
@:native("GetSeed")
public function getSeed():Int;
@:native("SetSeed")
public function setSeed(seed:Int):Void;
@:native("SetOctaves")
public function setOctaves(octaveCount:Int):Void;
@:native("GetOctaves")
public function getOctaves():Int;
@:native("SetPeriod")
public function setPeriod(period:Single):Void;
@:native("GetPeriod")
public function getPeriod():Single;
@:native("SetPersistence")
public function setPersistence(persistence:Single):Void;
@:native("GetPersistence")
public function getPersistence():Single;
@:native("SetLacunarity")
public function setLacunarity(lacunarity:Single):Void;
@:native("GetLacunarity")
public function getLacunarity():Single;
#if doc_gen
/**
Generate a noise image in `godot.Image_Format.l8` format with the requested `width` and `height`, based on the current noise parameters. If `noise_offset` is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
@param noiseOffset If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("GetImage")
public function getImage(width:Int, height:Int, ?noiseOffset:Null<godot.Vector2>):godot.Image;
#else
/**
Generate a noise image in `godot.Image_Format.l8` format with the requested `width` and `height`, based on the current noise parameters. If `noise_offset` is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
@param noiseOffset If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("GetImage")
public overload function getImage(width:Int, height:Int):godot.Image;
/**
Generate a noise image in `godot.Image_Format.l8` format with the requested `width` and `height`, based on the current noise parameters. If `noise_offset` is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
@param noiseOffset If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("GetImage")
public overload function getImage(width:Int, height:Int, noiseOffset:Nullable1<godot.Vector2>):godot.Image;
#end
/**
Generate a tileable noise image in `godot.Image_Format.l8` format, based on the current noise parameters. Generated seamless images are always square (`size` × `size`).
Note: Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise.
**/
@:native("GetSeamlessImage")
public function getSeamlessImage(size:Int):godot.Image;
/**
Returns the 1D noise value `[-1,1]` at the given x-coordinate.
Note: This method actually returns the 2D noise value `[-1,1]` with fixed y-coordinate value 0.0.
**/
@:native("GetNoise1d")
public function getNoise1d(x:Single):Single;
/**
Returns the 2D noise value `[-1,1]` at the given position.
**/
@:native("GetNoise2d")
public function getNoise2d(x:Single, y:Single):Single;
/**
Returns the 3D noise value `[-1,1]` at the given position.
**/
@:native("GetNoise3d")
public function getNoise3d(x:Single, y:Single, z:Single):Single;
/**
Returns the 4D noise value `[-1,1]` at the given position.
**/
@:native("GetNoise4d")
public function getNoise4d(x:Single, y:Single, z:Single, w:Single):Single;
/**
Returns the 2D noise value `[-1,1]` at the given position.
**/
@:native("GetNoise2dv")
public function getNoise2dv(pos:godot.Vector2):Single;
/**
Returns the 3D noise value `[-1,1]` at the given position.
**/
@:native("GetNoise3dv")
public function getNoise3dv(pos:godot.Vector3):Single;
}