Last active
November 24, 2020 21:10
-
-
Save feromes/9014dcb19665dab20e697765208850bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
# Define os valores da tela para serem referenciados no código | |
xmax, ymax = 1000, 1000 | |
# Carrega os pontos que estão no arquivo e atribui às listas globais x e y | |
def load_points(): | |
global x, y | |
x, y = [], [] | |
with open('complexidade-200-pontos.csv', 'rb') as csvfile: | |
points = csv.reader(csvfile, delimiter=',') | |
for row in points: | |
x.append(float(row[0])) | |
y.append(float(row[1]) * -1.0) | |
# retorna a boundbox minima da lista de pontos carregada | |
def word_bbox(): | |
return ((min(x), min(y)), (max(x), max(y))) | |
# retorna a bound box adaptada ao desenho | |
def word_box_range(x_margin=100, y_margin=200): | |
_xmin = x_margin | |
_xmax = (xmax - x_margin) | |
_ymin = y_margin | |
_ymax = ((_xmax - _xmin) / (max(x) - min(x))) * (max(y) - min(y)) + y_margin | |
return ((_xmin, _ymin), (_xmax, _ymax)) | |
def setup(): | |
load_points() | |
global word_bbox | |
word_bbox = word_bbox() | |
print word_bbox | |
background(255, 255, 255) | |
size(xmax, ymax) | |
noLoop() | |
def draw(): | |
#################### | |
### complexidade ### | |
#################### | |
noFill() | |
strokeWeight(0.01) | |
beginShape() | |
g = (-1, 1) | |
d = 180 | |
r = 0.3 | |
_word_box_range = word_box_range() | |
vertex(map(randomGaussian(), -4, 4, _word_box_range[0][0], _word_box_range[1][0]), | |
map(randomGaussian(), -4, 4, _word_box_range[0][1], _word_box_range[1][1])) | |
# itera sob cada ponto | |
for i, c in enumerate(x): | |
# definindo parametros que serão utilizados para desenhar em cada ponto | |
_r, _g, _b = random(0, 256), random(0, 256), random(0, 256) | |
_i = floor(random(0, len(x))) | |
_x = map(c, word_bbox[0][0], word_bbox[1][0], _word_box_range[0][0], _word_box_range[1][0]) | |
_y = map(y[i], word_bbox[0][1], word_bbox[1][1], _word_box_range[0][1], _word_box_range[1][1]) | |
_x2 = map(randomGaussian(), g[0], g[1], _x-d, _x+d) | |
_y2 = map(randomGaussian(), g[0], g[1], _y-d, _y+d) | |
_x3 = map(randomGaussian(), g[0], g[1], _x-d, _x+d) | |
_y3 = map(randomGaussian(), g[0], g[1], _y-d, _y+d) | |
# reforça os pontos internos | |
fill(_r, _g, _b) | |
circle(_x, _y, 1.8) | |
bezierVertex((randomGaussian() * r) + _x, | |
(randomGaussian() * r) + _y, | |
(randomGaussian() * r) + _x, | |
(randomGaussian() * r) + _y, | |
_x, _y) | |
bezierVertex((randomGaussian() * r) + _x, | |
(randomGaussian() * r) + _y, | |
(randomGaussian() * r) + _x, | |
(randomGaussian() * r) + _y, | |
_x, _y) | |
# gera as linhas caóticas | |
noFill() | |
stroke(0, 0, 0, 190) | |
bezierVertex(_x2, _y2, _x3, _y3, _x, _y) | |
endShape() | |
#################### | |
### determinismo ### | |
#################### | |
fill(0, 0, 0) | |
rect(0, ymax/2, xmax, ymax/2) | |
textAlign(CENTER, CENTER) | |
# textSize(120) | |
font = loadFont('BitstreamVeraSans-Bold-120.vlw') | |
textFont(font, 100) | |
fill(255,255,255) | |
text("DETERMINISM", xmax/2, 3*(ymax/4)) | |
# salvando arquivo de imagem | |
save('complexidade-determinismo.png') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment