This file contains hidden or 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
| # Translated to Processing Python mode from the Java example at | |
| # "Processing: Creative Coding and Generative Art in Processing 2" by Ira Greenberg, Dianna Xu, Deepak Kumar | |
| tileSize = 50 # tamanho_grid | |
| rows = 50 # n_linhas | |
| cols = 50 # n_colunas, | |
| tiles = [[None] * rows for _ in range(cols)] | |
| ic = color(100, 125, 0) # orange # ic = color(100, 125, 0) | |
| oc = color(20, 150, 255) # blue # oc = color(20, 150, 255) |
This file contains hidden or 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
| from __future__ import division | |
| def setup(): | |
| size(600, 600) | |
| def draw(): | |
| background(0) | |
| grid_elem = 10 | |
| spac_size = width / (grid_elem + 1) | |
| v = spac_size * 1.5 |
This file contains hidden or 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
| """ | |
| Example of Video Capture on Processing Python Mode | |
| """ | |
| add_library('video') | |
| add_library('pdf') | |
| cell_size = 16 # cell size | |
| save_pdf = False | |
| def setup(): | |
| global cols, rows, video |
This file contains hidden or 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
| from itertools import combinations | |
| from itertools import combinations_with_replacement # com repetição | |
| from itertools import permutations # a ordem importa | |
| from itertools import product # todos com todos (inclui repetições e a ordem importa) | |
| elementos = ("agua", "terra", "ar", "fogo") | |
| print(list(combinations(elementos, 2))) # 6 | |
| """ | |
| [('agua', 'terra'), ('agua', 'ar'), ('agua', 'fogo'), |
This file contains hidden or 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
| # estruturas de dados listas, tuplas | |
| # loop for | |
| # enumerate() | |
| # grades, grade de elementos numerados | |
| from random import shuffle | |
| pos_celulas = [] | |
| tam = 40 # tamanho | |
| def setup(): |
This file contains hidden or 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
| # estruturas de dados listas, tuplas | |
| # loop for | |
| # enumerate() | |
| # grades, grade de elementos numerados | |
| from random import shuffle | |
| pos_celulas = [] | |
| tam = 100 # tamanho | |
| celula_arrastada = None | |
| def setup(): |
This file contains hidden or 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
| # You *need* to install py5! | |
| # Instructions at https://py5.ixora.io/ | |
| from collections import Counter | |
| from random import randint | |
| import py5 | |
| cell_size = 4 | |
| current_board = set() |
This file contains hidden or 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
| names = ['Albert', 'Allison & Peter', 'John & Paul', 'Mary', 'Ann'] | |
| def r_enumerate(iterable): | |
| return reversed(tuple(enumerate(iterable))) | |
| for i, name in r_enumerate(names): | |
| if '&' in name: | |
| a, b = name.split('&') | |
| names[i] = a.strip() | |
| names.insert(i + 1, b.strip()) |
This file contains hidden or 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
| from __future__ import division | |
| def point_inside_poly(x, y, points): | |
| # ray-casting algorithm based on | |
| # https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html | |
| inside = False | |
| for i, p in enumerate(points): | |
| pp = points[i - 1] | |
| xi, yi = p | |
| xj, yj = pp |
This file contains hidden or 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
| # Baseado em https://stackoverflow.com/a/40877887/19771 | |
| from tkinter import * | |
| current = None | |
| def DrawGrid(drawing_area, line_distance): | |
| for x in range(line_distance,600,line_distance): | |
| drawing_area.create_line(x, 0, x, 600, fill="#d3d3d3") |