# Help with Extrusion from 2D to 3D

**URL:** <https://discourse.processing.org/t/help-with-extrusion-from-2d-to-3d/9656>\
**Category:** Coding Questions\
**Created:** [March 26, 2019, 5:59pm UTC](https://discourse.processing.org/t/help-with-extrusion-from-2d-to-3d/9656 "2019-03-26T17:59:06Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [March 26, 2019, 10:33pm UTC](https://discourse.processing.org/t/help-with-extrusion-from-2d-to-3d/9656/4 "2019-03-26T22:33:38Z")

</div>

Right, well, the parameters to the box() function are the size of each box. Set x and y to 1, and vary the z size based on the brightness. You also want to adjust the position because boxes are drawn from their centers:

```auto
PImage img;
boolean mono = false;

void setup() {
  size(600, 400, P3D);
  img = loadImage("http://www.tfguy44.com/MyIcon1.PNG");
  img.loadPixels();
  noStroke();
}

void draw() {
  background(mono?127:0);
  lights();
  translate(width/2, height/2);
  rotateX(-map(mouseY,0,height,-PI,PI));
  rotateY(map(mouseX,0,width,-PI,PI));
  scale(5);
  translate(-img.width/2, -img.height/2);
  fill(255);
  for (int x=0; x<img.width; x++) {
    for (int y=0; y<img.height; y++) {
      float bri = map(brightness(img.get(x, y)),0,255,0,10);
      pushMatrix();
      translate(x,y,bri/2);
      if( !mono ) fill(img.get(x, y));
      box(1,1,bri);
      popMatrix();
    }
  }
}

void mousePressed(){
  mono=!mono;
}

```

This isn’t a fish for you. This is a picture of me wearing my fisherman hat and holding my fishing rod and eating some fish. Study the elements that this snapshot presents and understand what they are for and how you can use them.

---

_[View the full topic](https://discourse.processing.org/t/help-with-extrusion-from-2d-to-3d/9656)._
