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
# Image from https://twitter.com/Berlin_Type/status/1250742042004766730 | |
imagePath = "MEHRINGDAMM.jpeg" | |
w, h = imageSize(imagePath) | |
size(w, h) | |
with savedState(): | |
rotate(0.1) | |
image(imagePath, (0, 0), 0.6) |
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
def translatePoints(points, dx, dy): | |
return [(x + dx, y + dy) for x, y in points] | |
def transposePoints(points): | |
return [(y, x) for x, y in points] | |
def pairs(seq): | |
it = iter(seq) | |
prev = next(it) | |
for item in it: |
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
# Original: | |
# Paul Brown, 'Untitled Computer Assisted Drawing' (1975) | |
# The program was written in Fortran and drawn with Calcomp's drum pen plotter. | |
# https://twitter.com/satoshi_aizawa/status/1218786881631965186 | |
def drawArc(center, radius, startAngle, endAngle): | |
bez = BezierPath() | |
bez.arc(center, radius, startAngle, endAngle, False) | |
drawPath(bez) |
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
# Generate a jellyfish-like pulsating blobby animation. | |
from random import seed | |
def varyPoint(pt, radius, phase): | |
x, y = pt | |
dx = radius * cos(phase) | |
dy = radius * sin(phase) | |
return x + dx, y + dy |
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
# http://dailydrawbot.tumblr.com/post/163234641179/nested-boxes | |
def easeInOutQuad(t): | |
t *= 2 | |
if t < 1: | |
return 0.5 * (t ** 2) | |
else: | |
t = 2 - t | |
return 1 - 0.5 * (t ** 2) |
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
# FREQUENCY = 1 | |
# http://dailydrawbot.tumblr.com/post/135252661206/the-blob | |
# FREQUENCY = 2 | |
# http://dailydrawbot.tumblr.com/post/135266061309/the-blob-2 | |
def centerOval(pt, radiusX, radiusY): | |
x, y = pt | |
oval(x - radiusX, y - radiusY, 2 * radiusX, 2 * radiusY) |
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
# An interpretation of Marcel Duchamp's Rotoreliefs, as seen in his 1926 movie Anemic Cinema: | |
# https://www.youtube.com/watch?v=dXINTf8kXCc | |
def circle(pt, radius): | |
diameter = 2 * radius | |
x, y = pt | |
oval(x - radius, y - radius, diameter, diameter) | |
canvasSize = 500 | |
nFrames = 64 # 64 |
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
# Slightly modified from | |
# https://twitter.com/petrvanblokland/status/860610270410018817 | |
# by Petr van Blokland @petrvanblokland | |
def drawSierpinskiSquare(px, py, w, maxW, maxH): | |
if w < 1: | |
return | |
for x in range(3): | |
for y in range(3): | |
if x == 1 and y == 1: |
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
# http://dailydrawbot.tumblr.com/post/143801148619/square-vs-lozenge | |
def rotatedSquare(x, y, squareSize, angle): | |
offsetSin = squareSize * sin(radians(angle)) | |
save() | |
translate(x + offsetSin, 0) | |
rotate(angle) | |
rect(0, 0, squareSize, squareSize) | |
restore() |
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
# Result: | |
# http://dailydrawbot.tumblr.com/post/150807743869/growing-circles | |
def circle(pt, radius): | |
diameter = 2 * radius | |
x, y = pt | |
oval(x - radius, y - radius, diameter, diameter) | |
nFrames = 50 | |
canvasSize = 500 |