Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan McLeod warpling

View GitHub Profile
@warpling
warpling / CAMediaTimingFunction.swift
Last active Apr 12, 2020
Better CAMediaTimingFunctions
View CAMediaTimingFunction.swift
//
// CAMediaTimingFunction.swift
import UIKit
extension CAMediaTimingFunction {
static let linear = CAMediaTimingFunction(name: .linear)
static let easeOut = CAMediaTimingFunction(name: .easeOut)
@warpling
warpling / UIBezierPath+AttributedString.swift
Last active Feb 12, 2020
AttributedString to UIBezierPath
View UIBezierPath+AttributedString.swift
extension UIBezierPath {
// Source: https://github.com/aderussell/string-to-CGPathRef/blob/0bd9350dc2100029f3ddb8d9667384841549ecd6/ARCGPathFromString/ARCGPathFromString.m
convenience init(attributedString: NSAttributedString) {
let letters = CGMutablePath()
let line = CTLineCreateWithAttributedString(attributedString as CFAttributedString)
let runArray = CTLineGetGlyphRuns(line)
@warpling
warpling / RegexExample
Created Dec 14, 2019
Help me create a regex that captures the first quoted string and the second quoted string!
View RegexExample
/* This is not important but maybe useful to the regex */
"this.is.a.reverse-dns.thing" = "Blackbox “Stealth” T-Shirt";
/* This is not important but maybe useful to the regex */
"this.is.another.reverse-dns.thing-it.can.have-hyphens" = "I’m a long string.
I also have line breaks and sometimes \"escaped quotation marks\"
📦 Oh and emojis.";
@warpling
warpling / Mento.playground
Last active Aug 1, 2019
Copying Tinder's "mentos" button animation (based on tweet: https://twitter.com/warpling/status/930567671015358464?s=20)
View Mento.playground
//: Playground - noun: a place where people can play
import UIKit
class Mento: UIView {
// The thickness ratio of our mento, 1.0 being a perfect sphere.
let mentoThicknessScale: CGFloat = 0.60
let shape: UIView = {
@warpling
warpling / Moon.h
Last active Dec 20, 2019
🌔 Drawing an accurate moon with UIBezierPath
View Moon.h
//
// Moon.h
// Blackbox
//
// Created by Ryan McLeod on 12/2/14.
// Copyright (c) 2014 Ryan McLeod. All rights reserved.
//
#import <UIKit/UIKit.h>
@warpling
warpling / CAMediaTimingFunction+Extended.swift
Last active Oct 1, 2019
CAMediaTimingFunctions (Swift 4)
View CAMediaTimingFunction+Extended.swift
//
// CAMediaTimingFunctions+Extended.swift
// Geiger
//
// Created by Ryan McLeod on 1/22/19.
// Copyright © 2019 Grow Pixel. All rights reserved.
//
import UIKit
View MathTools.h
// Maps one range onto another
// Example: [-50, 100] to [0, 1.0]
// Example: [0.2, 1.0] to [1.0, 0.0]
#define MAPRANGE(x, inputLow, inputHigh, outputLow, outputHigh) ({\
__typeof(x) __x = (x); \
__typeof(inputLow) __inputLow = (inputLow); \
__typeof(inputHigh) __inputHigh = (inputHigh); \
__typeof(outputLow) __outputLow = (outputLow); \
__typeof(outputHigh) __outputHigh = (outputHigh); \
(((__x - __inputLow) / (__inputHigh - __inputLow)) * (__outputHigh - __outputLow)) + __outputLow; \
View SharkfoodMuteSwitchDetector.h
//
// SharkfoodMuteSwitchDetector.h
//
// Created by Moshe Gottlieb on 6/2/13.
// Copyright (c) 2013 Sharkfood. All rights reserved.
//
#import <Foundation/Foundation.h>
View SKAction+FadeColorAction.h
//
// SKAction+FadeColorAction.h
//
#import <SpriteKit/SpriteKit.h>
@interface SKAction (FadeColorAction)
+ (SKAction*) fadeColorFrom:(SKColor*)fromColor toColor:(SKColor*)toColor duration:(CGFloat)duration;
View MotionOrientation.h
//
// MotionOrientation.h
//
// Originally based on code by Sangwon Park on 5/3/12.
// Copyright (c) 2012 tastyone@gmail.com. All rights reserved.
// Heavily modified by Ryan McLeod on 10/3/14
// Copyright (c) 2014 ryanmcleod@gmail.com. All rights reserved.
#import <CoreMotion/CoreMotion.h>
#import <CoreGraphics/CoreGraphics.h>
You can’t perform that action at this time.