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
#!/bin/bash | |
# This is a companion script to https://github.com/konstantin-kelemen/arduino-amiibo-tools | |
# The original post this was crafted for was https://games.kel.mn/en/create-amiibo-clones-with-arduino/ | |
# For more info go to https://games.kel.mn/en/companion-script-to-simplify-amiibo-cloning-with-arduino/ | |
#requirements: | |
#sha1sum (part of coreutils) | |
#xxd (part of vim) | |
#hexdump | |
#amiitool (https://github.com/socram8888/amiitool) |
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
#!/bin/bash | |
# This is a companion script to https://github.com/konstantin-kelemen/arduino-amiibo-tools | |
# The original post this was crafted for was https://games.kel.mn/en/create-amiibo-clones-with-arduino/ | |
# For more info go to https://games.kel.mn/en/companion-script-to-simplify-amiibo-cloning-with-arduino/ | |
#requirements: | |
#sha1sum (part of coreutils) | |
#xxd (part of vim) | |
#hexdump | |
#amiitool (https://github.com/socram8888/amiitool) |
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
// | |
// JWScrollStateMachine.swift | |
// JWThumbnailsNavigation | |
// | |
// Created by Jongwon Woo on 26/03/2017. | |
// Copyright © 2017 CocoaPods. 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
public class ElasticTransition : NSObject, ElasticMotionStateMachineDelegate { | |
init(presentedViewController: UIViewController, presentingViewWidth: Float) { | |
self.stateMachine = ElasticMotionStateMachine(ElasticMotionDirection.Right, threshold: threshold, vibrationSec: 2.0) | |
self.stateMachine.delegate = self | |
} | |
func elasticMotionStateMachine(stateMachine: ElasticMotionStateMachine, didChangeState state: ElasticMotionState, deltaPoint: CGPoint) { | |
if stateMachine.direction == ElasticMotionDirection.Right { | |
let fullOpenedWidth = CGFloat(presentingViewWidth) | |
switch state { |
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
func elasticMotionStateMachine(stateMachine: ElasticMotionStateMachine, didChangeState state: ElasticMotionState, deltaPoint: CGPoint) { | |
switch state { | |
case .MayOpen: | |
let newOriginX = self.view.frame.origin.x + deltaPoint.x | |
if newOriginX >= 0 && newOriginX < CGFloat(threshold) { | |
self.view.center = CGPointMake(self.view.center.x + deltaPoint.x, self.view.center.y) | |
} | |
// other state | |
} |
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 ViewController: UIViewController { | |
@IBAction func handlePan(recognizer: UIPanGestureRecognizer) { | |
let currentPoint = recognizer.translationInView(self.view) | |
if let stateMachine = self.stateMachine { | |
switch recognizer.state { | |
case .Began, .Changed: | |
stateMachine.keepMoving(currentPoint) | |
default: | |
stateMachine.stopMoving() |
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
enum ElasticMotionState { | |
case Closed | |
case MayOpen | |
case WillOpen | |
case Opened | |
case MayClose | |
case WillClose | |
} |
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 ElasticMotionStateMachine { | |
func keepMoving(currentPoint: CGPoint) { | |
if self.state == .Closed || self.state == .WillClose || self.state == .Opened || self.state == .WillOpen { | |
self.beginPoint = currentPoint | |
self.totalMovingPoint = CGPointZero | |
} | |
let delta = self.deltaPointFromCurrentPoint(currentPoint) | |
self.addMovingPoint(delta) | |
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
func panGestureRecognized(recognizer: UIPanGestureRecognizer) { | |
if recognizer.state == .Began { | |
setupContentViewShadow() | |
originalPoint = CGPointMake(contentViewContainer.center.x - CGRectGetWidth(contentViewContainer.bounds) / 2.0, | |
contentViewContainer.center.y - CGRectGetHeight(contentViewContainer.bounds) / 2.0) | |
menuViewContainer.transform = CGAffineTransformIdentity | |
if (scaleBackgroundImageView) { | |
backgroundImageView.transform = CGAffineTransformIdentity |
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 Country { | |
let name:String | |
var capitalCity:City? | |
init (name:String, capitalName:String) { | |
self.name = name | |
self.capitalCity = City(name: capitalName, country: self) | |
} | |
} | |
class City { |