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 Diamond: Shape { | |
func path(in rect: CGRect) -> Path { | |
let (x, y, width, height) = rect.centeredSquare.flatten() | |
let lowerPoint = CGPoint(x: x + width / 2, y: (y + height )) | |
let path = Path { p in | |
p.move(to: lowerPoint) |
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 Spade: Shape { | |
func path(in rect: CGRect) -> Path { | |
let (x, y, width, height) = rect.centeredSquare.flatten() | |
var heartPath = Heart().rotation(.A180).path(in: CGRect(x: x, y: y, width: width, height: height * 0.9)) //take 10% for bottom rect | |
let rectPath = Rectangle().path(in: CGRect(x: x + width * 0.4, y: y + height * 0.5, width: width * 0.2, height: height * 0.5)) | |
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 Club: Shape { | |
func path(in rect: CGRect) -> Path { | |
let (x, y, width, height) = rect.centeredSquare.flatten() | |
let center = rect.centeredSquare.center | |
let center1 = CGPoint(x: x + width / 2, y: (y + height/4 )) | |
let center2 = CGPoint(x: x + width / 4, y: (y + height/2 )) |
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
struct QRCodeDataSet { | |
let logo: UIImage? | |
let url: String | |
let backgroundColor: CIColor | |
let color: CIColor | |
let size: CGSize | |
init(logo: UIImage? = nil, url: String) { | |
self.logo = logo | |
self.url = url |
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
private func createCIImage() -> CIImage? { | |
guard let filter = CIFilter(name: "CIQRCodeGenerator") else { | |
return nil | |
} | |
filter.setDefaults() | |
filter.setValue(url.data(using: String.Encoding.ascii), forKey: "inputMessage") | |
filter.setValue("H", forKey: "inputCorrectionLevel") | |
//https://www.qrcode.com/en/about/error_correction.html | |
return filter.outputImage | |
} |
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
private func updateColor(image: CIImage) -> CIImage? { | |
guard let colorFilter = CIFilter(name: "CIFalseColor") else { return nil } | |
colorFilter.setValue(image, forKey: kCIInputImageKey) | |
colorFilter.setValue(color, forKey: "inputColor0") | |
colorFilter.setValue(backgroundColor, forKey: "inputColor1") | |
return colorFilter.outputImage | |
} |
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
private func addLogo(image: CIImage, logo: UIImage) -> CIImage? { | |
guard let combinedFilter = CIFilter(name: "CISourceOverCompositing") else { return nil } | |
guard let logo = logo.cgImage else { | |
return image | |
} | |
let ciLogo = CIImage(cgImage: logo) | |
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 | |
import Foundation | |
import UIKit | |
struct ContentView: View { | |
var body: some View { | |
ZStack { | |
QRView().frame(width: 300, height: 300, alignment: .center) |
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 ContentView: View { | |
@State private var text = "Test Multiline" | |
var body: some View { | |
TextEditor(text: $text) | |
.padding() | |
.font(.subheadline) | |
} | |
} |
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 | |
class Brand: ObservableObject { | |
var name = "Apple" | |
var type = "Tech" | |
} | |
struct ContentView: View { |