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
extension CIVector | |
{ | |
func toArray() -> [CGFloat] | |
{ | |
var returnArray = [CGFloat]() | |
for i in 0 ..< self.count | |
{ | |
returnArray.append(self.valueAtIndex(i)) | |
} |
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 UIKit | |
typealias RGBA = (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) | |
extension UIColor | |
{ | |
func multiply(value: CGFloat) -> UIColor | |
{ | |
let newRed = getRGBA().red * value | |
let newGreen = getRGBA().green * value |
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
class ThresholdFilter: CIFilter | |
{ | |
var inputImage : CIImage? | |
var threshold: CGFloat = 0.75 | |
let thresholdKernel = CIColorKernel(string: | |
"kernel vec4 thresholdFilter(__sample image, float threshold)" + | |
"{" + | |
" float luma = (image.r * 0.2126) + (image.g * 0.7152) + (image.b * 0.0722);" + | |
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
extension CGPoint | |
{ | |
func distanceTo(point: CGPoint) -> CGFloat | |
{ | |
return hypot(self.x - point.x, self.y - point.y) | |
} | |
} |
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
extension UIBezierPath | |
{ | |
func interpolatePointsWithHermite(interpolationPoints : [CGPoint]) | |
{ | |
let n = interpolationPoints.count - 1 | |
for var ii = 0; ii < n; ++ii | |
{ | |
var currentPoint = interpolationPoints[ii] | |
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
extension CGRect | |
{ | |
func aspectFitInRect(target target: CGRect) -> CGRect | |
{ | |
let scale: CGFloat = | |
{ | |
let scale = target.width / self.width | |
return self.height * scale <= target.height ? | |
scale : |
NewerOlder