Skip to content

Instantly share code, notes, and snippets.

View villares's full-sized avatar
💥

Alexandre B A Villares villares

💥
View GitHub Profile
def inicie_caneta(*args):
global caneta
caneta = True
resetMatrix()
if args:
x, y = args
translate(x, y)
else:
translate(width / 2, height / 2)
rotate(HALF_PI)
@villares
villares / nuvem.py
Created June 26, 2020 20:17
Uma primeira tentativa de nuvem de palavras com Turtle Graphics no Python :)
# Sugestão: uso o IDE thonny.org
# precisa de um arquivo texto.txt 'ao lado' deste script
from turtle import *
from collections import Counter
from random import randrange
def fala(texto, tamanho=18, estilo="normal"):
write(texto, align='center', font=("Open Sans",
tamanho, estilo))
@villares
villares / processing_py.pyde
Created June 27, 2020 02:55
código issue Fernanda
### arrastando vários círculos
arrastando = None # None quer dizer nenhum círculo sendo arrastado
circulos = [] # lista com coordenadas e tamanhos dos círculos
def setup():
size(400, 400)
strokeWeight(3)
fill(0, 200) # preenchimento translúcido
for _ in range(5): # vamos sortear 5 círculos
@villares
villares / graph.py
Created July 14, 2020 20:25
Graphs!
"""
A simple Python graph class, demonstrating the essential facts and functionalities of graphs
based on https://www.python-course.eu/graphs_python.php and https://www.python.org/doc/essays/graphs/
"""
class Graph(object):
def __init__(self, graph_dict=None):
"""
Initialize a graph object with dictionary provided,
@villares
villares / sketch.js
Created July 17, 2020 23:40
Adapting Repeller from Khan Academy for p5js
// adapted from Khan Academy that adapts Dan Shiffman, natureofcode.com
// https://pt.khanacademy.org/computing/computer-programming/programming-natural-simulations/programming-particle-systems/a/particle-systems-with-forces
var gravity;
var particleSystem;
var repeller;
function setup() {
createCanvas(400, 400);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@villares
villares / deque_writer.pyde
Last active October 8, 2020 17:51
Processing Python mode
"""
Para rodar, installe o Processing modo Python:
https://abav.lugaralgum.com/como-instalar-o-processing-modo-python/
Teclas:
ESPAÇO: apaga tudo
c: Muda modo de cor ou cinza
x: Muda paleta de cor
SHIFT: apaga itens nas duas pontas do deque
"""
@villares
villares / circle.pde
Last active October 22, 2020 19:34
FreyaHolmer's Mathfs ported to Processing Java!
// https://twitter.com/FreyaHolmer/status/1319278214087258112?s=20
// FROM: https://github.com/FreyaHolmer/Mathfs/
/*
TODO: YEAH INTERSECT IT IS HARD... IF ANYONE WANTS TO HELP...!
- CircleFromThreePoints() depends on LineSegment2D and Intersect...
- I have some lazy line segment intersection I could use
but Freya's has cool Rays and infinite lines...
- ...
- Then I'll port everything to Processing Python mode...
*/
@villares
villares / index.html
Created November 8, 2020 00:38
pyp5js (pyodide version) without editor
<!DOCTYPE html>
<!-- pyp5js index.html boilerplate -->
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pyp5js with Pyodide Demo</title>
<style> body, html, canvas {padding: 0; margin: 0; overflow: hidden;} </style>
@villares
villares / sharpen_and_blur.pyde
Last active November 14, 2020 20:07
Repeatedly Sharpen and Blur an image - Add a /data/ folder to your sketch with a `img.jpg` file
# based on https://processing.org/tutorials/pixels/
w = 80
# It's possible to perform a convolution
# the image with different matrices
sharpen_kernel = [[-1, -1, -1],
[-1, 9, -1],
[-1, -1, -1]]