# Pentagonal Tesselation

**URL:** <https://discourse.processing.org/t/pentagonal-tesselation/34416>\
**Category:** Gallery\
**Created:** [January 1, 2022, 8:00pm UTC](https://discourse.processing.org/t/pentagonal-tesselation/34416 "2022-01-01T20:00:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [January 1, 2022, 8:00pm UTC](https://discourse.processing.org/t/pentagonal-tesselation/34416/1 "2022-01-01T20:00:39Z")

</div>

Happy New Year everyone!

I hope you enjoy some tiling with pentagons.

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

More ideas here: [https://math.dartmouth.edu/~mutzel/pentagonal\_tiling.pdf](https://math.dartmouth.edu/~mutzel/pentagonal_tiling.pdf)  
And here: [Cairo pentagonal tiling - Wikipedia](https://en.wikipedia.org/wiki/Cairo_pentagonal_tiling)

```python
def setup(): 
    size(180 * 3, 90 * 6) 
    s = 15
    w, h = 12 * s, 6 * s
    cols = width // w
    rows = height // h
    for i in range(cols + 1):
        x = i * w
        for j in range(rows + 1):
            y = j * h
            if j % 2:
                module(x, y, s)
            else:
                module(x + w / 2, y, s)
    
def module(x, y, s):
    fill(255, 220, 0)
    pentagon(x, y, s) 
    fill(255, 220, 155)
    pentagon(x + 6 * s, y, s, r=1) 
    fill(0, 100, 200)
    pentagon(x - 6 * s, y, s, r=3) 
    fill(140, 180, 255)
    pentagon(x, y, s, r=2) 
     
def pentagon(xo, yo, s, r=0): 
    pts = ((-2, 0), (2, 0), (3, 3), (0, 4), (-3, 3)) 
    pushMatrix() 
    translate(xo, yo) 
    rotate(HALF_PI * r) 
    beginShape() 
    for x, y in pts: 
        vertex(x * s, y * s) 
    endShape(CLOSE) 
    popMatrix()

```

---

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [January 1, 2022, 10:57pm UTC](https://discourse.processing.org/t/pentagonal-tesselation/34416/2 "2022-01-01T22:57:37Z")

</div>

Happy New Year Alexandre ! Thank you for sharing this, I really like the colors you used.

And of course, Happy New Year to everyone. Special thoughts for our small Python enthusiasts community.

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [January 1, 2022, 11:01pm UTC](https://discourse.processing.org/t/pentagonal-tesselation/34416/3 "2022-01-01T23:01:47Z")

</div>

Thanks! But I have to admit that I imitated the colors from the example at the Wikipedia article! 😃

---

<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:** [January 3, 2022, 8:52am UTC](https://discourse.processing.org/t/pentagonal-tesselation/34416/4 "2022-01-03T08:52:48Z")

</div>

I could not resist having a go with JRubyArt and py5 (which is a bit too similar at present so I don’t show it here). Here’s JRubyArt version:-

```ruby
ANGLE = PI / 2
PTS = [Vec2D.new(-30, 0), Vec2D.new(30, 0), Vec2D.new(45, 45), Vec2D.new(0, 60), Vec2D.new(-45, 45)]
S = 15
W = 12 * S
H = 6 * S

def settings
  size(W * 3, H * 6)
end

def setup
  sketch_title 'Cairo tiling'
  @renderer ||= GfxRender.new(g)
  cols = width + W
  rows = height + H
  grid(cols, rows, W, H) do |x, y|
     (y % W).zero? ? composite_tile(x + W / 2, y, S) : composite_tile(x, y, S)
  end
end

def composite_tile(x, y, s)
  fill(255, 220, 0)
  pentagon(x, y, s)
  fill(255, 220, 155)
  pentagon(x + 6 * s, y, s, r = 1)
  fill(0, 100, 200)
  pentagon(x - 6 * s, y, s, r = 3)
  fill(140, 180, 255)
  pentagon(x, y, s, r = 2)
end

def pentagon(xo, yo, s, r = 0)
  push_matrix
  translate(xo, yo)
  rotate(ANGLE * r)
  begin_shape
  PTS.map { |vec| vec.to_vertex(@renderer) }
  end_shape
  pop_matrix
end

```

Makes use of ruby-processing grid function and vector to vertex function (I think py5 probably has something similar with new vector class).
