# Happy Canada Day!

**URL:** <https://discourse.processing.org/t/happy-canada-day/46639>\
**Category:** Gallery\
**Created:** [July 1, 2025, 3:33pm UTC](https://discourse.processing.org/t/happy-canada-day/46639 "2025-07-01T15:33:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 1, 2025, 3:33pm UTC](https://discourse.processing.org/t/happy-canada-day/46639/1 "2025-07-01T15:33:47Z")

</div>

Hello folks!

Happy Canada Day!

[![](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/500px-Flag_of_Canada_%28Pantone%29.svg.png) ](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/500px-Flag_of_Canada_%28Pantone%29.svg.png)

```processing
/**
 * Textured 3D Cube with Canada Flag on Top Face
 * 
 * Author: glv
 * Date: 2025-07-01
 *
 * This sketch demonstrates drawing a 3D cube with a
 * texture applied only on the top face, without using
 * offscreen buffers, directly in Processing's P3D.
 */

PImage flag;

void setup() {
  size(300, 300, P3D);
  flag = loadImage("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/500px-Flag_of_Canada_%28Pantone%29.svg.png");
  flag.resize(200, 100);
}

void draw() {
  background(10);
  lights();
  translate(width/2, height/2);

  // Rotate box for demo
  rotateX(radians(-60));
  rotateY(radians(frameCount));

  // Draw the box without fill or stroke
  noFill();
  stroke(255);
  box(80, 20, 180);

  // Draw textured top face manually as a quad
  float w = 40; // half width
  float d = 90; // half depth
  float y = -10; // top face

  beginShape(QUADS);
  texture(flag);

  // Rotate UV 90 degrees clockwise if needed:
  vertex(-w, y, -d, 0, flag.height);
  vertex( w, y, -d, 0, 0);
  vertex( w, y, d, flag.width, 0);
  vertex(-w, y, d, flag.width, flag.height);

  endShape();
}

```

References:

- [Canada - Wikipedia](https://en.wikipedia.org/wiki/Canada)
- [https://www.canada.ca/en.html](https://www.canada.ca/en.html)

`:)`
