This file contains hidden or 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 SwiftUI | |
struct FloatEffect: GeometryEffect { | |
var animatableData: CGFloat | |
func effectValue(size: CGSize) -> ProjectionTransform { | |
ProjectionTransform(CGAffineTransform(translationX: 0, y: sin(animatableData) * 12)) | |
} | |
} |
This file contains hidden or 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 is a port from the following Objective C code | |
// http://stackoverflow.com/a/24770675/1269132 | |
func roundedPolygonPath(squareLength: CGFloat, lineWidth: CGFloat, sides: Int, cornerRadius: CGFloat) -> UIBezierPath { | |
let path = UIBezierPath() | |
// how much to turn at every corner | |
let theta = 2.0 * CGFloat.pi / CGFloat(sides) | |
// offset from which to start rounding corners | |
let offset = cornerRadius * tan(theta / 2.0) | |
let sideLength: CGFloat = { |