This file contains 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 SwiftUI | |
import UIKit | |
struct NoClipText: UIViewRepresentable { | |
typealias UIViewType = NoClipLabel | |
let text: String | |
let font: UIFont | |
let clipExtension: EdgeSizes |
This file contains 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
A list of sketch scripts |
This file contains 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 SceneKit | |
class CircleNode: SCNNode { | |
init(detail: Int = 500) { | |
super.init() | |
let elements = self.generateElements(detail: detail) |
This file contains 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
// Example | |
// Thanks to Aby for the idea / inital code nippet | |
// https://sketchplugins.com/d/201-inserting-a-layer-into-a-document-with-sketch-ux/7 | |
context.document.actionsController().actionForID("MSShowReplaceColorSheetAction").performAction(nil); | |
// there may be cases where you need to pass in a reference to an object in order for the for the action to work | |
// here is how you can insert a symbol instance programmatically | |
// for now let's assume you have a symbol master selected |
This file contains 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
class Names: SimplePublisher { | |
typealias Output = Result<String, Error> | |
var subscriptions = [SimpleSubscription<Output, Failure>]() | |
let names = ["Alice", "Bob", "Claris", "Doug"] | |
shoutName() { | |
if let name = names.randomElement() { | |
publish(.success(name)) | |
} else { | |
assertionFailure("There are def some names in there...") |
This file contains 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
final class LoopedVideoPlayerView: UIView { | |
fileprivate var videoURL: URL? | |
fileprivate var queuePlayer: AVQueuePlayer? | |
fileprivate var playerLayer: AVPlayerLayer? | |
fileprivate var playbackLooper: AVPlayerLooper? | |
func prepareVideo(_ videoURL: URL) { | |
let playerItem = AVPlayerItem(url: videoURL) |
This file contains 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
extension UIFont { | |
// The `rawValue` MUST match the filename (without extension) | |
public enum Graphik: String, FontCacheDescriptor { | |
case regular = "GraphikAltWeb-Regular" | |
case medium = "GraphikAltWeb-Medium" | |
case regularItalic = "GraphikAltWeb-RegularItalic" | |
case mediumItalic = "GraphikAltWeb-MediumItalic" | |
} | |
This file contains 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
extension UIFont { | |
/** | |
Will return the best font conforming to the descriptor which will fit in the provided bounds. | |
*/ | |
static func bestFittingFontSize(for text: String, in bounds: CGRect, fontDescriptor: UIFontDescriptor, additionalAttributes: [NSAttributedStringKey: Any]? = nil) -> CGFloat { | |
let constrainingDimension = min(bounds.width, bounds.height) | |
let properBounds = CGRect(origin: .zero, size: bounds.size) | |
var attributes = additionalAttributes ?? [:] | |
This file contains 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
/// Creates a sequence of tuple-3s built out of three underlying sequences. | |
/// Based on Zip2Seqence from the Swift Standard Library. | |
/// https://github.com/apple/swift/blob/9361a6b66f6f8351e89c090f604d7e1f42e2a045/stdlib/public/core/Zip.swift | |
/// | |
/// - Parameters: | |
/// - sequence1: The first sequence or collection to zip. | |
/// - sequence2: The second sequence or collection to zip. | |
/// - sequence3: The third sequence or collection to zip. | |
/// - Returns: A sequence of tuple triples, where the elements of each triplet are | |
/// corresponding elements of `sequence1`, `sequence2`, and `sequence3`. |
This file contains 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
// | |
// Created by はるふ on 2017/12/11. | |
// Copyright © 2017年 ha1f. All rights reserved. | |
// | |
import Foundation | |
import CoreImage | |
import AVFoundation | |
extension CIFilter { |
NewerOlder