# Terrain art with math

**URL:** <https://discourse.processing.org/t/terrain-art-with-math/28916>\
**Category:** Gallery\
**Created:** [March 28, 2021, 1:45am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916 "2021-03-28T01:45:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 28, 2021, 1:45am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/1 "2021-03-28T01:45:47Z")

</div>

I used to think that the terrain is only formed by the noise, but with mathematics is more beautiful

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 28, 2021, 1:56am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/2 "2021-03-28T01:56:12Z")

</div>

@[Chrisir](https://discourse.processing.org/u/Chrisir)  
@ [glv](https://discourse.processing.org/u/glv)  
@ [paulgoux](https://discourse.processing.org/u/paulgoux)  
@ [josephh](https://discourse.processing.org/u/josephh)  
@[jb4x](https://discourse.processing.org/u/jb4x)

hi for all and thanks for help this is my unfinished work but it is great progress for now and many thanks for all

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 28, 2021, 2:00am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/3 "2021-03-28T02:00:05Z")

</div>

![Untitled 108](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4a59184a24c5ad5bd036b851849d308ad006a8eb.jpeg)

 ![Untitled 110](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7c38a989f2024817b9c38d8bedeb117b2a31c01d.jpeg)

 ![Untitled 111](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/693b69125926f63061f5a6bbe04cd0b499c13e6c.jpeg)

 ![Untitled 111](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/693b69125926f63061f5a6bbe04cd0b499c13e6c.jpeg) ![Untitled 112](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3bcd70c1071557ddc42f768cb3c1c852bb8f7d38.jpeg) ![Untitled 113](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/22cd074b5be2d8151219ea5647ff1674288b27ba.jpeg) ![Untitled 114](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fb7311d4aeb6835a212507ad977a662abd249baa.jpeg) ![Untitled 115](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3cc74c53924c55ac148fafb2c9ba43b2382d5ec1.jpeg) ![Untitled 116](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5fd6c633e768c1a4992f6cb2b2ce8897b6c6e7d9.jpeg) ![Untitled 117](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e20cd4e3ced0d2e45a15140606ce0ea9dcc7794f.jpeg) ![Untitled 118](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3e44e200c7ce1d08f47e00112c0497b303e59a53.jpeg) ![Untitled 119](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/430b3a4ae08e627ad8156ee6636283e5ad109c9a.jpeg) ![Untitled 120](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/273ce0f2a6d8a5cd0437794d730145846da1d7cb.jpeg) ![Untitled 121](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/34829ff4008334400f7800929e1da2da50fc7c32.jpeg) ![Untitled 122](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d59f8775ff0166c3fe618a235de82a3dc483b882.jpeg) ![Untitled 123](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/477dab63ab2fdb7694583de0f7e6fd0bad4f6d56.jpeg) ![Untitled 124](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/92e0323373119e08d364c7e7930baf9134124ab5.jpeg) ![Untitled 125](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/aa5fce35254f23d3e8401a63dd6834f579b4a98e.jpeg)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 28, 2021, 9:43am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/4 "2021-03-28T09:43:06Z")

</div>

Well done!

I like it!

It is similar to what I tried.

See [Math Projects · Kango/MathProjects Wiki · GitHub](https://github.com/Kango/MathProjects/wiki/Math-Projects)

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 28, 2021, 11:11am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/5 "2021-03-28T11:11:52Z")

</div>

[![](https://img.youtube.com/vi/mD6b_hP17WI/maxresdefault.jpg "BIG PROJECT! Top Down City Based Car Crime Game #1") ](https://www.youtube.com/watch?v=mD6b_hP17WI)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 28, 2021, 12:48pm UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/6 "2021-03-28T12:48:35Z")

</div>

nice work

but you have full control than me

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 28, 2021, 3:41pm UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/7 "2021-03-28T15:41:59Z")

</div>

Some of my 3d printer final prints

 ![IMG_20210328_183605](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b3683985e1a63ee6f03dbf22df866faf8d984751.jpeg)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 29, 2021, 3:00pm UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/8 "2021-03-29T15:00:25Z")

</div>

@[Chrisir](https://discourse.processing.org/u/Chrisir)

 ![Untitled](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7840c990e3c2ea54d15c1dc18801539cfa334086.jpeg)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 30, 2021, 8:23pm UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/9 "2021-03-30T20:23:29Z")

</div>

more math

 ![Untitled 137](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d780d55446e196116fa1452c04f85d63492934a0.jpeg)

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 31, 2021, 4:26am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/10 "2021-03-31T04:26:51Z")

</div>

check out my sketch its a 2d perlin grid with sliders. Its kind of an old project and hasnt yet been converted to 3d. I have added the grid to my windows gui Lib, I still need to work on file acquisitions in android. The library will come with a boid/entity class, so you could add animals and plants etc.

> **[paulgoux/test-project](https://github.com/paulgoux/test-project)**
>
> Contribute to paulgoux/test-project development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 31, 2021, 4:43am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/11 "2021-03-31T04:43:51Z")

</div>

how to use it ??? on android ?and how to add jar file ?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 31, 2021, 4:51am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/12 "2021-03-31T04:51:47Z")

</div>

You should be able to run the sketch file by clicking on it everything is ready to go. Ill update the library file later to add more interactivity. For now the grid constructer requires an instance of bms. And the constructor is as follows.

```auto
new Grid(xpos, ypos, width, height, resolution, bms) 

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 31, 2021, 4:56am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/13 "2021-03-31T04:56:36Z")

</div>

nice 😄

 ![Untitled 138](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/93dd58eb08a99b9fea6d34df2153b02e2fbb4f61.jpeg)

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 31, 2021, 5:11am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/14 "2021-03-31T05:11:41Z")

</div>

Play around with the sliders. Some of them dont do anything, but all th required sliders are there the others are for the 3d version which is not finished yet.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 31, 2021, 5:16am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/15 "2021-03-31T05:16:42Z")

</div>

> [@paulgoux](#):
>
> Play around with the sliders

ok … when you end inform me

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 31, 2021, 5:18am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/16 "2021-03-31T05:18:55Z")

</div>

I mean the grid ones…

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 31, 2021, 5:21am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/17 "2021-03-31T05:21:32Z")

</div>

i do understand you …

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [April 1, 2021, 1:45am UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/18 "2021-04-01T01:45:07Z")

</div>

![Screenshot_2021-04-01-04-41-54-777](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c0027cf96ef0d79ea89185004398fc00ae4345b2.jpeg)

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [April 3, 2021, 6:38pm UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/19 "2021-04-03T18:38:32Z")

</div>

this is the full grid portion of the code. This is the code almost following the example in Sebastian Lagues’ vid. I have added the double for loop and probably wont as I currently have other projects to get on with. But my repo is updated with the latest library files.

```auto
public void display(){
    
      mouseLogic();
    //logic();
      keys();
      output.append = true;
      
      //applet.println("amp1 "+ amp1);
      applet.noiseSeed((int)(seed));
      if(pallete.click(8))save();
      agentsCounted = 0;
      if (border){
        applet.stroke(0);
        applet.fill(255);
        applet.rect(x,y,w,h);
      }
      if(sliderMenu!=null&&sliderMenu.visible&&sliderMenu.menu.smdown||sUpdate){
        update = true;
        mdown = true;
        
        
      }
      else update = false;
      if(mdown&&!applet.mousePressed&&contour)contourUpdate = true;
      if(!applet.mousePressed)mdown = false;
      if(scale<=0)scale = 0.0001f;
      //if(contour)applet.beginShape();
      
        
      if(canvas==null)canvas = applet.createGraphics(res*rows,res*cols,applet.JAVA2D);
      //if(update||keyUpdate||sysUpdate||begin)
      canvas.beginDraw();
      //canvas2.beginDraw();
      for(int i=0;i<rows;i++){
        for(int j=0;j<cols;j++){
          
          applet.noStroke();
          int p = j + i * cols;
          Grid_space a = squares.get(p);

          if(update||keyUpdate||sysUpdate||begin){
            amplitude = amp1;
            frequency = freq1;
            float height = 0;
            mapNoise[j][i] = 0;
            
            for(int k=0;k<octaves;k++){
              
              float y1 = fy + scale1*i*frequency + octaveOffsets.get(k).x;
              float x1 = fx + scale1*j*frequency + octaveOffsets.get(k).y;
              float n1 = applet.noise(x1,y1);

              height += (n1*amplitude);
              //float height = n1*amp1;
              amplitude *= persistance;
              frequency *= lacunarity;
            }
            mapNoise[j][i] = height;
              // if(height>sealevel)map[j][i] = applet.color(0, 0, 153);
              // else if(height>groundlevel)map[j][i] = applet.color(204, 204, 0);
              // else if(height>grasslevel)map[j][i] = applet.color(51, 153, 51);
              // else if(height>mountainlevel)map[j][i] = applet.color(102, 102, 153); 

              // with alpha
              // if (height>mountainlevel)map[j][i] = applet.color(102, 102, 153,mountainlevel*255); 
              // else if (height>grasslevel)map[j][i] = applet.color(51, 153, 51,grasslevel*255);
              // else if (height>groundlevel)map[j][i] = applet.color(204, 204, 0,groundlevel*255);
              // else if (height<sealevel)map[j][i] = applet.color(0, 0, 153,sealevel*255);
              if (height>mountainlevel)map[j][i] = applet.color(102, 102, 153); 
              else if (height>grasslevel)map[j][i] = applet.color(51, 153, 51);
              else if (height>groundlevel)map[j][i] = applet.color(204, 204, 0);
              else if (height<sealevel)map[j][i] = applet.color(0, 0, 153);

              a.col = applet.color(map[j][i]);
              debug(a);
              
              //a.get_neighbours(this);
              //a.getNeighbours4(this);
              
            if(applet.brightness(a.col) > max)max = applet.brightness(a.col);
            canvas.fill(a.col);
            canvas.noStroke();
            canvas.rect(a.x,a.y,a.w,a.h);
            a.compared = false;
            begin = false;
          }
          
          if(a.popVisited)applet.fill(a.popCol);
          int count_ = 0;
          if(agentsPopulated)updateAgents(count_,a);
          //if(contour)a.drawBoundaries();
          if (!mapScoped&&count_==0)agentsCounted ++;
      }}
// g1.img = canvas.get((int)x,(int)y,(int)w,(int)h);
  g1.img = canvas.get();
  canvas.endDraw();
  float w1 = -(applet.width - w)/2;
  float h1 = -(applet.height - h)/2;
  applet.image(g1.img,x+w1,y+h1);
  
  applet.strokeWeight(1);
  if(!contour){
    // remember to change sobel back;
    g1.sobel = null;
  }else {
    if(g1.sobel==null||contourUpdate){
      g1.sobel(9,20);
      applet.println(scale1,frequency,amplitude,octaves);

      contourUpdate = false;
    }
    applet.image(g1.sobel,0,0);
  }
  sysUpdate = false;
  update = false;
  sUpdate = false;
  contourUpdate = false;
      //if (contour)applet.endShape(OPEN);
// if(applet.frameCount%10==0)applet.println("grid display",mountainlevel);
  //applet.println(squaresCounted,squares.size());
  if (toggle&&pallete.visible)pallete.draw();
  if (toggle&&sliderSettings!=null&&sliderSettings.toggle) {
	  sliderSettings.displayTab();
	  sliderSettings.setvScroll(0,200);
  }
  if (squaresCounted==squares.size()) sdown = false;
  if (agentsCounted==squares.size()-rows&&agentsPopulated)mapScoped = true;
  if (bcount>=squares.size())Boundaries = true;

  applet.fill(0);
  applet.text(applet.frameRate,100,100);
      
  };

```

currently produces this

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d67cfb5e438a75269f68510dda3982c9d0139e7e.png)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [April 4, 2021, 2:50pm UTC](https://discourse.processing.org/t/terrain-art-with-math/28916/20 "2021-04-04T14:50:45Z")

</div>

@[paulgoux](https://discourse.processing.org/u/paulgoux)

nice work

[Next page](https://discourse.processing.org/t/terrain-art-with-math/28916.md?page=2)
