# 3 sketch in one

**URL:** <https://discourse.processing.org/t/3-sketch-in-one/29036>\
**Category:** Gallery\
**Created:** [April 1, 2021, 2:19am UTC](https://discourse.processing.org/t/3-sketch-in-one/29036 "2021-04-01T02:19:01Z")\
**Posts on this page:** 5\
**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:** [April 1, 2021, 2:19am UTC](https://discourse.processing.org/t/3-sketch-in-one/29036/1 "2021-04-01T02:19:01Z")

</div>

I have collected 3 sketch in one

1 \* [6.2: Two Loops / Grid Exercise - Processing Tutorial - YouTube](https://www.youtube.com/watch?v=esKLU3dJo70)

- [Grid | Learning Processing 2nd Edition](http://learningprocessing.com/examples/chp16/example-16-06-Grid)

```auto
type or paste code here

```

2 [How to "project" or "map" 2D shapes or images on 3D terrain - Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/23133/#Comment_100772)

3 [Chrisir](https://forum.processing.org/two/profile/25/Chrisir)

[December 2015](https://forum.processing.org/two/discussion/comment/57454/#Comment_57454) edited December 2015 Answer ✓

```auto
PImage img;
int cols, rows;
int scl = 26;
int w = 2800;
int h = 2600;

float ax, ay;

int videoScale =14;

int cols1, rows1;

//int sphereMy ;
void setup() {
  size(1200, 1000, OPENGL);
// rectMode(CENTER);
String http = "http://";
  img = loadImage( http + "www.tfguy44.com/MyIcon1.PNG");

//img = loadImage( "MyIcon1.png");
 cols = w / scl;
  rows = h/ scl;
//cols1 = width/videoScale;
// rows1 = height/videoScale;
 rows1 = 222/videoScale;
 cols1 = 222/videoScale;
  texture(img);

}
 
void draw() {
  background(0);
 
  lights();
 
 translate(width/2, height/2, 0);
 
  scale(1.5);
  rotateY(map(mouseX, 0, width, -PI, PI));
  rotateX(-map(mouseY, 0, height, -PI, PI));
 
  //point(455, 434, 122);
  for (int u=0; u<1; u+=1) {
    sphereMy(20-u, 10-u, 111-u);
  }

 // stroke(255, 0, 0);
 // fill(255, 0, 0, 128);
// noStroke(); 
 noFill(); 
 stroke(255, 255, 255);
// fill(0, 0, 255, 128);
  plane();
 
 // stroke(0, 255, 0);
 // fill(0, 255, 0, 128);
  rotateX(HALF_PI);
 //noStroke(); 
// noFill(); 
stroke(255, 255, 255);
 //fill(0, 0, 255, 128);
  plane();
// NoStrok();
// noStroke(); 
// noFill(); 
 stroke(255, 255, 255);
//fill(255, 255, 255);
 rotateY(HALF_PI);
  plane();
}
 
void plane() {
  //for (int f=-6; f<7; f++) {
 // for (int c=-6; c<7; c++) {
     // rect(10*c, 10*f, 10, 10);
   for (int k = 0; k < cols1; k++) {
    // Begin loop for rows
    for (int j = 0; j < rows1; j++) {

      // Scaling up to draw a rectangle at (x,y)
      int g = k*videoScale;
      int t = j*videoScale;
     // fill(255);
      //stroke(0);
      // For every column and row, a rectangle is drawn at an (x,y) location scaled and sized by videoScale.
      rect(g, t, videoScale, videoScale); 
  
  

}
  }
}
//void sphereMy(float s, float d, float w) {
 void sphereMy(float l, float r, float e) {
 lights();
  

  background(4);
  
   
   pushMatrix();
  noStroke(); 
 // fill(255, 111, 11);
  translate(r, l, e); 
  sphere (2); 
 // translate(width/2, height/2);
 // rotateY(map(mouseX, 0, width, -PI, PI));
  //rotateX(map(mouseY, 0, width, -PI, PI));
 scale(0.09);

  translate(-w/12, -h/12);
  for (int y = 0; y < rows-1; y++) {
   
    beginShape(TRIANGLE_STRIP);
     
    texture(img);

    for (int x = 0; x < cols; x++) {
      ax = map(x, 0, cols, 0, img.width);
      ay = map(y, 0, rows, 0, img.height);

      vertex(x*scl, y*scl, map(brightness(img.get(int(ax), int(ay))), 320, 255, 0, 200), ax, ay );

      ax = map(x, 0, cols, 0, img.width);
      ay = map(y+1, 0, rows, 0, img.height);

      vertex(x*scl, (y+1)*scl, map(brightness(img.get(int(ax), int(ay))), 320, 255, 0, 200), ax, ay );
      //rect(x*scl, y*scl, scl, scl);
    }
    endShape();
  }
  
  
  
  
  popMatrix();
}

```

---

<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, 2:26am UTC](https://discourse.processing.org/t/3-sketch-in-one/29036/2 "2021-04-01T02:26:48Z")

</div>

![Screenshot_2021-04-01-04-49-44-595](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1109ed9a4e9678cd07a5ed76244a4ba9b9998c69.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:** [April 1, 2021, 2:27am UTC](https://discourse.processing.org/t/3-sketch-in-one/29036/3 "2021-04-01T02:27:26Z")

</div>

![Screenshot_2021-04-01-04-49-19-821](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6866f758d94dbbaa54fe7f25cee8f882c9e068d5.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:** [April 1, 2021, 2:28am UTC](https://discourse.processing.org/t/3-sketch-in-one/29036/4 "2021-04-01T02:28:23Z")

</div>

![Screenshot_2021-04-01-04-48-12-479](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/850822f609c87208864eba8ed7f293da6c99c759.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:** [April 1, 2021, 2:31am UTC](https://discourse.processing.org/t/3-sketch-in-one/29036/5 "2021-04-01T02:31:13Z")

</div>

@[TfGuy44](https://forum.processing.org/two/profile/279/TfGuy44)

@ [Chrisir](https://forum.processing.org/two/profile/25/Chrisir)

thanks
