-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e3ff85
commit 880ca1c
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Copyright © 2024 Alexander Romanov | ||
// ColorData.swift, created on 13.06.2024 | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct ColorData: Codable { | ||
private var red: Double = 1 | ||
private var green: Double = 1 | ||
private var blue: Double = 1 | ||
private var opacity: Double = 1 | ||
|
||
public var color: Color { | ||
Color(red: red, green: green, blue: blue, opacity: opacity) | ||
} | ||
|
||
public init(red: Double, green: Double, blue: Double, opacity: Double) { | ||
self.red = red | ||
self.green = green | ||
self.blue = blue | ||
self.opacity = opacity | ||
} | ||
|
||
public init(color: Color) { | ||
let components = color.cgColor?.components ?? [] | ||
|
||
if components.count > 0 { | ||
red = Double(components[0]) | ||
} | ||
|
||
if components.count > 1 { | ||
green = Double(components[1]) | ||
} | ||
|
||
if components.count > 2 { | ||
blue = Double(components[2]) | ||
} | ||
|
||
if components.count > 3 { | ||
opacity = Double(components[3]) | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Copyright © 2024 Alexander Romanov | ||
// Coordinate2DData.swift, created on 13.06.2024 | ||
// | ||
|
||
import MapKit | ||
|
||
public struct Coordinate2DData: Codable { | ||
public let latitude: Double | ||
public let longitude: Double | ||
|
||
public init(latitude: Double, longitude: Double) { | ||
self.latitude = latitude | ||
self.longitude = longitude | ||
} | ||
|
||
public init(_ location: CLLocationCoordinate2D) { | ||
latitude = location.latitude | ||
longitude = location.longitude | ||
} | ||
|
||
public var location: CLLocationCoordinate2D { | ||
CLLocationCoordinate2D(latitude: latitude, longitude: longitude) | ||
} | ||
} |