kopia lustrzana https://github.com/villares/sketch-a-day
combinatorics example
rodzic
1d4d91017a
commit
66d494cc85
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 24 KiB |
|
@ -0,0 +1,32 @@
|
||||||
|
"""*
|
||||||
|
* A simple example for class Combination.
|
||||||
|
* fjenett 20090306
|
||||||
|
"""
|
||||||
|
|
||||||
|
add_library('Combinatorics')
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
size(500, 500)
|
||||||
|
background(0)
|
||||||
|
fill(255, 0, 0)
|
||||||
|
textSize(11)
|
||||||
|
|
||||||
|
chars = "0123456789ABCDEF"
|
||||||
|
# Generate the following combinations:
|
||||||
|
# place 16 elements on 3 positions
|
||||||
|
combinations = Combination(len(chars), 3)
|
||||||
|
println(combinations.totalAsInt())
|
||||||
|
|
||||||
|
h = height / (combinations.totalAsInt() + 0.5) * 10.8
|
||||||
|
x, y, w = 0, h, 48
|
||||||
|
while (combinations.hasMore()):
|
||||||
|
c = combinations.next()
|
||||||
|
t = chars[c[0]] + " " + chars[c[1]] + " " + chars[c[2]]
|
||||||
|
text(t, 20 + x, 5 + y)
|
||||||
|
x += w
|
||||||
|
if x > width:
|
||||||
|
x = 0
|
||||||
|
y += h
|
||||||
|
|
||||||
|
saveFrame("sketch_190518a.png")
|
||||||
|
noLoop()
|
Ładowanie…
Reference in New Issue