Skip to content

Instantly share code, notes, and snippets.


Alexandre B A Villares villares

View GitHub Profile
villares /
Last active Jun 19, 2022
Made with @Introscopia and 2D simulations course at participants at Sesc Av. Paulista [WIP at]
# Check out further developments at:
# Pymunk PINBALL experiments at Sesc Av. Paulista
# Needs and
# You'll need to learn about py5 imported mode (sketch_runner)
import pymunk as pm # importa lib de simulação
from random import choice
space = pm.Space() # objeto espaço de simulação
villares /
Last active May 31, 2022
Tweaking a PySimpleGUI Image viewer example
# For use with /home/villares/GitHub/sketch-a-day/2022/sketch_2022_05_29
import PySimpleGUI as sg
# import PySimpleGUIQt as sg
import os.path
import PIL.Image
import io
Based on: Demo for displaying any format of image file.
View irregular_grid.pyde
# Based on Ahmad Moussa's article
# via Chris Barber
# Code for Processing Python mode (
from collections import namedtuple
from random import choice, sample, seed
Rect = namedtuple("Rect", "posX posY dimX dimY")
rect_infos = []
Inspired by 'follow 3' code from Keith Peters in the Processing examples
you will need's sketch runner for imported mode
def setup():
global first_seg, other_seg
size(500, 500)
# you will need's sketch runner for imported mode
def setup():
global first_seg
size(500, 500)
seg = Segment((100, 100), (100, 100))
for _ in range(10):
seg = Segment((100, 100), (100,100), seg)
villares / kirigami.pyde
Last active Jun 8, 2022
There are several files on this Gist... the ones ending in `.pyde` are for Processing Python Mode, the others `.py` are for use with the `` library on Python 3.8+. One has a "manual" tuples option.
View kirigami.pyde
# for Processing Python Mode
add_library('pdf') # equivale a importar a lib de PDF no Processing
mode_3D = True # modo 3D ou 2D (muda com tecla '3')
save_pdf = False # Avisa que vai exportar, tecla 's'
seed = 5465 # "semente" que trava os sorteios dos números aleatórios e do noise
s = 0.005 # noise scale
villares /
Last active Apr 7, 2022
Noite de Processing - Simulações Físicas - com John e Alexandre
# You'll need py5 -
# Also needs
# Similar to the previous one but with some monkey patching and changes the softbody grid construction
import py5
import pymunk as pm
space = pm.Space()
space.gravity = (0, 600)
villares / rotated_rect.pyde
Last active Feb 27, 2022
Rotated Rectangle example
View rotated_rect.pyde
from random import choice
def setup():
size(500, 500)
def draw():
villares /
Last active Nov 1, 2021
A quick proof of concept, PVector-like class for use with my py5 sketches
# A quick proof of concept, PVector-like class for use with my py5 ( based sketches
# Made from previous versions for pyp5js:
import math
from numbers import Number
TWO_PI = math.tau
class PVector:
View chain_reaction.pyde
from random import choice
atoms = [] # lista de objetos
neutrons = []
def setup():
""" Define área de desenho e popula lista de particles """
size(800, 800) # área de desenho (width, height)
half_width, half_height = width / 2, height / 2
density = 200 # try 900