kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
7d5d9a5d31
commit
7412bcb229
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.3 MiB |
|
@ -0,0 +1,61 @@
|
|||
"""Grid study"""
|
||||
|
||||
from random import choice
|
||||
|
||||
def setup():
|
||||
size(500, 500)
|
||||
rectMode(CENTER)
|
||||
colorMode(HSB)
|
||||
create_grids()
|
||||
|
||||
def create_grids():
|
||||
global shapes
|
||||
shapes = []
|
||||
for i in range(10):
|
||||
d = int(random(4, 11))
|
||||
sp = 25
|
||||
x = int(random(-7, 8)) * sp
|
||||
y = int(random(-7, 8)) * sp
|
||||
si = random(15, 35)
|
||||
sh = choice((ELLIPSE, RECT))
|
||||
shapes.extend(grid(pos=(x, y),
|
||||
dims=(d, d),
|
||||
space=sp,
|
||||
elem=(create_element, sh, si))
|
||||
)
|
||||
def draw():
|
||||
background(0)
|
||||
translate(width / 2., height / 2.)
|
||||
|
||||
for s in shapes:
|
||||
shape(s)
|
||||
|
||||
def grid(pos, dims, space, elem):
|
||||
gx, gy = pos
|
||||
col_num, row_num = dims
|
||||
func, args = elem[0], elem[1:]
|
||||
result = []
|
||||
half_w = col_num * space / 2.
|
||||
half_h = row_num * space / 2.
|
||||
for ix in range(col_num):
|
||||
x = gx + ix * space + space / 2. - half_w
|
||||
for iy in range(row_num):
|
||||
y = gy + iy * space + space / 2. - half_h
|
||||
noFill()
|
||||
stroke(color_rule(ix, iy, row_num))
|
||||
strokeWeight(3)
|
||||
result.append(func(x, y, *args))
|
||||
return result
|
||||
|
||||
def color_rule(ix, iy, row_num):
|
||||
return color(row_num * 24 - (ix + iy) % 3 * 32 , 200, 200, 100)
|
||||
|
||||
|
||||
def create_element(x, y, *args):
|
||||
return createShape(args[0], x, y, args[1], args[1])
|
||||
|
||||
def keyPressed():
|
||||
if key == "s":
|
||||
saveFrame("####.png")
|
||||
if key == " ":
|
||||
create_grids()
|
|
@ -20,6 +20,12 @@ You may also support my artistic work, open teaching resources and research with
|
|||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_190729a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190729a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_190728a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190728a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
|
|
Ładowanie…
Reference in New Issue