Alexandre B A Villares 🐍 · @villares
987 followers · 2664 posts · Server ciberlandia.pt

sketch_2023_03_31

import py5

margin = 60

def setup():
py5.size(800, 800)
py5.no_loop()

def draw():
py5.background(0)
grid(margin, margin, py5.width - margin * 2)

def grid(xo, yo, largura_total, n=3):
w = largura_total / n
color_step = 255 / n
for j in range(n):
x = xo + w * j
for i in range(n):
y = yo + w * i
py5.fill(i * color_step, # red
j * color_step, # green
255 - i * color_step) # blue
if w > 10 and py5.random(9) > 5:
grid(x, y, w)
else:
py5.circle(x + w / 2, y + w / 2, w * 0.98)

def key_pressed():
py5.save_frame('###.png')
redraw()

py5.run_sketch()

#processing #python #py5 #トゥートprocessing #tootprocessing #generativeart #creativecoding

Last updated 2 years ago

Alexandre B A Villares 🐍 · @villares
865 followers · 1446 posts · Server ciberlandia.pt

# iamkate.com/data/12-bit-rainbo
palette = (
'#817', '', '', '',
'', '', '', '',
'', '', '', '#639'
)

def setup():
size(800, 800)
no_stroke()
background(0)

def draw():
xc = yc = 400
for i in range(6):
m = 1 - abs(cos(radians(frame_count / 2))) ** 5
r = 150 + 150 * m
a = radians(frame_count / 2 + 60 * i)
x = xc + r * cos(a)
y = yc + r * sin(a)
fill(palette[i])
circle(x, y, 150)
r = 300 - 150 * m
a = a + radians(30)
x = xc + r * cos(a)
y = yc + r * sin(a)
fill(palette[-1 -i])
circle(x, y, 150)

#processing #python #py5 #genuary #genuary31 #トゥートprocessing #a35 #c66 #e94 #ed0 #9d5 #4d8 #2cb #0bc #09c #36b

Last updated 2 years ago

Alexandre B A Villares 🐍 · @villares
857 followers · 1390 posts · Server ciberlandia.pt

imported mode
# Kate Rose Morley's palette
# iamkate.com/data/12-bit-rainbo

from itertools import product

palette = (
'#817', '', '', '',
'', '', '', '',
'', '', '', '#639'
)

def setup():
global palavras
size(800, 800)
no_loop()
rect_mode(CENTER)
no_stroke()

def draw():
w = 400
i = 0
for x, y in product(range(0, width, w), repeat=2):
for z in range(3):
fill(palette[i])
square(w / 2 + x, w / 2 + y, w / (z / 2 + 1))
i += 1

#processing #python #py5 #genuary #genuary30 #トゥートprocessing #a35 #c66 #e94 #ed0 #9d5 #4d8 #2cb #0bc #09c #36b

Last updated 2 years ago

Alexandre B A Villares 🐍 · @villares
843 followers · 1246 posts · Server ciberlandia.pt

S = 600
ns = 1

def setup():
size(S, S)
no_stroke()

def draw():
noise_seed(ns)
background(255, 255, 0)
x, f = 8, frame_count
while x < S * 2:
y = 8
while y < S:
M = 16 + 4 * sin(x * 0.05)
h = M * noise(x * 0.01, y * 0.01, f * 0.01) #+ sin(y * 0.005)
fill(0)
(h * 24, 255 - h * 16, 0)
circle(x, y, min(M * 0.45, h))
y += min(M * 0.5, h)
x += M * 0.5
fill(255, 255, 0)
rect(0, S - 4, width, 4)

def key_pressed():
global ns
ns += 1

#sketch_2022_01_25 #processing #トゥートprocessing #python #py5 #genuary #genuary25 #fill

Last updated 2 years ago

Alexandre B A Villares 🐍 ☔ · @villares
814 followers · 1034 posts · Server ciberlandia.pt

"""
sketch_2022_01_17

Code for (py5coding.org) imported mode

Recursive grid - I'm always grateful for Takao Shunsuke's inspiration.


"""

def setup():
size(1024, 1024)
no_loop()

def draw():
background(0)
grid(0, 0, width, 4)
save_frame('###.png')

def grid(grid_x, grid_y, grid_size, n):
cell_size = grid_size / n
for i in range(n):
x = grid_x + i * cell_size
for j in range(n):
y = grid_y + j * cell_size
if cell_size < 20:
fill(x % 255, 200, y % 255)
circle(x + cell_size / 2,
y + cell_size / 2,
cell_size)
elif n == 1:
fill(0, 0, 200)
square(x, y, cell_size)
else:
next_n = int(random(1, 5))
grid(x, y, cell_size, next_n)

def key_pressed():
redraw()

#genuary #genuary17 #python #processing #py5 #トゥートprocessing #tootprocessing

Last updated 2 years ago

# Um exemplo de como exportar um sketch no ( + ) em alta resolução:
# Usando py5 (py5coding.org) com "imported mode", via plugin no Thonny IDE github.com/tabreturn/thonny-py

def setup():
size(512, 512)

# Prepare to record a high-res output
scale_factor = 4
out = create_graphics(width * scale_factor, height * scale_factor)
begin_record(out)
out.scale(scale_factor) # Needs to be after begin_record()

# Your drawing goes here!
background(0)
rect_mode(CENTER) # Don't forget to put mode changes
color_mode(HSB) # inside the recorded part!
no_stroke()
for i in range(16, 256, 16):
fill(i, 200, 200,)
rect(i * 2, i * 2, 32, 32)
fill((i + 128) % 256, 200, 200,)
ellipse(i * 2, i * 2, 16, 16)

# End recording and save
end_record()
out.save('output.png')

#py5 #processing #python #トゥートprocessing #tootprocessing

Last updated 2 years ago

# Abreviated version from github.com/villares

from collections import deque
history = deque(maxlen=512)

def setup():
size(600, 400)
no_stroke()
color_mode(HSB)

def draw():
background(51)
for i, (x, y) in enumerate(history):
fill(i / 2, 255, 255, 128)
circle(x, y, 8 + i / 16)
if history:
history.append(history.popleft())

def mouse_dragged():
history.append((mouse_x, mouse_y))

def key_pressed():
history.clear()

#トゥートprocessing #py5

Last updated 2 years ago