boominadhaprakash / analogclock Goto Github PK
View Code? Open in Web Editor NEWAnalogClock in Swift v4.2
AnalogClock in Swift v4.2
To make this run correctly in swift 5 I just needed to make 2 changes. I got the hour, minute and second components using Calendar and removed shown commented out below. Next I commented out the +180 for LayerAnimation
//[1]
// *** Get Individual components from date ***
static let hour = Calendar.current.component(.hour, from: Date())
static let minute = Calendar.current.component(.minute, from: Date())
static let second = Calendar.current.component(.second, from: Date())
// let hour1 = CGFloat(hour * (30))//360/12 =30
// let hour2 = CGFloat(minutes)//1/60360/12 = 1/6030=0.5
// static let hour = hour1 + hour2
// //static let hour = (CGFloat(Date().hour * (360/12)) + (CGFloat(Date().minute) * (1.0/60) * (360/12)))
// static let minute = CGFloat(minutes * (360/60))
// static let second = CGFloat(seconds * (360/60))
//[2]
extension AnalogClockView {
func secondLayerAnimation() {
let secondAnimation = setUpLayerAnimation(duration: 60, isRemovedOnCompletion: false, timingFunction: CAMediaTimingFunction(name: .linear), fromValue: CGFloat(Angle.second/+180/) * CGFloat(Double.pi / 180), byValue: (2 * Double.pi))
secondLayer.add(secondAnimation, forKey: AnimationKey.second)
}
func minuteLayerAnimation() {
let minuteAnimation = setUpLayerAnimation(duration: 6060, isRemovedOnCompletion: false, timingFunction: CAMediaTimingFunction(name: .linear), fromValue: (Double(Angle.minute/+180*/) * Double.pi / 180), byValue: 2 * Double.pi)
minuteLayer.add(minuteAnimation, forKey: AnimationKey.minute)
}
func hourLayerAnimation() {
let hourAnimation = setUpLayerAnimation(duration: 606012, isRemovedOnCompletion: false, timingFunction: CAMediaTimingFunction(name: .linear), fromValue: (Double(Angle.hour/+180/) * Double.pi / 180), byValue: 2 * Double.pi)
hourLayer.add(hourAnimation, forKey: AnimationKey.hour)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.