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
// This works. | |
kernel vec4 simpleFilter(sampler p) | |
{ | |
vec2 dc = destCoord(); | |
return sample(p, samplerTransform(p, dc)); | |
} | |
// This does not. It produces [0, 0, 0, 255] for the first 255 pixels and then [0, 0, 0, 0] thereafter. | |
kernel vec4 simpleFilter(sampler p) | |
{ |
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
// Improved Noise - Copyright 2002 Ken Perlin. | |
// Adapted and updated for iOS by Joshua Sullivan, 2016.01.12 | |
// Apply the function 6t^5 - 15t^4 + 10t^3 | |
float fade(float t) | |
{ | |
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); | |
} | |
// I'm keeping this around for reference. |
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 TouchCaptureControl: UIControl { | |
var value: CIVector = CIVector(x: 0.0, y: 0.0) | |
@IBInspectable var horizontalMinimumValue: CGFloat = 0.0 | |
@IBInspectable var horizontalMaximumValue: CGFloat = 1.0 | |
@IBInspectable var verticalMinimumValue: CGFloat = 0.0 | |
@IBInspectable var verticalMaximumValue: CGFloat = 1.0 | |
@IBInspectable var flipHorizontalAxis: Bool = false | |
@IBInspectable var flipVerticalAxis: Bool = false |
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 SingleWave { | |
float SEGMENTS_PER_CYCLE = 48.0; | |
float wavelength, r, dr; | |
color drawColor; | |
SingleWave(float wavelength, color drawColor) { | |
this.wavelength = wavelength; | |
this.drawColor = drawColor; |
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
static float FOCAL_LENGTH = 200.0; | |
static float ORBIT_RADIUS = 180.0; | |
static int SPARK_COUNT = 200; | |
class Spark { | |
color clr; | |
float orbitRadius; | |
float rx, ry, rz, drx, dry, drz; | |
Spark(color c, float orbitRadius) { | |
this.clr = c; |
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 Swift | |
/// This method returns half of the input value if the number is even. It returns nil if the number is odd. | |
func evenHalfOrNil(input: Int) -> Int? { | |
if (input % 2 == 0) { | |
return input / 2 | |
} else { | |
return nil | |
} | |
} |
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
// | |
// ViewController.swift | |
// MetalCoreImage | |
// | |
// Created by Joshua Sullivan on 4/21/16. | |
// Copyright © 2016 The Nerdery. All rights reserved. | |
// | |
import UIKit | |
import MetalKit |
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
// | |
// ColorCubeImageCreator.swift | |
// ColorCubeImageCreator | |
// | |
// Created by Joshua Sullivan on 4/25/16. | |
// Copyright © 2016 Joshua Sullivan. All rights reserved. | |
// | |
import UIKit |
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
//: # Challenge Accepted #49 | |
//: ## WUnderground API Client | |
//: ### Version 2.0 | |
//: | |
//: Implement the networking layer for the Umbrella weather app(iOS or Android), | |
//: using a similar architecture to the one demonstrated in the first episode of Swift Talks. | |
//: | |
//: - note: | |
//: This is my updated solution to the challenge which demonstrates a more powerful and flexible | |
//: approach to customizing the request sent to the API through the use of closures rather than |
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
// | |
// ColorCubeHelper.swift | |
// | |
// Created by Joshua Sullivan on 10/01/16. | |
// Copyright © 2016 Joshua Sullivan. All rights reserved. | |
// | |
import UIKit | |
import Accelerate |