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.pens.basePen import BasePen | |
| from lib.tools.bezierTools import calculateAngle | |
| from math import sin, cos, radians | |
| class MyPen(BasePen): | |
| def __init__(self, outpen, distance, insice): | |
| BasePen.__init__(self, None) |
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 * | |
| from lib.tools.misc import randomColor | |
| # get the application icon image | |
| icon = NSApp().applicationIconImage() | |
| # get the size | |
| w, h = icon.size() | |
| # make a rect with the size of the image | |
| imageRect = NSMakeRect(0, 0, w, h) | |
| # create a new image with the same size |
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.tools import IntersectGlyphWithLine | |
| # get the current glypyh | |
| g = CurrentGlyph() | |
| # intersect the glyph with a line | |
| # it will return a list with all intersection points | |
| print IntersectGlyphWithLine(g, ((0, 200), (600, 200))) |
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 MarginMover(object): | |
| leftMarginKeyDownTrigger = "y" # change this to make it fit with your hot keys | |
| rightMarginKeyDownTrigger = "u" # change this to make it fit with your hot keys | |
| def __init__(self): | |
| # subscribe to key and mouse events | |
| addObserver(self, "keyDown", "keyDown") |
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
| # create a reusable bezierPath with a triangle | |
| triangle = BezierPath() | |
| triangle.moveTo((0, 0)) | |
| triangle.lineTo((width(), 0)) | |
| triangle.lineTo((width()/2, height())) | |
| triangle.closePath() | |
| # set the maximum recusions | |
| maxSteps = 7 |
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
| """ | |
| Apply any filter on any view. | |
| CIFilter reference: https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIAccordionFoldTransition | |
| """ | |
| from mojo.UI import CurrentSpaceCenter | |
| from AppKit import * |
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 | |
| from AppKit import NSSound, NSURL | |
| path = u"http://soundbible.com/grab.php?id=1995&type=mp3" | |
| url = NSURL.URLWithString_(path) | |
| sound = NSSound.alloc().initWithContentsOfURL_byReference_(url, False) | |
| class SomeMotivation(object): | |
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.UI import OpenGlyphWindow | |
| from mojo.events import addObserver | |
| class BaseGlyphJumper(object): | |
| def __init__(self): | |
| # add observer on key down | |
| addObserver(self, "keyDown", "keyDown") | |
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
| # DrawBot example | |
| import urllib2 | |
| import json | |
| searchTerm = 'DrawBot app is AWESOME' | |
| ## get data from google | |
| fetcher = urllib2.build_opener() | |
| startIndex = "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
| from drawBot import * | |
| from drawBot.ui.drawView import DrawView | |
| from vanilla import * | |
| class DrawBotViewer(object): | |
| def __init__(self): | |
| # create a window | |
| self.w = Window((400, 400), minSize=(200, 200)) |