add shape picker for backgrounds
This commit is contained in:
31
Shared/Models/DiamondView.swift
Normal file
31
Shared/Models/DiamondView.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// DiamondView.swift
|
||||
// Feels
|
||||
//
|
||||
// Created by Trey Tartt on 3/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct Diamond:Shape {
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
var path = Path()
|
||||
// get the center of the rect
|
||||
let center = CGPoint(x: rect.midX, y: rect.midY)
|
||||
// get the starting of our drawing the right side of our diamond
|
||||
let startingPoint = CGPoint(x: rect.maxX, y: center.y)
|
||||
// move our start of drawing to the beggining point
|
||||
path.move(to: startingPoint)
|
||||
// distance / 2 is our height
|
||||
// create all our points
|
||||
let secondPoint = CGPoint(x: center.x, y: rect.maxY)
|
||||
let thirdPoint = CGPoint(x: rect.minX , y: center.y)
|
||||
let fourthPoint = CGPoint(x: center.x, y: rect.minY)
|
||||
path.addLine(to: secondPoint)
|
||||
path.addLine(to: thirdPoint)
|
||||
path.addLine(to: fourthPoint)
|
||||
path.addLine(to: startingPoint)
|
||||
return path
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user