diff --git a/2020/sketch_2020_05_03a/circulos.txt b/2020/sketch_2020_05_03a/circulos.txt new file mode 100644 index 00000000..0a409484 --- /dev/null +++ b/2020/sketch_2020_05_03a/circulos.txt @@ -0,0 +1,100 @@ +68 120 37.5507659912 +71 98 32.7605819702 +78 83 26.2493400574 +84 71 36.1811676025 +87 63 35.6623039246 +89 59 37.2014465332 +90 56 37.5425949097 +91 56 23.1710891724 +93 55 34.2703857422 +98 50 31.6832389832 +103 47 33.4321708679 +108 45 25.8527698517 +113 42 20.8555641174 +124 37 29.9782791138 +136 31 31.7752609253 +149 27 24.8222732544 +154 26 34.5677070618 +160 24 20.0283756256 +173 24 22.2010574341 +183 24 20.4927997589 +186 24 30.4036521912 +191 24 20.9710578918 +197 26 28.8784370422 +200 30 25.5658760071 +207 40 35.2682342529 +212 50 28.6996612549 +214 60 21.890417099 +215 69 32.1768112183 +215 74 35.6216468811 +215 80 35.1529312134 +215 88 35.537853241 +215 96 30.0481872559 +215 110 35.7975616455 +200 134 20.947555542 +183 161 23.5521335602 +174 174 35.4246482849 +163 186 33.276473999 +134 217 26.9876251221 +121 232 29.432636261 +111 245 35.4188079834 +92 268 25.752664566 +82 283 33.6404495239 +81 286 26.13022995 +80 286 28.5353317261 +80 288 39.8384246826 +80 293 21.6028556824 +84 296 28.3275051117 +87 298 32.2336921692 +90 299 34.3659210205 +95 301 27.6532554626 +111 303 26.9357223511 +120 303 32.9280700684 +127 303 25.6983222961 +134 303 22.3617763519 +148 299 27.5169754028 +155 293 36.1063766479 +163 286 38.0320510864 +181 264 22.0957355499 +193 250 29.5887451172 +204 236 25.3923835754 +214 224 39.7097625732 +225 213 21.2051372528 +234 203 33.681224823 +249 187 23.3013076782 +255 179 24.9780349731 +262 172 34.3098945618 +262 171 38.1615066528 +115 133 24.8885917664 +126 138 38.888633728 +139 144 25.6563510895 +152 152 22.8422679901 +168 162 33.01404953 +198 177 27.1914539337 +209 182 20.3977928162 +214 185 34.9469566345 +220 187 32.9031295776 +228 190 20.6996994019 +233 194 29.5262489319 +241 199 32.8629074097 +248 204 29.2589321136 +254 210 28.8827438354 +270 226 29.4981384277 +283 239 21.0945587158 +293 248 34.3515319824 +305 257 36.0827255249 +312 261 23.1237487793 +315 264 26.8098888397 +317 265 26.0853843689 +317 266 28.0420150757 +317 266 29.112121582 +317 267 34.2958297729 +318 269 24.6351699829 +325 280 20.2182407379 +329 288 23.17329216 +336 298 32.5065689087 +338 301 31.270116806 +339 304 23.0612754822 +341 307 28.4858779907 +341 308 25.7688598633 +342 308 37.6960639954 diff --git a/2020/sketch_2020_05_03a/sketch_2020_01_03a.png b/2020/sketch_2020_05_03a/sketch_2020_01_03a.png new file mode 100644 index 00000000..3dc8d0c7 Binary files /dev/null and b/2020/sketch_2020_05_03a/sketch_2020_01_03a.png differ diff --git a/2020/sketch_2020_05_03a/sketch_2020_05_03a.pyde b/2020/sketch_2020_05_03a/sketch_2020_05_03a.pyde new file mode 100644 index 00000000..27eef29a --- /dev/null +++ b/2020/sketch_2020_05_03a/sketch_2020_05_03a.pyde @@ -0,0 +1,63 @@ +# from __future__ import unicode_literals + +circulos = [] + +def setup(): + size(400, 400) + fill(100, 100, 255) + println(u"Tecle 'W' para gravar e 'L' para carregar dados de um arquivo texto") + +def draw(): + background(0) + for circulo in circulos: + x, y, tamanho = circulo + ellipse(x, y, tamanho, tamanho) + +def mouseDragged(): + circulo = (mouseX, mouseY, random(20, 40)) + circulos.append(circulo) + +def keyPressed(): + if key =='w' or key == 'W': + selectOutput("Salvar como:", "salvar_circulos") # Argumentos: título, função chamada na conclusão + if key == 'l' or key == 'L': + selectInput("Escolha um arquivo:", "carregar_circulos") + if key == ' ': + circulos[:] = [] + if key == 's': + saveFrame("sketch_2020_01_03a.png") + +def salvar_circulos(arquivo): + if arquivo == None: + print("Gravação cancelada.") + else: + path_arquivo = arquivo.getAbsolutePath() + if not path_arquivo.endswith('.txt'): + path_arquivo += '.txt' + linhas = [] + for circulo in circulos: + x, y, tamanho = circulo + linhas.append(u'{} {} {}'.format(x, y, tamanho)) + saveStrings(path_arquivo, linhas) + +def carregar_circulos(arquivo): + if arquivo == None: + print(u"Seleção cancelada.") + else: + path_arquivo = arquivo.getAbsolutePath() + print("Arquivo selecionado: " + path_arquivo) + linhas = loadStrings(path_arquivo) + for linha in linhas: + str_x, str_y, str_tamanho = linha.split() + circulo = float(str_x), float(str_y), float(str_tamanho) + circulos.append(circulo) + + + # from io import open # usando este quebra + # if not path_arquivo.endswith('.txt'): + # path_arquivo += '.txt' + # with open(path_arquivo, 'w') as f: # acrescentando encoding='utf-8' quebra :( + # # print file_out <_io.TextIOWrapper name=u'/home/villares/a.txt' + # for circulo in circulos: + # x, y, tamanho = circulo + # f.write('{} {} {} #é\n'.format(x, y, tamanho))