Skip to content

Instantly share code, notes, and snippets.

View westerlund's full-sized avatar

Simon Westerlund westerlund

View GitHub Profile
@westerlund
westerlund / RubberBand.md
Created May 25, 2017 14:25 — forked from originell/RubberBand.md
This is a straight copy of – to avoid this ever going dark http://squareb.wordpress.com/2013/01/06/31/

Analysis of Apple’s rubber band scrolling

January 6, 2013

I recently saw a post on Twitter from @chpwn that described the alogorithm that Apple uses for its “rubber band” or “bungee” scrolling.

b = (1.0 – (1.0 / ((x * c / d) + 1.0))) * d
@westerlund
westerlund / cocoa-drawing.swift
Last active November 29, 2015 10:33 — forked from randomsequence/cocoa-drawing.swift
Drawing images with CGContext and NSGraphicsContext in Swift
//: Playground - noun: a place where people can play
import Cocoa
let bounds = CGRectMake(0, 0, 100, 100);
func DrawImageInCGContext(size: CGSize, drawFunc: (context: CGContextRef, rect: CGRect) -> Void) -> NSImage? {
let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue)
if let context = CGBitmapContextCreate(
//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
//
import UIKit