Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# exemplo_lista = [10, 20, 3, 13, 1]
# exemplo_tupla = (10, 22, "sim", color(0))
# [(100, 100, 5, cor), (200, 100, 10, cor), ...]
from itertools import combinations
def setup():
global dados_bolas, combos
size(500, 500)
fill(200, 200, 0) # amarelo
dados_bolas = cria_grade(5, 5, 100, 100) # cria uma lista de tuplas
combos = list(combinations(dados_bolas, 2))
print(len(combos))
def draw():
background(0)
translate(50, 50)
for x, y, tam, cor in dados_bolas:
fill(cor)
noStroke()
ellipse(x, y, tam, tam)
ini = int(random(300)) - 11
for a, b in combos[ini:ini+10]:
x1, y1, _, _ = a
x2, y2, _, _ = b
stroke(255)
strokeWeight(5)
line(x1, y1, x2, y2)
def cria_grade(colunas, filas, espaco_x=1, espaco_y=1):
pontos = []
for i in range(colunas):
x = i * espaco_x
for j in range(filas):
y = j * espaco_y
tam = random(10, 50)
colorMode(HSB)
# cor = color(random(256), 200, 255)
h = (128 + map(tam, 10, 50, 0, 255)) % 256
cor = color(h, 200, 255)
pontos.append((x, y, tam, cor))
return pontos
def keyPressed():
global dados_bolas
if key == ' ':
dados_bolas = cria_grade(5, 5, 100, 100)
@villares

This comment has been minimized.

Copy link
Owner Author

@villares villares commented Mar 24, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment