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
| import AppKit | |
| import CoreText | |
| x, y, w, h = 100, 100, 300, 500 | |
| f = FormattedString() | |
| f.fontSize(12) | |
| f += "hello" | |
| f.fill(1, 0, 0) |
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
| import AppKit | |
| def appendHTML(self, html): | |
| htmlString = AppKit.NSString.stringWithString_(html) | |
| txt, _, _ = AppKit.NSAttributedString.alloc().initWithData_options_documentAttributes_error_( | |
| htmlString.dataUsingEncoding_(AppKit.NSUTF8StringEncoding), | |
| {AppKit.NSDocumentTypeDocumentAttribute: AppKit.NSHTMLTextDocumentType, AppKit.NSCharacterEncodingDocumentAttribute: AppKit.NSUTF8StringEncoding}, | |
| None, None) | |
| self._attributedString.appendAttributedString_(txt) |
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
| # runs in drawbot | |
| # shows all names of | |
| import AppKit | |
| names = [n for n in dir(AppKit) if n.startswith("NSImageName")] | |
| for name in names: | |
| im = AppKit.NSImage.imageNamed_(getattr(AppKit, name)) | |
| if im is None: | |
| print(name) |
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 mojo.events import addObserver | |
| class SuperZoom(object): | |
| def __init__(self): | |
| addObserver(self, "keyDown", "keyDown") | |
| def keyDown(self, notification): | |
| view = notification["view"] |
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 fontMath.mathGlyph import MathGlyph, _expandImage | |
| def translate(self, pt): | |
| x, y = pt | |
| copiedGlyph = self.copyWithoutMathSubObjects() | |
| # width | |
| copiedGlyph.width = self.width + x | |
| # height | |
| copiedGlyph.height = self.height + y | |
| # contours |
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
| import AppKit | |
| layoutAttribute = { | |
| "left": AppKit.NSLayoutAttributeLeft, | |
| "right": AppKit.NSLayoutAttributeRight, | |
| "top": AppKit.NSLayoutAttributeTop, | |
| "bottom": AppKit.NSLayoutAttributeBottom, | |
| "leading": AppKit.NSLayoutAttributeLeading, | |
| "trailing": AppKit.NSLayoutAttributeTrailing, | |
| "width": AppKit.NSLayoutAttributeWidth, |
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
| import defcon | |
| glyph = defcon.Glyph() | |
| pen = glyph.getPen() | |
| pen.moveTo((76, 102)) | |
| pen.qCurveTo( | |
| (168, 94), |
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 vanilla import * | |
| class TestConstraints: | |
| def __init__(self): | |
| self.w = Window((400, 400), "AutoLayout", minSize=(200, 200)) | |
| self.w.info = TextBox("auto", "auto layout:", alignment="right") | |
| self.w.input = EditText("auto") |
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
| import pyclipper | |
| from booleanOperations.booleanOperationManager import _addContour, _operationMap, _fillTypeMap | |
| def clipExecute(subjectContours, clipContours, operation, subjectFillType="nonZero", | |
| clipFillType="nonZero", addBoundsTest=True): | |
| pc = pyclipper.Pyclipper() | |
| for i, subjectContour in enumerate(subjectContours): | |
| _addContour(clipperPath=pc, contour=subjectContour, fillType=pyclipper.PT_SUBJECT, contourCount=i) |