Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created December 22, 2020 09:44
Show Gist options
  • Save amosgyamfi/cbbfb692d56017a12edd46ce3c87eec0 to your computer and use it in GitHub Desktop.
Save amosgyamfi/cbbfb692d56017a12edd46ce3c87eec0 to your computer and use it in GitHub Desktop.
//
// Aaron-Burden-Gvnuvp8Cs1O-UnsplashView.swift
// Exported from Kite Compositor for Mac 2.0.2
//
// Created on 22.12.2020, 9.34.
//
import UIKit
class Aaron-Burden-Gvnuvp8Cs1O-UnsplashView: UIView
{
// MARK: - Initialization
init()
{
super.init(frame: CGRect(x: 0, y: 0, width: 900, height: 600))
self.setupLayers()
}
required init?(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
self.setupLayers()
}
// MARK: - Setup Layers
private func setupLayers()
{
// Images
//
guard let aaronBurdenGVnUVPCsOUnsplashJpgImage = UIImage(named: "aaron-burden-GVnUVP8cs1o-unsplash.jpg") else {
fatalError("Warning: Unable to locate image named 'aaron-burden-GVnUVP8cs1o-unsplash.jpg'")
}
// aaron-burden-GVnUVP8cs1o-unsplash
//
let aaronBurdenGVnUVPCsOUnsplashLayer = CALayer()
aaronBurdenGVnUVPCsOUnsplashLayer.name = "aaron-burden-GVnUVP8cs1o-unsplash"
aaronBurdenGVnUVPCsOUnsplashLayer.bounds = CGRect(x: 0, y: 0, width: 400, height: 300)
aaronBurdenGVnUVPCsOUnsplashLayer.position = CGPoint(x: 250, y: 150)
aaronBurdenGVnUVPCsOUnsplashLayer.anchorPoint = CGPoint(x: 0, y: 0)
aaronBurdenGVnUVPCsOUnsplashLayer.contents = aaronBurdenGVnUVPCsOUnsplashJpgImage.cgImage
aaronBurdenGVnUVPCsOUnsplashLayer.contentsGravity = .resizeAspect
aaronBurdenGVnUVPCsOUnsplashLayer.shadowOffset = CGSize(width: 0, height: 1)
aaronBurdenGVnUVPCsOUnsplashLayer.allowsEdgeAntialiasing = true
aaronBurdenGVnUVPCsOUnsplashLayer.allowsGroupOpacity = true
aaronBurdenGVnUVPCsOUnsplashLayer.fillMode = .forwards
// aaron-burden-GVnUVP8cs1o-unsplash Animations
//
// filters.Kaleidoscope.inputCount
//
let filtersKaleidoscopeInputCountAnimation = CABasicAnimation()
filtersKaleidoscopeInputCountAnimation.beginTime = self.layer.convertTime(CACurrentMediaTime(), from: nil) + 0.000001
filtersKaleidoscopeInputCountAnimation.duration = 5
filtersKaleidoscopeInputCountAnimation.repeatCount = 1200
filtersKaleidoscopeInputCountAnimation.autoreverses = true
filtersKaleidoscopeInputCountAnimation.fillMode = .forwards
filtersKaleidoscopeInputCountAnimation.isRemovedOnCompletion = false
filtersKaleidoscopeInputCountAnimation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
filtersKaleidoscopeInputCountAnimation.keyPath = "filters.Kaleidoscope.inputCount"
filtersKaleidoscopeInputCountAnimation.toValue = 64
filtersKaleidoscopeInputCountAnimation.fromValue = 6
aaronBurdenGVnUVPCsOUnsplashLayer.add(filtersKaleidoscopeInputCountAnimation, forKey: "filtersKaleidoscopeInputCountAnimation")
// filters.Kaleidoscope.inputAngle
//
let filtersKaleidoscopeInputAngleAnimation = CABasicAnimation()
filtersKaleidoscopeInputAngleAnimation.beginTime = self.layer.convertTime(CACurrentMediaTime(), from: nil) + 0.000001
filtersKaleidoscopeInputAngleAnimation.duration = 5
filtersKaleidoscopeInputAngleAnimation.speed = 0.5
filtersKaleidoscopeInputAngleAnimation.repeatCount = 1200
filtersKaleidoscopeInputAngleAnimation.autoreverses = true
filtersKaleidoscopeInputAngleAnimation.fillMode = .forwards
filtersKaleidoscopeInputAngleAnimation.isRemovedOnCompletion = false
filtersKaleidoscopeInputAngleAnimation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
filtersKaleidoscopeInputAngleAnimation.keyPath = "filters.Kaleidoscope.inputAngle"
filtersKaleidoscopeInputAngleAnimation.toValue = 2
filtersKaleidoscopeInputAngleAnimation.fromValue = -2
aaronBurdenGVnUVPCsOUnsplashLayer.add(filtersKaleidoscopeInputAngleAnimation, forKey: "filtersKaleidoscopeInputAngleAnimation")
self.layer.addSublayer(aaronBurdenGVnUVPCsOUnsplashLayer)
}
// MARK: - Responder
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)
{
guard let location = touches.first?.location(in: self.superview),
let hitLayer = self.layer.presentation()?.hitTest(location) else { return }
print("Layer \(hitLayer.name ?? String(describing: hitLayer)) was tapped.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment