# Ilustrações vetoriais com programação - Aula 2
### `hackmd.io/@sesc-av-paulista/ilustras-vetoriais-2`
#### [índice das aulas](https://hackmd.io/@sesc-av-paulista/ilustras-vetoriais)
- variáveis
- criando novas funções com `def`
- repetição com o *loop* `for`
- grades (filas e colunas de elementos)
- sorteios (pseudo-aleatórios) `random`
- Exercícios: https://abav.lugaralgum.com/faded-parsons-visual/
### Variáveis

```python!
def setup():
size(600, 500)
no_stroke()
x = 100
y = 250
largura = 200
fill(255)
ellipse(x, y, largura, largura / 150 * 80)
fill(255, 0, 0)
circle(x, y, largura / 150 * 60)
fill(0)
circle(x, y, largura / 150 * 30)
```
### Funções
```python
def setup():
size(600, 500)
olho(300, 250, 150) # x, y, largura
olho(400, 350, 120)
olho(100, 100, 100)
def olho(x, y, largura):
no_stroke()
fill(255)
ellipse(x, y, largura, largura / 150 * 80)
fill(255, 0, 0)
circle(x, y, largura / 150 * 60)
fill(0)
circle(x, y, largura / 150 * 30)
```
### Laços de repetição
```python!
>>> frutas = ['jabuticab', 'manga', 'melancia', 'banana', 'pera', 'maracujá', 'uva']
>>> type(frutas)
<class 'list'>
>>> len(frutas)
7
```





### Grade

```python
def setup():
size(500, 500)
numero_circulos = 25
diametro = width / numero_circulos
for j in range(numero_circulos): # j = 0, ... numero_circulos-1
y = diametro / 2 + j * diametro
for i in range(numero_circulos): # i = 0, 1, 2 ... numero_circulos-1
x = diametro / 2 + i * diametro
circle(x, y, diametro)
```
