Type | Requirement | |
---|---|---|
Platform |
iOS |
10.0+ |
macOS |
10.10 |
|
tvOS |
N/A |
|
watchOS |
N/A |
|
Linux |
N/A |
|
IDE |
Xcode |
9.3+ |
Language |
Swift |
4.1+ |
DaVinci
is open-sourced software, licensed under the MIT
license.
import DaVinci
public func draw(in context: CGContext, rect: CGRect) {
let fillColorOne: CGColor = #colorLiteral(red: 0.05, green:0.49, blue:0.98, alpha:0.8).cgColor
func cal(_ ref: CGFloat, _ acu: CGFloat) -> CGFloat {
let reference: CGFloat = 66
return (ref / reference) * acu
}
let arrowPartTop = DaVinci.Path.init(point: CGPoint.init(x: cal(11, rect.width), y: rect.midY))
.addLine(to: CGPoint.init(x: cal(44.5, rect.width), y: 0))
.addLine(to: CGPoint.init(x: cal(54, rect.width), y: cal(9.5, rect.height)))
.addLine(to: CGPoint.init(x: cal(30, rect.width), y: rect.midY))
.close()
let arrowPartBottom = arrowPartTop.flip(.vertically, by: rect.midY)
let arrow = arrowPartTop + arrowPartBottom
context.fill(path: arrow, color: fillColorOne)
}