Skip to content

Commit b0121fd

Browse files
committed
docs for noise_mode
1 parent aeaf788 commit b0121fd

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

docs/_methods/noise_mode.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
layout: post
3+
title: "noise_mode"
4+
---
5+
6+
### Name ###
7+
8+
`noise_mode` _NB: not currently available in vanilla processing_.
9+
10+
### Examples ###
11+
12+
```ruby
13+
#!/usr/bin/env jruby -w
14+
require 'picrate'
15+
16+
class TestNoise < Processing::App
17+
attr_reader :z
18+
19+
def setup
20+
stroke(255, 64)
21+
@z = 0
22+
end
23+
24+
def draw
25+
noise_scale = 0.01
26+
background(0)
27+
grid(width, height, 10, 10) do |x, y|
28+
arrow(x, y, noise(x * noise_scale, y * noise_scale, z * noise_scale) * TWO_PI * 2)
29+
end
30+
@z += 1
31+
end
32+
33+
def mouse_pressed
34+
mode = Processing::SIMPLEX
35+
noise_mode mode
36+
sketch_title "#{mode}"
37+
end
38+
39+
def mouse_released
40+
mode = Processing::VALUE # default mode "Perlin Noise" in vanilla processing
41+
noise_mode(mode)
42+
sketch_title "#{mode}"
43+
end
44+
45+
46+
def arrow(x, y, ang)
47+
pushMatrix()
48+
translate(x, y)
49+
rotate(ang)
50+
line(0, 0, 20, 0)
51+
translate(20, 0)
52+
rotate(PI + 0.4)
53+
line(0, 0, 5, 0)
54+
rotate(-0.8)
55+
line(0, 0, 5, 0)
56+
popMatrix()
57+
end
58+
59+
def settings
60+
size(600, 400, P2D)
61+
end
62+
end
63+
64+
TestNoise.new
65+
66+
```
67+
68+
### Description ###
69+
70+
Currently supports two implementations of noise ValueNoise (Perlin noise in vanilla processing), up to 3D and SimplexNoise up to 4D.
71+
72+
### Syntax ###
73+
74+
```ruby
75+
noise_mode(mode) # default mode is Processing::VALUE, and Processing::SIMPLEX
76+
```
77+
78+
### Related ###
79+
80+
`noise(x, y, z, w)` SimplexNoise only
81+
82+
`noise(x, y, z)` ValueNoise and SimplexNoise

0 commit comments

Comments
 (0)