Skip to content

Instantly share code, notes, and snippets.

@typemytype
typemytype / install_liquid_c_on_Monterey
Created January 22, 2022 18:33
command to install liquid-c on Monterey
gem install liquid-c -- --with-cflags="-Wno-compound-token-split-by-macro"
import vanilla
import merz
class Demo:
def __init__(self):
# setup window
self.w = vanilla.Window((400, 400), minSize=(150, 150))
import AppKit
import webbrowser
import urllib
import json
import os
import ssl
import vanilla
from mojo.extensions import ExtensionBundle
def lerp(value1, value2, factor):
return value1 + (value2 - value1) * factor
size(400, 400)
R = (sqrt(5) - 1) / 2
def F(x1, y1, r, s, t, n):
# get the current glyph
glyph = CurrentGlyph()
# get the point pen
pointPen = glyph.getPointPen()
# loop over all contours
# convert the glyph to a list first
# so we can remove the contour and alter the glyph
for contour in list(glyph):
# get all the points
points = contour.points
x, y = 0, 0
w = h = 200
circles = 3
offset = 20
thickness = 26
color1 = (0, 1, 1)
color2 = (1, .5, 0)
color3 = (1, 0, 1)
color4 = (1, 1, 0)
from AppKit import *
t = """Yeah! A designspace is file that contains the plans for an interpolation system for a typeface. It describes how the source fonts relate and how they should interpolate. It defines the dimensions in which the typeface developes, for instance “weight”, “width”, or other things. A designspace also stores information about the instances, specific locations in the designspace that are interesting and what they need to be called. Designspaces can be used to build variable fonts, but you can also use them to generate fixed UFOs. This text is an introduction to designspace construction. It does not go into detail how to design letterforms for interpolation, or things like family planning. That is for other chapters. To avoid getting tangled in typographic terminology, the dimensions in this text are named after colors."""
synth = NSSpeechSynthesizer.alloc().initWithVoice_("com.apple.speech.synthesis.voice.Whisper")
synth.startSpeakingString_(t)
from math import sqrt
class AnimationFrame(object):
def __init__(self, index, factor):
self._index = index
self._factor = factor
def index(self):
return self._index
@typemytype
typemytype / speechToCommand.py
Created July 18, 2020 21:40
speech to command
import AppKit
import vanilla
from lib.tools.debugTools import ClassNameIncrementer
class SpeechRecognizerDelegate(AppKit.NSObject, metaclass=ClassNameIncrementer):
def speechRecognizer_didRecognizeCommand_(self, recognizer, command):
import os
import vanilla
def showHide(sender):
value = "true"
if "Hide" in sender.getNSButton().title():
value = "false"
os.system(f"defaults write com.apple.finder CreateDesktop {value} && killall Finder")