# Another Lambda Example In Processing 4

**URL:** <https://discourse.processing.org/t/another-lambda-example-in-processing-4/22458>\
**Category:** Gallery\
**Created:** [July 7, 2020, 7:35pm UTC](https://discourse.processing.org/t/another-lambda-example-in-processing-4/22458 "2020-07-07T19:35:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [July 7, 2020, 7:35pm UTC](https://discourse.processing.org/t/another-lambda-example-in-processing-4/22458/1 "2020-07-07T19:35:59Z")

</div>

```java
int version = 0; //if we grab multiple frames, they will be numbered
float timeSeed = 0.1; //seed for the third dimension of the noise
float NOISE_STRENGTH = 80.0; //strength of the noise effect

import processing.pdf.*;

boolean saveOneFrame = false;
NoiseGenerator generator;

void setup() {
  size(1000, 1000); //resolution does not really matter since we are working with vectors
  frameRate(24);
  generator = (x, y, seed) -> NOISE_STRENGTH * noise(
  x / 150.0,
  y / 150.0 + seed * 2,
  seed
  ) - 100;
}

void draw() {
  if (saveOneFrame == true) { //turn on recording for this frame if we clicked the mouse
    beginRecord(PDF, "Line_"+version+".pdf");
  }

  background(255);
  noFill();
  stroke(0);
  strokeWeight(1);
  timeSeed = millis()/5000.0; 
  for (int cy = 0; cy < height+100; cy+=50) { //iterate down the page
    for (int cx = 0; cx < width+100; cx+=50) { //iterate across the page
      beginShape();
      float div = 2.0*PI/10.0; //divide 2PI into 1/10ths
      for (float a = 0; a<=2.0*PI; a+=div) { //work around the circle
        float x = (cos(a)*60) + cx; //convert polar to cartesian
        float y = (sin(a)*60) + cy;
        x += generator.noise(x, y, millis()/5000); //add noise to each point
        y += generator.noise(x, y, millis()/5000);
        vertex(x, y); //add the point to the shape
      }
      endShape(CLOSE);
    }
  }
  if (saveOneFrame == true) {
    endRecord();
    version++;
    saveOneFrame = false;
  }
}

void mousePressed() {
  saveOneFrame = true;
}

```

Interface

```java
interface NoiseGenerator{
  float noise(float x, float y, float timeSeed);
}

```

 ![lambda](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c7edb454509b8e49edd2a5cc5eefac7587902fed.png)
