This file contains hidden or 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 hidden or 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 |
This file contains hidden or 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/160078796339/lissajous-grid | |
| # remade from https://twitter.com/fermatslibrary/status/857580490425020416 | |
| def lissajous(a, b, phase, radius): | |
| numSteps = 340 | |
| points = [] | |
| for i in range(numSteps): | |
| angle = 2 * pi * i / numSteps | |
| x = radius * sin(a * angle + phase) | |
| y = -radius * sin(b * angle) |
This file contains hidden or 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 hidden or 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/160364438359/ellipses | |
| def drawEllipses(cx, cy, rx, ry, dx, dy, n, bw=0): | |
| for i in range(n): | |
| fill(bw) | |
| oval(cx - rx, cy - ry, 2 * rx, 2 * ry) | |
| rx -= dx | |
| ry -= dy | |
| bw = 1 - bw |
This file contains hidden or 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 hidden or 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
| from AppKit import NSScreen, NSDeviceSize, NSDeviceResolution | |
| from Quartz import CGDisplayScreenSize | |
| for i, screen in enumerate(NSScreen.screens(), 1): | |
| description = screen.deviceDescription() | |
| pw, ph = description[NSDeviceSize].sizeValue() | |
| rx, ry = description[NSDeviceResolution].sizeValue() | |
| mmw, mmh = CGDisplayScreenSize(description["NSScreenNumber"]) | |
| scaleFactor = screen.backingScaleFactor() | |
| pw *= scaleFactor |
This file contains hidden or 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 hidden or 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
| canvasSize = 500 | |
| numSquares = 25 | |
| squareSize = canvasSize / numSquares | |
| numFrames = 50 | |
| for frame in range(numFrames): | |
| t = frame / numFrames | |
| newPage(canvasSize, canvasSize) | |
| frameDuration(1/25) |