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
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 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
# Based on a work by Herbert W. Kapitzki | |
# https://twitter.com/Lett_Arc/status/1369712193063780352 | |
# from fontTools.misc.vector import Vector | |
from fontTools.misc.arrayTools import Vector | |
def pairs(iterable): | |
it = iter(iterable) | |
first = next(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
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 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 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 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 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 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
# This borrows heavily from: | |
# http://jsfiddle.net/Rebug/5uLr7s6o/ | |
# | |
# Resulting gif: | |
# http://dailydrawbot.tumblr.com/post/134989689114/an-archimedean-spherical-spiral | |
import math | |
import colorsys | |
def circle(pt, radius): |
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/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) |