---
# System prepended metadata

title: Grupo de estudos em Python - Ladrilhamentos geométricos - 8/maio

---

### Sesc Av. Paulista
## Grupo de estudos em Python
# `hackmd.io/@sesc-av-paulista/estudos-em-python-8-maio`



- Hexágonos 
    - [site redblobgames.com/grids/hexagons](https://www.redblobgames.com/grids/hexagons/)
![image](https://hackmd.io/_uploads/H1L_nvcgex.png)

- Azulejos pentagonais "do Cairo"
    - https://blogs.ams.org/visualinsight/2016/01/15/cairo-tiling/
    - [na Wikipedia](https://en.m.wikipedia.org/wiki/Cairo_pentagonal_tiling)
![image](https://hackmd.io/_uploads/rJcgnwcgle.png)

- Quadrados e triângulos
![image](https://hackmd.io/_uploads/SycdADqlex.png)


### Pentágono dos azulejos do Cairo

![images](https://hackmd.io/_uploads/BJ46V_5gex.jpg)

### Primeira aproximação

![image](https://hackmd.io/_uploads/Syz8Nd9lgg.png)

![image](https://hackmd.io/_uploads/rkenZtcexx.png)

```python=

def setup():
    size(450, 450)
    base = 75
    no_fill()
    w = base * 3
    h = base * 1.5
    for i in range(3):
        for j in range(5):
            if j % 2 == 0:
                x = i * w
            else:
                x = i * w + w / 2
            y = j * h
            grupo(x, y, base)    
    
def grupo(x, y, base):
    desc = base * 1.5
    pentagono(x, y, base, rot=False)
    pentagono(x, y, base, rot=False, flip=True)
    pentagono(x + desc, y, base, rot=True)
    pentagono(x - desc, y, base, rot=True, flip=True)
    
def pentagono(xb, yb, lado_base, rot=False, flip=False):
    vs = [
    (-2,  0),
    (-3, -3),
    ( 0, -4),
    ( 3, -3),
    ( 2,  0)
    ]
    u = lado_base / 4
    with begin_closed_shape():
        for i, j in vs:
            if flip:
                j = -j
            if rot:
               i, j = j, -i
            x = xb + i * u
            y = yb + j * u
            vertex(x, y)
    

```

### Colorido

![image](https://hackmd.io/_uploads/H1Pd8K5eel.png)


```python=
def grupo(x, y, base):
    desc = base * 1.5
    fill(200, 0, 0)
    pentagono(x, y, base, rot=False)
    fill(255, 150, 150)
    pentagono(x, y, base, rot=False, flip=True)
    fill(0, 0, 200)
    pentagono(x + desc, y, base, rot=True)
    fill(150, 150, 255)
    pentagono(x - desc, y, base, rot=True, flip=True)

    
```

### Animado

![sketch_2025_05_08](https://hackmd.io/_uploads/HynUaC9xxl.gif)

https://github.com/villares/sketch-a-day/blob/main/2025/sketch_2025_05_08/sketch_2025_05_08.py