Skip to content

Instantly share code, notes, and snippets.

@kostiakoval
Created February 14, 2016 12:05
Show Gist options
  • Save kostiakoval/8415bef99d950f0d2590 to your computer and use it in GitHub Desktop.
Save kostiakoval/8415bef99d950f0d2590 to your computer and use it in GitHub Desktop.
Valentine Day
import UIKit
import XCPlayground
let a = 10
let layer = CAShapeLayer()
layer.strokeColor = UIColor.redColor().CGColor
layer.fillColor = UIColor(red: 1, green: 0.33, blue: 0.33, alpha: 1).CGColor
layer.lineWidth = 12
layer.lineCap = kCALineCapRound
layer.lineJoin = kCALineCapRound
let view = UIView(frame: CGRect(x: 0, y: 0, width: 640, height: 640 ))
view.layer.addSublayer(layer)
XCPlaygroundPage.currentPage.liveView = view
let points: [CGPoint] = 0.stride(to: M_PI * 2, by: 0.01).map {
let x = pow(sin($0), 3)
var y = 13 * cos($0)
y -= 5 * cos(2 * $0)
y -= 2 * cos(3 * $0)
y -= cos(4 * $0)
y /= 16
return CGPoint(x: 380 + (x * 300), y: 320 + (y * -300))
}
let path = CGPathCreateMutable()
CGPathAddLines(path, nil, points, points.count)
layer.path = path
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
UIView.animateWithDuration(2, delay: 0, options: [.Repeat, .Autoreverse], animations: {
view.transform = CGAffineTransformScale( view.transform , 1.2, 1.2)
}, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment