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 Cocoa | |
| // Only needed until we have class variables | |
| var __SwizzleSayHello = { (who:String) -> String in | |
| return "Hello, \(who)" | |
| } | |
| class Swizzle { | |
| //Only needed until we have class variables | |
| class var _sayHello : (String)->String { get{ return __SwizzleSayHello } set (swizzle) {__SwizzleSayHello = swizzle} } |
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 Foundation | |
| class CubicCurveUtils { | |
| /** | |
| * Returns Y given X on a CubicPath segment | |
| * PARAM: p0: prev end point | |
| * PARAM: c0: controllpoint 1 for prev end point | |
| * PARAM: c1: control point 2 for end point | |
| * PARAM: p1: end point | |
| */ |
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
| // | |
| // Point.swift | |
| // SwiftGenericGeometry | |
| // | |
| // Created by Jonathan Wight on 3/29/16. | |
| // Copyright © 2016 schwa.io. All rights reserved. | |
| // | |
| public protocol PointType: Equatable { | |
| associatedtype Scalar: ScalarType |
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
| protocol Thing { | |
| typealias argType | |
| func doit(val:argType) -> argType | |
| } | |
| class IntThing : Thing { | |
| func doit(val: Int) -> Int { | |
| return val + 1 | |
| } | |
| } |
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
| /** | |
| * | |
| */ | |
| func zoomBackAndForthAnimTest(){ | |
| //Setup window 200x300,white | |
| let winRect = CGRect(0,0,200,300) | |
| window.size = winRect.size | |
| window.contentView = InteractiveView2() | |
| window.title = "" |
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
| override func pressureChange(with event: NSEvent) { | |
| /*A value from 0.0 through 1.0 indicating the degree of pressure applied to an appropriate input device.*/ | |
| Swift.print("event.pressure: " + "\(event.pressure)") | |
| /*The pressure behavior and progression for an event of type pressure.*/ | |
| switch event.pressureBehavior {//<-NSPressureBehavior | |
| case .primaryAccelerator: | |
| Swift.print("primaryAccelerator") | |
| case .primaryDeepClick: |
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
| var prevStage = 0 | |
| override func pressureChange(with event: NSEvent) { | |
| let curStage:Int = event.stage | |
| if event.pressureBehavior == NSPressureBehavior.primaryDeepClick,prevStage != curStage { | |
| switch (curStage,prevStage){ | |
| case (0,1): | |
| Swift.print("from idle to clickStage") | |
| case (1,0): | |
| Swift.print("from clickStage to idle") | |
| case (1,2): |
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
| /** | |
| * NOTE: calculates the entire range of the stage pressures so from stage 0 to 1 the pressure goes from 0 to 0.5 and from stage 1 to 2 the linear pressure goes from 0.5 to 1 this makes it easier to scale things in a linear fashion from 0 to 1 in the entire stage range | |
| */ | |
| var linearPressure:CGFloat{ | |
| if event.stage == 0 { | |
| return 0 | |
| }else if event.stage == 1{ | |
| return pressure / 2 | |
| }else /*if stage == 2*/ { | |
| return 0.5 + (pressure / 2) |
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
| NSUserNotificationCenter.default.delegate = self//add this in the applicationDidFinishLaunching call | |
| extension AppDelegate:NSUserNotificationCenterDelegate{ | |
| func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool { | |
| return true | |
| } | |
| } |
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 Cocoa | |
| @testable import Utils | |
| @testable import Element | |
| @NSApplicationMain | |
| class AppDelegate:NSObject, NSApplicationDelegate { | |
| weak var window:NSWindow! | |
| var win:NSWindow?/*<--The window must be a class variable, local variables doesn't work*/ | |
| var menu:Menu? | |