kopia lustrzana https://github.com/villares/sketch-a-day
clean up
rodzic
2f95540488
commit
fca9282f10
|
|
@ -23,7 +23,6 @@ COLORS = [color(0), color(0), color(0),
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
size(600, 600, P2D)
|
size(600, 600, P2D)
|
||||||
colorMode(HSB)
|
|
||||||
rectMode(CENTER)
|
rectMode(CENTER)
|
||||||
|
|
||||||
A.position(40, height - 70)
|
A.position(40, height - 70)
|
||||||
|
|
@ -47,17 +46,16 @@ def draw():
|
||||||
x = int(random(width - tam) / c) * c
|
x = int(random(width - tam) / c) * c
|
||||||
y = int(random(height - tam) / c) * c
|
y = int(random(height - tam) / c) * c
|
||||||
stroke(rnd_choice(COLORS))
|
stroke(rnd_choice(COLORS))
|
||||||
noFill() # fill(rnd_choice(COLORS), 100)
|
|
||||||
strokeWeight(int(random(1, 3)))
|
strokeWeight(int(random(1, 3)))
|
||||||
random_a = rnd_choice(range(1, a + 1))
|
random_a = rnd_choice(range(1, a + 1))
|
||||||
grid(x, y, random_a, b, c, rnd_choice(SHAPES))
|
grid(x, y, random_a, b, c, rnd_choice(SHAPES))
|
||||||
|
|
||||||
# uncomment next lines to export GIF
|
# uncomment next lines to export GIF
|
||||||
if not frameCount % 30:
|
# if not frameCount % 30:
|
||||||
gif_export(GifMaker,
|
# gif_export(GifMaker,
|
||||||
frames=2000,
|
# frames=2000,
|
||||||
delay=500,
|
# delay=500,
|
||||||
filename=SKETCH_NAME)
|
# filename=SKETCH_NAME)
|
||||||
|
|
||||||
# Draws sliders and checks for mouse dragging or keystrokes
|
# Draws sliders and checks for mouse dragging or keystrokes
|
||||||
Slider.update_all()
|
Slider.update_all()
|
||||||
|
|
@ -70,6 +68,3 @@ def grid(x, y, num, size_, space, func):
|
||||||
def rnd_choice(collection):
|
def rnd_choice(collection):
|
||||||
i = int(random(len(collection)))
|
i = int(random(len(collection)))
|
||||||
return collection[i]
|
return collection[i]
|
||||||
|
|
||||||
# def keyPressed():
|
|
||||||
# saveFrame(SKETCH_NAME + '_###.gif')
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,11 @@ ported to Processing 3 by 01010101 (https://github.com/01010101)
|
||||||
Download the library from https://github.com/01010101/GifAnimation/archive/master.zip
|
Download the library from https://github.com/01010101/GifAnimation/archive/master.zip
|
||||||
This helper was inspired by an example by Art Simon https://github.com/APCSPrinciples/AnimatedGIF/
|
This helper was inspired by an example by Art Simon https://github.com/APCSPrinciples/AnimatedGIF/
|
||||||
|
|
||||||
Put add_library('gifAnimation') at the start of your sketch
|
Put at the start of your sketch:
|
||||||
and add gif_export(GifMaker) at the end of draw()
|
add_library('gifAnimation')
|
||||||
|
from gif_exporter import gif_export
|
||||||
|
and at the end of draw():
|
||||||
|
gif_export(GifMaker)
|
||||||
"""
|
"""
|
||||||
def gif_export(GifMaker, # gets a reference to the library
|
def gif_export(GifMaker, # gets a reference to the library
|
||||||
filename="exported", # .gif will be added
|
filename="exported", # .gif will be added
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,6 @@ SHAPES = [my_ellipse,
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
size(600, 600, P2D)
|
size(600, 600, P2D)
|
||||||
colorMode(HSB)
|
|
||||||
rectMode(CENTER)
|
|
||||||
|
|
||||||
A.position(40, height - 70)
|
A.position(40, height - 70)
|
||||||
B.position(40, height - 30)
|
B.position(40, height - 30)
|
||||||
C.position(width - 140, height - 70)
|
C.position(width - 140, height - 70)
|
||||||
|
|
@ -28,8 +25,7 @@ def setup():
|
||||||
|
|
||||||
def draw():
|
def draw():
|
||||||
background(200)
|
background(200)
|
||||||
noFill()
|
|
||||||
|
|
||||||
a = int(A.val) # number of elements
|
a = int(A.val) # number of elements
|
||||||
b = C.val * B.val / 100 # size of el ements (B.val % of spacing!)
|
b = C.val * B.val / 100 # size of el ements (B.val % of spacing!)
|
||||||
c = int(C.val) # spacing between elements
|
c = int(C.val) # spacing between elements
|
||||||
|
|
@ -64,6 +60,3 @@ def grid(x, y, num, size_, space, func):
|
||||||
def rnd_choice(collection):
|
def rnd_choice(collection):
|
||||||
i = int(random(len(collection)))
|
i = int(random(len(collection)))
|
||||||
return collection[i]
|
return collection[i]
|
||||||
|
|
||||||
# def keyPressed():
|
|
||||||
# saveFrame(SKETCH_NAME + '_###.gif')
|
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue