Skip to content

Instantly share code, notes, and snippets.

View villares's full-sized avatar
💥

Alexandre B A Villares villares

💥
View GitHub Profile
@villares
villares / animated_image_show.py
Last active July 26, 2024 23:25
Show images or SVGs from a folder named 'data' next to your py5 imported mode script.
"""
You'll need py5 and a use the run_sketch tool or Thonny + thonny-py5mode
to run this py5 "imported mode" style sketch. Learn more at py5coding.org
Add images or SVGs to a folder named 'data' next to your animated image show script.
It will run on full screen. Click on screen and press ESC to exit.
Adjust speed by changing the time_per_image variable in milliseconds.
Beware py5 might be unable to load some SVGs... an error message will be printed.
This version will not try to scale images to fit the screen.
@villares
villares / mapas_sesc_grupo_de_Estudo.ipynb
Last active July 11, 2024 18:41
Mapa das sorveterias - Grupo de Estudos em Python - Sesc Av. Paulista - Based on work by Lisa-Ho: https://github.com/Lisa-Ho/small-data-projects/blob/main/2023/2307-gelaterias/gelaterias-map.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@villares
villares / truchet.md
Last active March 12, 2024 02:49
Elementos para criar Truchet Tiles https://en.wikipedia.org/wiki/Truchet_tiles com py5 #Truchet #Pyhon #py5 #ProgramaçãoCriativa

Truchet tiles

Vídeos

Os exemplos mais abaixo neste Gist são a inspiração para 3 videozinhos sobre Azulejos de Truchet com py5 (usando py5 imported mode no Thonny)

Se você gostar, considere apoiar a instância do PeerTube do LHC que hospeda os vídeos https://peertube.lhc.net.br e me apoiar (que fiz esse material) https://liberapay.com/villares

@villares
villares / make_a_box.py
Created January 22, 2024 19:26
Caixinha com corte laser, versão com py5
import py5
fator_escala = 3.78 * 50 / 189
NOME = "caixa_flex-v1" # Precisa ser cortado 2x! só desenha "meia caixa"
W, H, P = 200, 120, 50 # dimensões
R = 30 # raio
XO, YO = 50, 50 # offset do desenho na página
def setup():
# -----------------------------------------------------------------------------
# From Pytnon to Numpy
# Copyright (2017) Nicolas P. Rougier - BSD license
# More information at https://github.com/rougier/numpy-book
# -----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib.animation import FuncAnimation
from matplotlib.collections import PathCollection
@villares
villares / dados.md
Created November 9, 2023 01:03
Lê uma planilha de Excel e altera um arquivo de Word

image

image

@villares
villares / multiple_page_pdf_py5_imported_mode.py
Last active January 26, 2024 15:21
Template for generating a multi-page PDF with py5 (and a bonus PDF "overlay" script)
"""
An example/template for generating a mutiple page PDF using py5.
Imported mode style - You'll need to use the thonny-py5mode plug-in or the sketch_runner tool
CC0 / Public Domain dedication - by Alexandre B A Villares
"""
NUM_PAGES = 10
s = 0.71 # scale factor 1 => 356 x 275 trying 252 x 195
rs = 1 # starting random seed
@villares
villares / Aqui_SP-OSMNX.py
Created August 25, 2023 13:30
Experimentos com osmnx
import pickle
from pathlib import Path
import osmnx as ox
from download_from_gdrive import download_from_gdrive
# configure the place, network type, trip times, and travel speed
place = {"city": "São Paulo", "country": "Brazil"}
network_type = "walk"
@villares
villares / export_single_png.py
Created August 18, 2023 14:24
Export PNG with transparent background
# using py5 imported mode (https://py5coding.org to learn more)
def setup():
size(600, 600) # drawing size
output_canvas = create_graphics(width, height)
background(255, 0, 0) # you can turn this off, this won't be recorded!
begin_record(output_canvas) # starts recording
# output_canvas.clear() # clears pixels (not necessary in this case)
color_mode(HSB) # this needs to be inside the recording!
no_stroke() # same as with the color_mode, has to be brought here