kopia lustrzana https://github.com/villares/sketch-a-day
31flat
rodzic
747082ef1b
commit
ced5bac28a
|
|
@ -0,0 +1,56 @@
|
|||
import random
|
||||
from bezmerizing import Polyline, Path
|
||||
from flat import document, shape, rgb, rgba, command, path
|
||||
import numpy as np
|
||||
from numpy.random import uniform, normal, choice
|
||||
from scipy.stats import truncnorm
|
||||
|
||||
width, height = 800, 800
|
||||
d = document(width, height, 'mm')
|
||||
page = d.addpage()
|
||||
black = rgb(0, 0, 0)
|
||||
|
||||
current_fill = rgb(255, 255, 255)
|
||||
current_stroke = rgb(0, 0, 0)
|
||||
|
||||
def fill(r, *args):
|
||||
global current_fill
|
||||
if len(args) == 0:
|
||||
g = b = r
|
||||
else:
|
||||
g, b = args
|
||||
current_fill = rgb(r,g, b)
|
||||
|
||||
def background(r, *args):
|
||||
if len(args) == 0:
|
||||
g = b = r
|
||||
else:
|
||||
g, b = args
|
||||
fig = shape().fill(rgb(r, g, b)).nostroke()
|
||||
page.place(fig.rectangle(0, 0, width, height))
|
||||
|
||||
def ellipse(x, y, w, h):
|
||||
fig = shape().fill(current_fill).stroke(current_stroke)
|
||||
page.place(fig.ellipse(x, y, w / 2, h / 2))
|
||||
|
||||
|
||||
def rect(x, y, w, h):
|
||||
fig = shape().fill(current_fill).stroke(current_stroke)
|
||||
page.place(fig.rectangle(x, y, w, h))
|
||||
|
||||
|
||||
def triangle(xa, ya, xb, yb, xc, yc):
|
||||
fig = shape().fill(current_fill).stroke(current_stroke)
|
||||
page.place(fig.polygon(Polyline([(xa, ya), (xb, yb), (xc, yc)])))
|
||||
|
||||
|
||||
# def size(w, h):
|
||||
# # doesn't work
|
||||
# global width, height, d
|
||||
# width, height = w, h
|
||||
# d = document(width, height, 'mm')
|
||||
|
||||
|
||||
def flatten(t):
|
||||
from itertools import chain
|
||||
return list(chain(*t))
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
from random import sample
|
||||
from bezmerizing import Polyline, Path
|
||||
#from flat import document, shape, rgb, rgba, command, path
|
||||
from flat_processing import *
|
||||
|
||||
from random import choice
|
||||
from random import randint
|
||||
|
||||
def ensamble(ex, ey, order):
|
||||
for _ in range(order):
|
||||
order, spacing, side = randint(3, 5), 14, 7
|
||||
x, y = randint(-5, 4) * side, randint(-5, 4) * side
|
||||
grid(ex+x, ey+y, order, spacing, choice(gliphs), side)
|
||||
|
||||
|
||||
def grid(x, y, order, spacing, function, *args):
|
||||
xo, yo = (x - order * spacing / 2, y - order * spacing / 2)
|
||||
for i in range(order):
|
||||
gx = spacing/2 + i * spacing
|
||||
for j in range(order):
|
||||
gy = spacing/2 + j * spacing
|
||||
function(xo + gx, yo + gy, *args)
|
||||
|
||||
gliphs = [lambda x, y, s: rect(x, y, s, s),
|
||||
lambda x, y, s: ellipse(x, y, s, s),
|
||||
lambda x, y, s: triangle(x - s, y, x - s, y + s, x, y + s),
|
||||
lambda x, y, s: triangle(x + s, y, x + s, y - s, x, y - s),
|
||||
]
|
||||
|
||||
|
||||
fill(0, 0, 200)
|
||||
grid(400, 400., 5, 150, ensamble, 5) # ensamble of 5 , on grid also order=5
|
||||
# grid(width/4.*3, height/2., 4, 150, ensamble, 5) # ensamble of 5 , on grid also order=5
|
||||
|
||||
|
||||
# background(0, 200, 0)
|
||||
|
||||
|
||||
d.pdf("test2.pdf")
|
||||
page.svg('test2.svg')
|
||||
#page.image(ppi=92, kind="rgb").png("sketch_2020_08_29.png")
|
||||
Plik diff jest za duży
Load Diff
|
Po Szerokość: | Wysokość: | Rozmiar: 270 KiB |
Plik diff jest za duży
Load Diff
|
|
@ -21,6 +21,13 @@
|
|||
## 2020
|
||||
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[sketch_2020_08_31flat](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_08_31flat) [[Python + flat](https://xxyxyz.org/flat)]
|
||||
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
|
@ -32,6 +39,7 @@
|
|||

|
||||
|
||||
[sketch_2020_08_29flat](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_08_29flat)[[Python + flat](https://xxyxyz.org/flat)]
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue