home.social

#tootprocessing — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #tootprocessing, aggregated by home.social.

  1. 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()

  2. """
    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()

  3. # Um exemplo de como exportar um sketch no #py5 (#Processing + #Python) 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')

    #トゥートProcessing #TootProcessing
    # Errata da descrição da imagem: quadradao -> quadrado; outpur.png -> output.png