sketch_2023_03_31 #Processing #Python #py5 #トゥートProcessing #TootProcessing #generativeArt #creativeCoding
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
#Processing #Python #py5 #genuary #genuary31 #トゥートProcessing
# https://iamkate.com/data/12-bit-rainbow/
palette = (
'#817', '#a35', '#c66', '#e94',
'#ed0', '#9d5', '#4d8', '#2cb',
'#0bc', '#09c', '#36b', '#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
#Processing #Python #py5 imported mode #genuary #genuary30 #トゥートProcessing
# Kate Rose Morley's palette
# https://iamkate.com/data/12-bit-rainbow/
from itertools import product
palette = (
'#817', '#a35', '#c66', '#e94',
'#ed0', '#9d5', '#4d8', '#2cb',
'#0bc', '#09c', '#36b', '#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
#sketch_2022_01_25 #Processing #トゥートProcessing #Python #py5 #genuary #genuary25
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)
#fill(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
"""
sketch_2022_01_17 #genuary #genuary17 #Python #Processing
Code for #py5 (py5coding.org) imported mode
Recursive grid - I'm always grateful for Takao Shunsuke's inspiration.
#トゥートProcessing #TootProcessing
"""
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
# Um exemplo de como exportar um sketch no #py5 (#Processing + #Python) em alta resolução:
# Usando py5 (https://py5coding.org) com "imported mode", via plugin no Thonny IDE https://github.com/tabreturn/thonny-py5mode
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
# Abreviated version from https://github.com/villares
#トゥートProcessing #py5
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()