# My attempt at (pseudo) Perlin Noise

**URL:** <https://discourse.processing.org/t/my-attempt-at-pseudo-perlin-noise/28287>\
**Category:** Gallery\
**Created:** [March 5, 2021, 6:30pm UTC](https://discourse.processing.org/t/my-attempt-at-pseudo-perlin-noise/28287 "2021-03-05T18:30:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [March 5, 2021, 6:30pm UTC](https://discourse.processing.org/t/my-attempt-at-pseudo-perlin-noise/28287/1 "2021-03-05T18:30:27Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a37ba5c4def554a892021eeffbbb4815262626c3.png)  
This is not layered, the original creates a random wave with maxHeight 128, second gets added on top of it with maxHeight 64, third with 32,… essentially `initialMaxHeight*pow(0.5,n)`

however this one works by creating a random wave, but instead of stacking, it splits a segment in two, with a point between the p1 and p2 (points that define the sides).

Would this still count as Perlin Noise? Or would this count just as a “pseudo perlin wave”?

> **Code**
>
> ```auto
> ArrayList<segment> segments = new ArrayList<segment>();
> int n = 10;
> void setup() {
> size(1600,600);
> addSegments(n);
> }
> void draw() {
> background(0); stroke(255);
> for(int i = 0;i < segments.size(); i++) segments.get(i).display();
> }
> void mousePressed() {
> for(int i = 0, m = segments.size(); i < m; i++) {
> segments.get(i).splitSegment();
> }
> }
> void keyPressed() {
> if(key == ' ') {
> segments.clear();
> addSegments(n);
> }
> }
> void addSegments(int num) {
> float v = random(1);
> float v2 = random(1);
> float wi = width/num;
> segments.add(new segment(v,v2,0,wi));
> for(int i = 0; i < num; i++) {
> v = v2;
> v2 = random(1);
> segments.add(new segment(v,v2,(i+1)*wi,(i+2)*wi));
> }
> }
> class segment {
> float p1, p2;
> float x1,x2;
> segment(float p1_, float p2_, float x1_, float x2_) {
> p1 = p1_;
> p2 = p2_;
> x1 = x1_;
> x2 = x2_;
> }
> void display() {
> line(x1,(1-p1)*height,x2,(1-p2)*height);
> }
> void splitSegment() {
> float newP = map(random(1),0,1,p1,p2),newX = (x1+x2)/2;
> segments.add(new segment(newP,p2,newX,x2));
> p2 = newP;
> x2 = newX;
> }
> }
> 
> ```
