partial transcription of Robothon 2012 presentation
© Tal Leming
Robofab was built as a scripting library. It was not built to be fast, it was built to be comfortable.
| # http://forum.drawbot.com/topic/148/voronoi-fun/2 | |
| import random | |
| import math | |
| def generate_voronoi_diagram(imgx, imgy, num_cells): | |
| nx = [] | |
| ny = [] | |
| nr = [] |
| from vanilla import * | |
| from AppKit import NSDragOperationCopy | |
| genericListPboardType = "genericListPboardType" | |
| class DragAndDropListItemsDemo: | |
| weekdays = { | |
| 'Mon' : [], | |
| 'Tue' : [], |
| '''animate individual characters in a variable font''' | |
| fontName = 'Skia' | |
| txt = 'variablefonts' | |
| # steps between min/max range | |
| steps = 12 | |
| # variable font range | |
| variations = listFontVariations(fontName) |
| from vanilla import HUDFloatingWindow, SquareButton, CheckBox | |
| from defconAppKit.windows.baseWindow import BaseWindowController | |
| from mojo import drawingTools as ctx | |
| from mojo.events import addObserver, removeObserver | |
| from mojo.UI import UpdateCurrentGlyphView, getDefault | |
| class LockLayerWidthsDialog(BaseWindowController): | |
| key = 'com.hipertipo.lockLayerWidths' | |
| verbose = True |
| from vanilla import Window | |
| from lib.UI.stepper import Stepper, EditStepper, SliderEditStepper | |
| class StepperDemo(object): | |
| def __init__(self): | |
| self.w = Window((300, 100), "Stepper Demo") | |
| self.w.stepper = Stepper((10, 10, -10, 24), value=100) | |
| self.w.open() |
partial transcription of Robothon 2012 presentation
© Tal Leming
Robofab was built as a scripting library. It was not built to be fast, it was built to be comfortable.
| # Differences between RoboFab and fontParts APIs | |
| ==================================================================================================== | |
| Robofab fontParts | |
| ==================================================================================================== | |
| OpenFont(ufoPath, showUI=False) OpenFont(ufoPath, showInterface=False) | |
| ---------------------------------------------------------------------------------------------------- | |
| font.guides font.guidelines | |
| ---------------------------------------------------------------------------------------------------- | |
| font.removeGuide font.removeGuideline |
| import extractor | |
| import defcon | |
| ttf_path = u"/Library/Fonts/Georgia.ttf" | |
| ufo_path = u"/Users/gferreira/Documents/test.ufo" | |
| ufo = defcon.Font() | |
| extractor.extractUFO(ttf_path, ufo) | |
| from lib.tools.bezierTools import curveConverter |
| # fontParts object map | |
| from grapefruit import Color | |
| from collections import OrderedDict | |
| class FontPartsMap(object): | |
| colors = OrderedDict([ | |
| ('font' , (80, 0.50, 0.49)), | |
| ('font_lib' , (136, 0.42, 0.55)), |
| @namespace url(http://www.w3.org/1999/xhtml); | |
| @-moz-document url-prefix("http://www.microsoft.com/typography/otspec/"), url-prefix("https://www.microsoft.com/typography/otspec/") { | |
| body { width: 40em; padding: 1em 4em; } | |
| p { font-size: 16px; line-height: 1.4em; margin: 1em 0; } | |
| code, pre { font-family: "Menlo"; } | |
| td { padding: 1em; } | |
| table.gray { width: 40em; } | |