picrate 2.0.1-java → 2.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/CHANGELOG.md +10 -0
- data/README.md +6 -3
- data/Rakefile +2 -1
- data/docs/_includes/footer.html +1 -1
- data/docs/_layouts/post.html +1 -1
- data/docs/_methods/alternative_methods.md +2 -1
- data/docs/_methods/noise_mode.md +88 -0
- data/docs/_posts/2018-05-06-install_jruby.md +3 -3
- data/docs/_posts/2018-11-18-building-gem.md +3 -1
- data/docs/_posts/2020-03-09-auto_install_picrate.md +2 -3
- data/docs/_posts/2020-05-11-getting_started_manjaro.md +20 -8
- data/docs/classes.md +2 -2
- data/docs/editors.md +2 -2
- data/docs/gems.md +3 -3
- data/docs/index.html +1 -1
- data/docs/libraries.md +2 -2
- data/docs/live.md +2 -2
- data/docs/magic.md +2 -2
- data/docs/methods.md +2 -2
- data/docs/modules.md +3 -3
- data/docs/objects.md +2 -2
- data/lib/picrate.rb +2 -1
- data/lib/picrate/app.rb +7 -2
- data/lib/picrate/helper_methods.rb +1 -1
- data/lib/picrate/native_folder.rb +1 -3
- data/lib/picrate/runner.rb +4 -4
- data/lib/picrate/version.rb +1 -1
- data/library/jcomplex/jcomplex.rb +1 -0
- data/library/pdf/pdf.rb +6 -0
- data/mvnw +2 -2
- data/mvnw.cmd +2 -2
- data/picrate.gemspec +3 -2
- data/pom.rb +22 -8
- data/pom.xml +27 -5
- data/src/main/java/monkstone/PicrateLibrary.java +1 -1
- data/src/main/java/monkstone/complex/JComplex.java +252 -0
- data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +41 -93
- data/src/main/java/monkstone/noise/FastTerrain.java +874 -0
- data/src/main/java/monkstone/noise/Noise.java +90 -0
- data/src/main/java/monkstone/noise/NoiseGenerator.java +75 -0
- data/src/main/java/monkstone/noise/NoiseMode.java +28 -0
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +881 -0
- data/src/main/java/monkstone/noise/OpenSimplex2S.java +1106 -0
- data/src/main/java/monkstone/noise/SmoothTerrain.java +1099 -0
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +22 -23
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/ShimAWT.java +711 -0
- data/src/main/java/processing/core/PApplet.java +14880 -14101
- data/src/main/java/processing/core/PConstants.java +5 -5
- data/src/main/java/processing/core/PFont.java +1 -1
- data/src/main/java/processing/core/PGraphics.java +284 -271
- data/src/main/java/processing/core/PImage.java +1620 -1815
- data/src/main/java/processing/core/PShape.java +18 -18
- data/src/main/java/processing/core/PSurface.java +105 -139
- data/src/main/java/processing/core/PSurfaceNone.java +29 -0
- data/src/main/java/processing/core/PVector.java +23 -23
- data/src/main/java/processing/data/Table.java +4 -4
- data/src/main/java/processing/net/Client.java +13 -13
- data/src/main/java/processing/net/Server.java +5 -5
- data/src/main/java/processing/opengl/PGL.java +649 -3699
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +2503 -2278
- data/src/main/java/processing/opengl/PJOGL.java +374 -1526
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +220 -86
- data/src/main/java/processing/pdf/PGraphicsPDF.java +607 -0
- data/test/deglut_spec_test.rb +2 -2
- data/test/respond_to_test.rb +0 -1
- data/vendors/Rakefile +33 -21
- data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
- metadata +24 -9
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -465
data/test/deglut_spec_test.rb
CHANGED
@@ -15,10 +15,10 @@ class DeglutTest < Minitest::Test
|
|
15
15
|
(-720..720).step(1) do |deg|
|
16
16
|
sine = DegLut.sin(deg)
|
17
17
|
deg_sin = Math.sin(deg * to_radian)
|
18
|
-
assert_in_delta(sine, deg_sin, delta = 0.
|
18
|
+
assert_in_delta(sine, deg_sin, delta = 0.0003)
|
19
19
|
cosine = DegLut.cos(deg)
|
20
20
|
deg_cos = Math.cos(deg * to_radian)
|
21
|
-
assert_in_delta(cosine, deg_cos, delta = 0.
|
21
|
+
assert_in_delta(cosine, deg_cos, delta = 0.0003)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/test/respond_to_test.rb
CHANGED
data/vendors/Rakefile
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'rake/clean'
|
5
|
+
require_relative './geany'
|
5
6
|
WARNING = 'WARNING: wget download failed you could do a manual download'
|
6
7
|
SOUND = 'sound.zip'
|
7
|
-
|
8
|
-
VIDEO = 'video
|
9
|
-
|
10
|
-
EXAMPLES = '0.5.
|
8
|
+
PROCESSING_GITHUB = 'https://github.com/processing'
|
9
|
+
VIDEO = 'video.zip'
|
10
|
+
DOWNLOAD = 'releases/download/latest'
|
11
|
+
EXAMPLES = '0.5.6'
|
11
12
|
HOME_DIR = ENV['HOME']
|
12
13
|
LIBRARY = File.join(HOME_DIR, '.picrate', 'libraries')
|
13
14
|
PROJECT_DIR = File.join(HOME_DIR, 'projects')
|
@@ -46,16 +47,24 @@ task download_samples: ["#{EXAMPLES}.tar.gz"]
|
|
46
47
|
|
47
48
|
desc 'download sound library'
|
48
49
|
task :download_sound do
|
49
|
-
wget_base = 'wget
|
50
|
-
wget_string = [wget_base, '
|
51
|
-
|
50
|
+
wget_base = ['wget', PROCESSING_GITHUB].join(' ')
|
51
|
+
wget_string = [wget_base, 'processing-sound', DOWNLOAD, SOUND].join('/')
|
52
|
+
begin
|
53
|
+
sh wget_string
|
54
|
+
rescue StandardError
|
55
|
+
warn(WARNING)
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
desc 'download video library'
|
55
60
|
task :download_video do
|
56
|
-
wget_base = 'wget
|
57
|
-
wget_string = [wget_base, '
|
58
|
-
|
61
|
+
wget_base = ['wget', PROCESSING_GITHUB].join(' ')
|
62
|
+
wget_string = [wget_base, 'processing-video', DOWNLOAD, VIDEO].join('/')
|
63
|
+
begin
|
64
|
+
sh wget_string
|
65
|
+
rescue StandardError
|
66
|
+
warn(WARNING)
|
67
|
+
end
|
59
68
|
end
|
60
69
|
|
61
70
|
desc 'initialize ~/.picrate directories'
|
@@ -69,9 +78,11 @@ task :install_config do
|
|
69
78
|
FileUtils.mkdir_p "#{HOME_DIR}/.config/geany/templates/files"
|
70
79
|
FileUtils.cp 'picrate.rb', "#{HOME_DIR}/.config/geany/templates/files"
|
71
80
|
end
|
72
|
-
|
73
|
-
|
74
|
-
FileUtils.
|
81
|
+
project_dir = File.join(HOME_DIR, 'projects')
|
82
|
+
unless File.exist? File.join(project_dir, 'picrate_sketches.geany')
|
83
|
+
FileUtils.mkdir_p "#{HOME_DIR}/projects"
|
84
|
+
config = GeanyConfig.new(project_dir)
|
85
|
+
config.save(File.join(project_dir, 'picrate_sketches.geany'))
|
75
86
|
end
|
76
87
|
end
|
77
88
|
|
@@ -86,15 +97,16 @@ end
|
|
86
97
|
|
87
98
|
desc 'copy sound library'
|
88
99
|
task copy_sound: SOUND do
|
89
|
-
|
90
|
-
|
91
|
-
|
100
|
+
sh "unzip #{SOUND}"
|
101
|
+
sh "rm -r #{LIBRARY}/sound" if File.exist? "#{LIBRARY}/sound"
|
102
|
+
sh "cp -r sound #{LIBRARY}"
|
103
|
+
sh 'rm -r sound'
|
92
104
|
end
|
93
105
|
|
94
106
|
desc 'copy video library'
|
95
|
-
task copy_video:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
107
|
+
task copy_video: VIDEO do
|
108
|
+
sh "unzip #{VIDEO}"
|
109
|
+
sh "rm -r #{LIBRARY}/video" if File.exist? "#{LIBRARY}/video"
|
110
|
+
sh "cp -r video #{LIBRARY}"
|
111
|
+
sh 'rm -r video'
|
100
112
|
end
|
@@ -1,3 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
def geany_config
|
6
|
+
%(
|
1
7
|
[editor]
|
2
8
|
line_wrapping=false
|
3
9
|
line_break_column=72
|
@@ -19,7 +25,7 @@ indent_mode=2
|
|
19
25
|
|
20
26
|
[project]
|
21
27
|
name=picrate_samples
|
22
|
-
base_path
|
28
|
+
base_path=examples
|
23
29
|
description=Exploring PiCrate
|
24
30
|
file_patterns=*.rb;*.glsl;*.txt;
|
25
31
|
|
@@ -28,14 +34,9 @@ long_line_behaviour=1
|
|
28
34
|
long_line_column=72
|
29
35
|
|
30
36
|
[files]
|
31
|
-
current_page=3
|
32
|
-
FILE_NAME_0=667;Ruby;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Fprojects%2Fpicrate_sketches%2Fbasics%2Farrays%2Farray.rb;0;2
|
33
|
-
FILE_NAME_1=1664;Ruby;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Fprojects%2Fpicrate_sketches%2Fadvanced_data%2Fload_save_json.rb;0;2
|
34
|
-
FILE_NAME_2=259;Sh;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Fjruby_install.sh;0;2
|
35
|
-
FILE_NAME_3=236;Sh;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Ftest.sh;0;2
|
36
37
|
|
37
38
|
[VTE]
|
38
|
-
last_dir
|
39
|
+
last_dir=<%= directory %>
|
39
40
|
|
40
41
|
[build-menu]
|
41
42
|
EX_00_LB=_Execute
|
@@ -60,3 +61,27 @@ NF_02_WD=
|
|
60
61
|
RubyFT_02_LB=_Reek
|
61
62
|
RubyFT_02_CM=reek --failure-exit-code=0 "%f"
|
62
63
|
RubyFT_02_WD=
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Class to merge ERB template and write config to file
|
68
|
+
class GeanyConfig
|
69
|
+
include ERB::Util
|
70
|
+
attr_accessor :home, :directory, :template
|
71
|
+
|
72
|
+
def initialize(directory, template = geany_config)
|
73
|
+
@home = home
|
74
|
+
@directory = directory
|
75
|
+
@template = template
|
76
|
+
end
|
77
|
+
|
78
|
+
def render
|
79
|
+
ERB.new(@template).result(binding)
|
80
|
+
end
|
81
|
+
|
82
|
+
def save(file)
|
83
|
+
File.open(file, 'w+') do |f|
|
84
|
+
f.write(render)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- monkstone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -29,15 +29,15 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '13.0'
|
33
33
|
name: rake
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- docs/_methods/map1d.md
|
131
131
|
- docs/_methods/methods_summary.md
|
132
132
|
- docs/_methods/mouse_pressed.md
|
133
|
+
- docs/_methods/noise_mode.md
|
133
134
|
- docs/_methods/post_initialize.md
|
134
135
|
- docs/_methods/processing_api.md
|
135
136
|
- docs/_methods/settings.md
|
@@ -186,11 +187,12 @@ files:
|
|
186
187
|
- lib/gluegen-rt-natives-linux-amd64.jar
|
187
188
|
- lib/gluegen-rt-natives-linux-armv6hf.jar
|
188
189
|
- lib/gluegen-rt.jar
|
190
|
+
- lib/itextpdf-5.5.13.2.jar
|
189
191
|
- lib/jogl-all-natives-linux-aarch64.jar
|
190
192
|
- lib/jogl-all-natives-linux-amd64.jar
|
191
193
|
- lib/jogl-all-natives-linux-armv6hf.jar
|
192
194
|
- lib/jogl-all.jar
|
193
|
-
- lib/picrate-2.0.
|
195
|
+
- lib/picrate-2.3.0.jar
|
194
196
|
- lib/picrate.rb
|
195
197
|
- lib/picrate/app.rb
|
196
198
|
- lib/picrate/creators/parameters.rb
|
@@ -209,9 +211,11 @@ files:
|
|
209
211
|
- library/color_group/color_group.rb
|
210
212
|
- library/control_panel/control_panel.rb
|
211
213
|
- library/dxf/dxf.rb
|
214
|
+
- library/jcomplex/jcomplex.rb
|
212
215
|
- library/library_proxy/README.md
|
213
216
|
- library/library_proxy/library_proxy.rb
|
214
217
|
- library/net/net.rb
|
218
|
+
- library/pdf/pdf.rb
|
215
219
|
- library/slider/slider.rb
|
216
220
|
- library/vector_utils/vector_utils.rb
|
217
221
|
- library/video_event/video_event.rb
|
@@ -226,11 +230,19 @@ files:
|
|
226
230
|
- src/main/java/monkstone/ColorUtil.java
|
227
231
|
- src/main/java/monkstone/MathToolModule.java
|
228
232
|
- src/main/java/monkstone/PicrateLibrary.java
|
233
|
+
- src/main/java/monkstone/complex/JComplex.java
|
229
234
|
- src/main/java/monkstone/core/LibraryProxy.java
|
235
|
+
- src/main/java/monkstone/fastmath/DegLutTables.java
|
230
236
|
- src/main/java/monkstone/fastmath/Deglut.java
|
231
237
|
- src/main/java/monkstone/fastmath/package-info.java
|
232
238
|
- src/main/java/monkstone/filechooser/Chooser.java
|
233
|
-
- src/main/java/monkstone/noise/
|
239
|
+
- src/main/java/monkstone/noise/FastTerrain.java
|
240
|
+
- src/main/java/monkstone/noise/Noise.java
|
241
|
+
- src/main/java/monkstone/noise/NoiseGenerator.java
|
242
|
+
- src/main/java/monkstone/noise/NoiseMode.java
|
243
|
+
- src/main/java/monkstone/noise/OpenSimplex2F.java
|
244
|
+
- src/main/java/monkstone/noise/OpenSimplex2S.java
|
245
|
+
- src/main/java/monkstone/noise/SmoothTerrain.java
|
234
246
|
- src/main/java/monkstone/slider/CustomHorizontalSlider.java
|
235
247
|
- src/main/java/monkstone/slider/CustomVerticalSlider.java
|
236
248
|
- src/main/java/monkstone/slider/SimpleHorizontalSlider.java
|
@@ -253,8 +265,10 @@ files:
|
|
253
265
|
- src/main/java/monkstone/videoevent/MovieEvent.java
|
254
266
|
- src/main/java/monkstone/videoevent/package-info.java
|
255
267
|
- src/main/java/processing/awt/PGraphicsJava2D.java
|
268
|
+
- src/main/java/processing/awt/PImageAWT.java
|
256
269
|
- src/main/java/processing/awt/PShapeJava2D.java
|
257
270
|
- src/main/java/processing/awt/PSurfaceAWT.java
|
271
|
+
- src/main/java/processing/awt/ShimAWT.java
|
258
272
|
- src/main/java/processing/core/PApplet.java
|
259
273
|
- src/main/java/processing/core/PConstants.java
|
260
274
|
- src/main/java/processing/core/PFont.java
|
@@ -325,6 +339,7 @@ files:
|
|
325
339
|
- src/main/java/processing/opengl/shaders/TexLightFrag.glsl
|
326
340
|
- src/main/java/processing/opengl/shaders/TexLightVert.glsl
|
327
341
|
- src/main/java/processing/opengl/shaders/TexVert.glsl
|
342
|
+
- src/main/java/processing/pdf/PGraphicsPDF.java
|
328
343
|
- src/main/resources/icon/icon-128.png
|
329
344
|
- src/main/resources/icon/icon-16.png
|
330
345
|
- src/main/resources/icon/icon-256.png
|
@@ -343,8 +358,8 @@ files:
|
|
343
358
|
- test/test_helper.rb
|
344
359
|
- test/vecmath_spec_test.rb
|
345
360
|
- vendors/Rakefile
|
361
|
+
- vendors/geany.rb
|
346
362
|
- vendors/picrate.rb
|
347
|
-
- vendors/picrate_sketches.geany
|
348
363
|
homepage: https://ruby-processing.github.io/PiCrate/
|
349
364
|
licenses:
|
350
365
|
- GPL-3.0
|
@@ -365,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
365
380
|
- !ruby/object:Gem::Version
|
366
381
|
version: '0'
|
367
382
|
requirements:
|
368
|
-
- java runtime == 11
|
383
|
+
- java runtime == 11+
|
369
384
|
rubygems_version: 3.0.6
|
370
385
|
signing_key:
|
371
386
|
specification_version: 4
|
@@ -1,465 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java.
|
3
|
-
*
|
4
|
-
* Based on example code by Stefan Gustavson (stegu@itn.liu.se).
|
5
|
-
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
|
6
|
-
* Better rank ordering method for 4D by Stefan Gustavson in 2012.
|
7
|
-
*
|
8
|
-
* This could be speeded up even further, but it's useful as it is.
|
9
|
-
*
|
10
|
-
* Version 2012-03-09
|
11
|
-
*
|
12
|
-
* This code was placed in the public domain by its original author,
|
13
|
-
* Stefan Gustavson. You may use it as you see fit, but
|
14
|
-
* attribution is appreciated.
|
15
|
-
*
|
16
|
-
*/
|
17
|
-
|
18
|
-
package monkstone.noise;
|
19
|
-
|
20
|
-
/**
|
21
|
-
*
|
22
|
-
* @author Martin Prout
|
23
|
-
*/
|
24
|
-
public class SimplexNoise { // Simplex noise in 2D, 3D and 4D
|
25
|
-
|
26
|
-
private static Grad grad3[] = {new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),
|
27
|
-
new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),
|
28
|
-
new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1)};
|
29
|
-
|
30
|
-
private static Grad grad4[] = {new Grad(0, 1, 1, 1), new Grad(0, 1, 1, -1), new Grad(0, 1, -1, 1), new Grad(0, 1, -1, -1),
|
31
|
-
new Grad(0, -1, 1, 1), new Grad(0, -1, 1, -1), new Grad(0, -1, -1, 1), new Grad(0, -1, -1, -1),
|
32
|
-
new Grad(1, 0, 1, 1), new Grad(1, 0, 1, -1), new Grad(1, 0, -1, 1), new Grad(1, 0, -1, -1),
|
33
|
-
new Grad(-1, 0, 1, 1), new Grad(-1, 0, 1, -1), new Grad(-1, 0, -1, 1), new Grad(-1, 0, -1, -1),
|
34
|
-
new Grad(1, 1, 0, 1), new Grad(1, 1, 0, -1), new Grad(1, -1, 0, 1), new Grad(1, -1, 0, -1),
|
35
|
-
new Grad(-1, 1, 0, 1), new Grad(-1, 1, 0, -1), new Grad(-1, -1, 0, 1), new Grad(-1, -1, 0, -1),
|
36
|
-
new Grad(1, 1, 1, 0), new Grad(1, 1, -1, 0), new Grad(1, -1, 1, 0), new Grad(1, -1, -1, 0),
|
37
|
-
new Grad(-1, 1, 1, 0), new Grad(-1, 1, -1, 0), new Grad(-1, -1, 1, 0), new Grad(-1, -1, -1, 0)};
|
38
|
-
|
39
|
-
private final static short PERMS[] = {151, 160, 137, 91, 90, 15,
|
40
|
-
131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
|
41
|
-
190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
|
42
|
-
88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
|
43
|
-
77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,
|
44
|
-
102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,
|
45
|
-
135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,
|
46
|
-
5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,
|
47
|
-
223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,
|
48
|
-
129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,
|
49
|
-
251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,
|
50
|
-
49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,
|
51
|
-
138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180};
|
52
|
-
// To remove the need for index wrapping, double the permutation table length
|
53
|
-
static final short[] PERM = new short[512];
|
54
|
-
static final short[] PERM_MOD_12 = new short[512];
|
55
|
-
|
56
|
-
static {
|
57
|
-
for (int i = 0; i < 512; i++) {
|
58
|
-
PERM[i] = PERMS[i & 255];
|
59
|
-
PERM_MOD_12[i] = (short) (PERM[i] % 12);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
// Skewing and unskewing factors for 2, 3, and 4 dimensions
|
64
|
-
private static final double F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
|
65
|
-
private static final double G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
|
66
|
-
private static final double F3 = 1.0 / 3.0;
|
67
|
-
private static final double G3 = 1.0 / 6.0;
|
68
|
-
private static final double F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
|
69
|
-
private static final double G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
|
70
|
-
|
71
|
-
// This method is a *lot* faster than using (int)Math.floor(x)
|
72
|
-
private static int fastfloor(double x) {
|
73
|
-
int xi = (int) x;
|
74
|
-
return x < xi ? xi - 1 : xi;
|
75
|
-
}
|
76
|
-
|
77
|
-
private static double dot(Grad g, double x, double y) {
|
78
|
-
return g.x * x + g.y * y;
|
79
|
-
}
|
80
|
-
|
81
|
-
private static double dot(Grad g, double x, double y, double z) {
|
82
|
-
return g.x * x + g.y * y + g.z * z;
|
83
|
-
}
|
84
|
-
|
85
|
-
private static double dot(Grad g, double x, double y, double z, double w) {
|
86
|
-
return g.x * x + g.y * y + g.z * z + g.w * w;
|
87
|
-
}
|
88
|
-
|
89
|
-
// 2D simplex noise
|
90
|
-
|
91
|
-
/**
|
92
|
-
*
|
93
|
-
* @param xin
|
94
|
-
* @param yin
|
95
|
-
* @return noise double
|
96
|
-
*/
|
97
|
-
public static double noise(double xin, double yin) {
|
98
|
-
double n0, n1, n2; // Noise contributions from the three corners
|
99
|
-
// Skew the input space to determine which simplex cell we're in
|
100
|
-
double s = (xin + yin) * F2; // Hairy factor for 2D
|
101
|
-
int i = fastfloor(xin + s);
|
102
|
-
int j = fastfloor(yin + s);
|
103
|
-
double t = (i + j) * G2;
|
104
|
-
double X0 = i - t; // Unskew the cell origin back to (x,y) space
|
105
|
-
double Y0 = j - t;
|
106
|
-
double x0 = xin - X0; // The x,y distances from the cell origin
|
107
|
-
double y0 = yin - Y0;
|
108
|
-
// For the 2D case, the simplex shape is an equilateral triangle.
|
109
|
-
// Determine which simplex we are in.
|
110
|
-
int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords
|
111
|
-
if (x0 > y0) {
|
112
|
-
i1 = 1;
|
113
|
-
j1 = 0;
|
114
|
-
} // lower triangle, XY order: (0,0)->(1,0)->(1,1)
|
115
|
-
else {
|
116
|
-
i1 = 0;
|
117
|
-
j1 = 1;
|
118
|
-
} // upper triangle, YX order: (0,0)->(0,1)->(1,1)
|
119
|
-
// A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
|
120
|
-
// a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
|
121
|
-
// c = (3-sqrt(3))/6
|
122
|
-
double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
|
123
|
-
double y1 = y0 - j1 + G2;
|
124
|
-
double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords
|
125
|
-
double y2 = y0 - 1.0 + 2.0 * G2;
|
126
|
-
// Work out the hashed gradient indices of the three simplex corners
|
127
|
-
int ii = i & 255;
|
128
|
-
int jj = j & 255;
|
129
|
-
int gi0 = PERM_MOD_12[ii + PERM[jj]];
|
130
|
-
int gi1 = PERM_MOD_12[ii + i1 + PERM[jj + j1]];
|
131
|
-
int gi2 = PERM_MOD_12[ii + 1 + PERM[jj + 1]];
|
132
|
-
// Calculate the contribution from the three corners
|
133
|
-
double t0 = 0.5 - x0 * x0 - y0 * y0;
|
134
|
-
if (t0 < 0) {
|
135
|
-
n0 = 0.0;
|
136
|
-
} else {
|
137
|
-
t0 *= t0;
|
138
|
-
n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient
|
139
|
-
}
|
140
|
-
double t1 = 0.5 - x1 * x1 - y1 * y1;
|
141
|
-
if (t1 < 0) {
|
142
|
-
n1 = 0.0;
|
143
|
-
} else {
|
144
|
-
t1 *= t1;
|
145
|
-
n1 = t1 * t1 * dot(grad3[gi1], x1, y1);
|
146
|
-
}
|
147
|
-
double t2 = 0.5 - x2 * x2 - y2 * y2;
|
148
|
-
if (t2 < 0) {
|
149
|
-
n2 = 0.0;
|
150
|
-
} else {
|
151
|
-
t2 *= t2;
|
152
|
-
n2 = t2 * t2 * dot(grad3[gi2], x2, y2);
|
153
|
-
}
|
154
|
-
// Add contributions from each corner to get the final noise value.
|
155
|
-
// The result is scaled to return values in the interval [-1,1].
|
156
|
-
return 70.0 * (n0 + n1 + n2);
|
157
|
-
}
|
158
|
-
|
159
|
-
// 3D simplex noise
|
160
|
-
|
161
|
-
/**
|
162
|
-
*
|
163
|
-
* @param xin
|
164
|
-
* @param yin
|
165
|
-
* @param zin
|
166
|
-
* @return
|
167
|
-
*/
|
168
|
-
public static double noise(double xin, double yin, double zin) {
|
169
|
-
double n0, n1, n2, n3; // Noise contributions from the four corners
|
170
|
-
// Skew the input space to determine which simplex cell we're in
|
171
|
-
double s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D
|
172
|
-
int i = fastfloor(xin + s);
|
173
|
-
int j = fastfloor(yin + s);
|
174
|
-
int k = fastfloor(zin + s);
|
175
|
-
double t = (i + j + k) * G3;
|
176
|
-
double X0 = i - t; // Unskew the cell origin back to (x,y,z) space
|
177
|
-
double Y0 = j - t;
|
178
|
-
double Z0 = k - t;
|
179
|
-
double x0 = xin - X0; // The x,y,z distances from the cell origin
|
180
|
-
double y0 = yin - Y0;
|
181
|
-
double z0 = zin - Z0;
|
182
|
-
// For the 3D case, the simplex shape is a slightly irregular tetrahedron.
|
183
|
-
// Determine which simplex we are in.
|
184
|
-
int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords
|
185
|
-
int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords
|
186
|
-
if (x0 >= y0) {
|
187
|
-
if (y0 >= z0) {
|
188
|
-
i1 = 1;
|
189
|
-
j1 = 0;
|
190
|
-
k1 = 0;
|
191
|
-
i2 = 1;
|
192
|
-
j2 = 1;
|
193
|
-
k2 = 0;
|
194
|
-
} // X Y Z order
|
195
|
-
else if (x0 >= z0) {
|
196
|
-
i1 = 1;
|
197
|
-
j1 = 0;
|
198
|
-
k1 = 0;
|
199
|
-
i2 = 1;
|
200
|
-
j2 = 0;
|
201
|
-
k2 = 1;
|
202
|
-
} // X Z Y order
|
203
|
-
else {
|
204
|
-
i1 = 0;
|
205
|
-
j1 = 0;
|
206
|
-
k1 = 1;
|
207
|
-
i2 = 1;
|
208
|
-
j2 = 0;
|
209
|
-
k2 = 1;
|
210
|
-
} // Z X Y order
|
211
|
-
} else { // x0<y0
|
212
|
-
if (y0 < z0) {
|
213
|
-
i1 = 0;
|
214
|
-
j1 = 0;
|
215
|
-
k1 = 1;
|
216
|
-
i2 = 0;
|
217
|
-
j2 = 1;
|
218
|
-
k2 = 1;
|
219
|
-
} // Z Y X order
|
220
|
-
else if (x0 < z0) {
|
221
|
-
i1 = 0;
|
222
|
-
j1 = 1;
|
223
|
-
k1 = 0;
|
224
|
-
i2 = 0;
|
225
|
-
j2 = 1;
|
226
|
-
k2 = 1;
|
227
|
-
} // Y Z X order
|
228
|
-
else {
|
229
|
-
i1 = 0;
|
230
|
-
j1 = 1;
|
231
|
-
k1 = 0;
|
232
|
-
i2 = 1;
|
233
|
-
j2 = 1;
|
234
|
-
k2 = 0;
|
235
|
-
} // Y X Z order
|
236
|
-
}
|
237
|
-
// A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
|
238
|
-
// a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and
|
239
|
-
// a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where
|
240
|
-
// c = 1/6.
|
241
|
-
double x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
|
242
|
-
double y1 = y0 - j1 + G3;
|
243
|
-
double z1 = z0 - k1 + G3;
|
244
|
-
double x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
|
245
|
-
double y2 = y0 - j2 + 2.0 * G3;
|
246
|
-
double z2 = z0 - k2 + 2.0 * G3;
|
247
|
-
double x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
|
248
|
-
double y3 = y0 - 1.0 + 3.0 * G3;
|
249
|
-
double z3 = z0 - 1.0 + 3.0 * G3;
|
250
|
-
// Work out the hashed gradient indices of the four simplex corners
|
251
|
-
int ii = i & 255;
|
252
|
-
int jj = j & 255;
|
253
|
-
int kk = k & 255;
|
254
|
-
int gi0 = PERM_MOD_12[ii + PERM[jj + PERM[kk]]];
|
255
|
-
int gi1 = PERM_MOD_12[ii + i1 + PERM[jj + j1 + PERM[kk + k1]]];
|
256
|
-
int gi2 = PERM_MOD_12[ii + i2 + PERM[jj + j2 + PERM[kk + k2]]];
|
257
|
-
int gi3 = PERM_MOD_12[ii + 1 + PERM[jj + 1 + PERM[kk + 1]]];
|
258
|
-
// Calculate the contribution from the four corners
|
259
|
-
double t0 = 0.5 - x0 * x0 - y0 * y0 - z0 * z0;
|
260
|
-
if (t0 < 0) {
|
261
|
-
n0 = 0.0;
|
262
|
-
} else {
|
263
|
-
t0 *= t0;
|
264
|
-
n0 = t0 * t0 * dot(grad3[gi0], x0, y0, z0);
|
265
|
-
}
|
266
|
-
double t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1;
|
267
|
-
if (t1 < 0) {
|
268
|
-
n1 = 0.0;
|
269
|
-
} else {
|
270
|
-
t1 *= t1;
|
271
|
-
n1 = t1 * t1 * dot(grad3[gi1], x1, y1, z1);
|
272
|
-
}
|
273
|
-
double t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2;
|
274
|
-
if (t2 < 0) {
|
275
|
-
n2 = 0.0;
|
276
|
-
} else {
|
277
|
-
t2 *= t2;
|
278
|
-
n2 = t2 * t2 * dot(grad3[gi2], x2, y2, z2);
|
279
|
-
}
|
280
|
-
double t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3;
|
281
|
-
if (t3 < 0) {
|
282
|
-
n3 = 0.0;
|
283
|
-
} else {
|
284
|
-
t3 *= t3;
|
285
|
-
n3 = t3 * t3 * dot(grad3[gi3], x3, y3, z3);
|
286
|
-
}
|
287
|
-
// Add contributions from each corner to get the final noise value.
|
288
|
-
// The result is scaled to stay just inside [-1,1]
|
289
|
-
return 32.0 * (n0 + n1 + n2 + n3);
|
290
|
-
}
|
291
|
-
|
292
|
-
// 4D simplex noise, better simplex rank ordering method 2012-03-09
|
293
|
-
|
294
|
-
/**
|
295
|
-
*
|
296
|
-
* @param x
|
297
|
-
* @param y
|
298
|
-
* @param z
|
299
|
-
* @param w
|
300
|
-
* @return noise double
|
301
|
-
*/
|
302
|
-
public static double noise(double x, double y, double z, double w) {
|
303
|
-
|
304
|
-
double n0, n1, n2, n3, n4; // Noise contributions from the five corners
|
305
|
-
// Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
|
306
|
-
double s = (x + y + z + w) * F4; // Factor for 4D skewing
|
307
|
-
int i = fastfloor(x + s);
|
308
|
-
int j = fastfloor(y + s);
|
309
|
-
int k = fastfloor(z + s);
|
310
|
-
int l = fastfloor(w + s);
|
311
|
-
double t = (i + j + k + l) * G4; // Factor for 4D unskewing
|
312
|
-
double X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
|
313
|
-
double Y0 = j - t;
|
314
|
-
double Z0 = k - t;
|
315
|
-
double W0 = l - t;
|
316
|
-
double x0 = x - X0; // The x,y,z,w distances from the cell origin
|
317
|
-
double y0 = y - Y0;
|
318
|
-
double z0 = z - Z0;
|
319
|
-
double w0 = w - W0;
|
320
|
-
// For the 4D case, the simplex is a 4D shape I won't even try to describe.
|
321
|
-
// To find out which of the 24 possible simplices we're in, we need to
|
322
|
-
// determine the magnitude ordering of x0, y0, z0 and w0.
|
323
|
-
// Six pair-wise comparisons are performed between each possible pair
|
324
|
-
// of the four coordinates, and the results are used to rank the numbers.
|
325
|
-
int rankx = 0;
|
326
|
-
int ranky = 0;
|
327
|
-
int rankz = 0;
|
328
|
-
int rankw = 0;
|
329
|
-
if (x0 > y0) {
|
330
|
-
rankx++;
|
331
|
-
} else {
|
332
|
-
ranky++;
|
333
|
-
}
|
334
|
-
if (x0 > z0) {
|
335
|
-
rankx++;
|
336
|
-
} else {
|
337
|
-
rankz++;
|
338
|
-
}
|
339
|
-
if (x0 > w0) {
|
340
|
-
rankx++;
|
341
|
-
} else {
|
342
|
-
rankw++;
|
343
|
-
}
|
344
|
-
if (y0 > z0) {
|
345
|
-
ranky++;
|
346
|
-
} else {
|
347
|
-
rankz++;
|
348
|
-
}
|
349
|
-
if (y0 > w0) {
|
350
|
-
ranky++;
|
351
|
-
} else {
|
352
|
-
rankw++;
|
353
|
-
}
|
354
|
-
if (z0 > w0) {
|
355
|
-
rankz++;
|
356
|
-
} else {
|
357
|
-
rankw++;
|
358
|
-
}
|
359
|
-
int i1, j1, k1, l1; // The integer offsets for the second simplex corner
|
360
|
-
int i2, j2, k2, l2; // The integer offsets for the third simplex corner
|
361
|
-
int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner
|
362
|
-
// [rankx, ranky, rankz, rankw] is a 4-vector with the numbers 0, 1, 2 and 3
|
363
|
-
// in some order. We use a thresholding to set the coordinates in turn.
|
364
|
-
// Rank 3 denotes the largest coordinate.
|
365
|
-
i1 = rankx >= 3 ? 1 : 0;
|
366
|
-
j1 = ranky >= 3 ? 1 : 0;
|
367
|
-
k1 = rankz >= 3 ? 1 : 0;
|
368
|
-
l1 = rankw >= 3 ? 1 : 0;
|
369
|
-
// Rank 2 denotes the second largest coordinate.
|
370
|
-
i2 = rankx >= 2 ? 1 : 0;
|
371
|
-
j2 = ranky >= 2 ? 1 : 0;
|
372
|
-
k2 = rankz >= 2 ? 1 : 0;
|
373
|
-
l2 = rankw >= 2 ? 1 : 0;
|
374
|
-
// Rank 1 denotes the second smallest coordinate.
|
375
|
-
i3 = rankx >= 1 ? 1 : 0;
|
376
|
-
j3 = ranky >= 1 ? 1 : 0;
|
377
|
-
k3 = rankz >= 1 ? 1 : 0;
|
378
|
-
l3 = rankw >= 1 ? 1 : 0;
|
379
|
-
// The fifth corner has all coordinate offsets = 1, so no need to compute that.
|
380
|
-
double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
|
381
|
-
double y1 = y0 - j1 + G4;
|
382
|
-
double z1 = z0 - k1 + G4;
|
383
|
-
double w1 = w0 - l1 + G4;
|
384
|
-
double x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
|
385
|
-
double y2 = y0 - j2 + 2.0 * G4;
|
386
|
-
double z2 = z0 - k2 + 2.0 * G4;
|
387
|
-
double w2 = w0 - l2 + 2.0 * G4;
|
388
|
-
double x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
|
389
|
-
double y3 = y0 - j3 + 3.0 * G4;
|
390
|
-
double z3 = z0 - k3 + 3.0 * G4;
|
391
|
-
double w3 = w0 - l3 + 3.0 * G4;
|
392
|
-
double x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
|
393
|
-
double y4 = y0 - 1.0 + 4.0 * G4;
|
394
|
-
double z4 = z0 - 1.0 + 4.0 * G4;
|
395
|
-
double w4 = w0 - 1.0 + 4.0 * G4;
|
396
|
-
// Work out the hashed gradient indices of the five simplex corners
|
397
|
-
int ii = i & 255;
|
398
|
-
int jj = j & 255;
|
399
|
-
int kk = k & 255;
|
400
|
-
int ll = l & 255;
|
401
|
-
int gi0 = PERM[ii + PERM[jj + PERM[kk + PERM[ll]]]] % 32;
|
402
|
-
int gi1 = PERM[ii + i1 + PERM[jj + j1 + PERM[kk + k1 + PERM[ll + l1]]]] % 32;
|
403
|
-
int gi2 = PERM[ii + i2 + PERM[jj + j2 + PERM[kk + k2 + PERM[ll + l2]]]] % 32;
|
404
|
-
int gi3 = PERM[ii + i3 + PERM[jj + j3 + PERM[kk + k3 + PERM[ll + l3]]]] % 32;
|
405
|
-
int gi4 = PERM[ii + 1 + PERM[jj + 1 + PERM[kk + 1 + PERM[ll + 1]]]] % 32;
|
406
|
-
// Calculate the contribution from the five corners
|
407
|
-
double t0 = 0.5 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
|
408
|
-
if (t0 < 0) {
|
409
|
-
n0 = 0.0;
|
410
|
-
} else {
|
411
|
-
t0 *= t0;
|
412
|
-
n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0);
|
413
|
-
}
|
414
|
-
double t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
|
415
|
-
if (t1 < 0) {
|
416
|
-
n1 = 0.0;
|
417
|
-
} else {
|
418
|
-
t1 *= t1;
|
419
|
-
n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1);
|
420
|
-
}
|
421
|
-
double t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
|
422
|
-
if (t2 < 0) {
|
423
|
-
n2 = 0.0;
|
424
|
-
} else {
|
425
|
-
t2 *= t2;
|
426
|
-
n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2);
|
427
|
-
}
|
428
|
-
double t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
|
429
|
-
if (t3 < 0) {
|
430
|
-
n3 = 0.0;
|
431
|
-
} else {
|
432
|
-
t3 *= t3;
|
433
|
-
n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3);
|
434
|
-
}
|
435
|
-
double t4 = 0.5 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
|
436
|
-
if (t4 < 0) {
|
437
|
-
n4 = 0.0;
|
438
|
-
} else {
|
439
|
-
t4 *= t4;
|
440
|
-
n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4);
|
441
|
-
}
|
442
|
-
// Sum up and scale the result to cover the range [-1,1]
|
443
|
-
return 27.0 * (n0 + n1 + n2 + n3 + n4);
|
444
|
-
}
|
445
|
-
|
446
|
-
// Inner class to speed upp gradient computations
|
447
|
-
// (In Java, array access is a lot slower than member access)
|
448
|
-
private static class Grad {
|
449
|
-
|
450
|
-
double x, y, z, w;
|
451
|
-
|
452
|
-
Grad(double x, double y, double z) {
|
453
|
-
this.x = x;
|
454
|
-
this.y = y;
|
455
|
-
this.z = z;
|
456
|
-
}
|
457
|
-
|
458
|
-
Grad(double x, double y, double z, double w) {
|
459
|
-
this.x = x;
|
460
|
-
this.y = y;
|
461
|
-
this.z = z;
|
462
|
-
this.w = w;
|
463
|
-
}
|
464
|
-
}
|
465
|
-
}
|