usainboltz.examples.mondrian¶
Mondrian paintings generation.
Generate a Mondrian painting from a simple grammar.
>>> from usainboltz.examples.mondrian import *
>>> grammar
{
canvas : Product(window, window, window, window),
window : Union(Product(red, z),
Product(blue, z),
Product(yellow, z),
Product(white, z),
Product(black, z),
Product(window, window, window, window))
}
The image is generated in svg format using the builders mechanism.
>>> sizes = {square: (20, 30), blue: (2, 4), red: (2, 4), yellow: (2, 4), black: (2, 4)}
>>> res = generator.sample(sizes)
>>> print(res.obj) # doctest: +ELLIPSIS
<svg width="1440" height="1440" xmlns="http://www.w3.org/2000/svg">
...
Functions
canvas_builder (windows) |
|
color_builder (t) |
|
pack_translate_scale (t) |
|
quad_builder (windows) |
-
usainboltz.examples.mondrian.
canvas_builder
(windows)¶
-
usainboltz.examples.mondrian.
color_builder
(t)¶
-
usainboltz.examples.mondrian.
pack_translate_scale
(t)¶
-
usainboltz.examples.mondrian.
quad_builder
(windows)¶