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
module.exports = function(context, req) { | |
context.log('push data:', req.body); | |
var str = req.body; | |
var results = str.split("&"); | |
var slackText = getParam(results, "text").replace(/\+/g, " ").replace(/mytodo/g, ""); | |
var userName = getParam(results, "user_name").replace(/\+/g, " "); | |
context.log(getParam(results, "token")); | |
context.log(getParam(results, "channel_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
import Foundation | |
import UIKit | |
public class DoodleCanvas : UIImageView { | |
} |
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 | |
import UIKit | |
public class DoodleCanvas : UIImageView { | |
let pi = CGFloat(Double.pi) | |
let forceSensitivity: CGFloat = 4.0 | |
var pencilTexture = UIColor(patternImage: UIImage(named: "PencilTexture")!) | |
let defaultLineWidth : CGFloat = 6 |
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 public func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { | |
guard let touch = touches.first else { | |
return | |
} | |
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0.0) | |
let context = UIGraphicsGetCurrentContext() | |
image?.draw(in: bounds) | |
var touches = [UITouch]() |
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
public func setup () { | |
resetDoodleRect() | |
lastTouchTimestamp = 0 | |
if #available(iOS 10.0, *) { | |
trackTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true, block: { | |
timer in | |
let now = Date().timeIntervalSince1970 |
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 drawDoodlingRect(context: CGContext?) { | |
let inset = 5 | |
markerColor.setStroke() | |
context!.setLineWidth(1.0) | |
context!.setLineCap(.round) | |
UIColor.clear.setFill() | |
ocrImageRect = CGRect(x: minX - inset, y: minY - inset, width: (maxX-minX) + inset*2, height: (maxY-minY) + 2*inset) | |
context!.addRect(ocrImageRect!) |
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 resetDoodleRect() { | |
minX = Int(self.frame.width) | |
minY = Int(self.frame.height) | |
maxX = 0 | |
maxY = 0 | |
lastTouchTimestamp = 0 | |
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 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
func fetchOCRText () { | |
let manager = CognitiveServices() | |
let ocrImage = image!.crop(rect: ocrImageRect!) | |
manager.retrieveTextOnImage(ocrImage) { | |
operationURL, error in | |
if #available(iOS 10.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
public func retrieveTextOnImage(_ image: UIImage, completion: @escaping (String?, NSError?) -> ()) { | |
assert(CognitiveServicesComputerVisionAPIKey.characters.count > 0, | |
"Please set the value of the API key variable (CognitiveServicesVisualFeaturesAPIKey) before attempting to use the application.") | |
var urlString = CognitiveServicesConfiguration.HandwrittenOcrURL | |
urlString += "?\(CognitiveServicesHTTPParameters.Handwriting)=true" | |
let url = URL(string: urlString) | |
print("calling the following URL: \(String(describing: url))") |
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
//at the very top of the class | |
import Foundation | |
import UIKit | |
import PlaygroundSupport | |
public class MyDoodleCanvas { | |
... | |
} | |
//after the class implementation |
OlderNewer