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
| # test implementation for https://github.com/unified-font-object/ufo-spec/issues/164 | |
| from urllib.parse import unquote | |
| import string | |
| separatorChar = "^" | |
| # TODO: [insert references] |
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
| # boring version of https://twitter.com/beesandbombs/status/1334541858366775298 | |
| # <3 beesandbombs! | |
| canvasSize = 800 | |
| numFrames = 50 | |
| numSquares = 50 | |
| radius = 0.3 * canvasSize | |
| squareSize = 0.2 * canvasSize | |
| for frame in range(numFrames): |
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 fontTools.misc.bezierTools import calcCubicParameters | |
| def cubic(*cubic_points): | |
| (ax, ay), (bx, by), (cx, cy), (dx, dy) = calcCubicParameters(*cubic_points) | |
| def evaluate(t): | |
| ttt = t * t * t | |
| tt = t * t | |
| x = ax * ttt + bx * tt + cx * t + dx | |
| y = ay * ttt + by * tt + cy * t + dy | |
| return x, y |
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
| # 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 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
| 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 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) |
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
| 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
| # 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) |