Alexandre B A Villares villares · he/him
  • São Paulo
  • https://abav.lugaralgum.com
  • I'm a teacher & visual artist. I research artistic and design practices that make use of computational means, promote creative coding and programming education in visual contexts, and develop open educational materials.

  • Joined on 2023-02-13

animação Hello World

This animation is made with points in a Python collections.deque data structure, added by dragging the mouse (see code further bellow).

  • 💬 Ask me about drawing with Python!
    • Check out py5 one of the projects I'm most active on.
    • Also pyp5js, a hack to bring in the vocabulary from py5 to a p5js + pyodide backend!
    • I try to make a new drawing with code everyday, and I put the results at skech-a-day.
  • 🔭 I have just finished a PhD at Unicamp by the end of 2025. I have very little idea of what I'm going to do now...
  • 👯 I’d like to collaborate on open resources to teach programming.
  • 📫 How to reach me: Mastodon or Email.
from collections import deque  # a double-ended queue
import py5  # check out https://github.com/py5coding 

history = deque(maxlen=512)  # mouse dragged positions

def setup():   # py5 will call this once to set things up
    py5.size(600, 400)
    py5.no_stroke()
    py5.color_mode(py5.HSB)

def draw():   # py5 will call this in a loop
    py5.background(51)
    for i, (x, y) in enumerate(history):
        py5.fill(i / 2, 255, 255, 128)
        py5.circle(x, y, 8 + i / 16)
    history.rotate(-1)  # Thank you Ramalho! Previously `if h: h.append(h.popleft())`

def mouse_dragged():  # py5 will call this when you drag the mouse
    history.append((py5.mouse_x, py5.mouse_y))
    
def key_pressed():   # py5 will call this when a key is pressed
    history.clear()

py5.run_sketch()