Created
March 14, 2018 10:41
-
-
Save pyk/1093ad2f86590baaa8bceaed8fac46b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CANVAS_HEIGHT = 600 | |
CANVAS_WIDTH = 600 | |
FPS = 15 | |
def setup(): | |
"""Setup the canvas""" | |
# Canvas size | |
size(CANVAS_HEIGHT, CANVAS_WIDTH, P3D) | |
# Draw from center | |
rectMode(CENTER) | |
# Grayscale value | |
stroke(32) | |
strokeWeight(2) | |
# Smooting | |
smooth(8) | |
# Disable fill for the shape | |
noFill() | |
frameRate(FPS) | |
frame_i = 0 | |
MAX_FRAME_COUNT = FPS * 3 # 5 seconds | |
MAX_SQUARE_SIZE = 60 | |
def draw(): | |
# Use global | |
global frame_i | |
# Set background | |
background(255) | |
row_count = 11 | |
column_count = 9 | |
rect_padding = 10 | |
x_point = (width/column_count) - rect_padding | |
y_point = (height/column_count) - rect_padding | |
max_rect_size = 50 | |
for i in range(row_count): | |
for j in range(column_count): | |
for pad in range(0, max_rect_size, rect_padding): | |
rect_size = max_rect_size - frame_i | |
rect(x_point, y_point, rect_size-pad, rect_size-pad) | |
x_point = x_point + (max_rect_size + rect_padding) | |
x_point = (width/column_count) - rect_padding | |
y_point += max_rect_size | |
frame_i += 1 | |
if frame_i % max_rect_size == 0: | |
frame_i = 0 | |
print("frame_i = {}".format(frame_i)) | |
if frameCount == MAX_FRAME_COUNT: noLoop() | |
saveFrame("frame-###.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment