Story locations

This commit is contained in:
Ilya Laktyushin
2023-07-31 20:19:11 +02:00
parent 487c01f448
commit 8805c0b7bd
38 changed files with 956 additions and 204 deletions

View File

@@ -1,4 +1,5 @@
import Foundation
import TelegramCore
public enum CodableDrawingEntity: Equatable {
public static func == (lhs: CodableDrawingEntity, rhs: CodableDrawingEntity) -> Bool {
@@ -46,6 +47,30 @@ public enum CodableDrawingEntity: Equatable {
return entity
}
}
public var mediaArea: MediaArea? {
switch self {
case let .location(entity):
return .venue(
coordinates: MediaArea.Coordinates(
x: entity.position.x / 1080.0 * 100.0,
y: entity.position.y / 1920.0 * 100.0,
width: (entity.renderImage?.size.width ?? 0.0) * entity.scale / 1080.0 * 100.0,
height: (entity.renderImage?.size.height ?? 0.0) * entity.scale / 1920.0 * 100.0,
rotation: entity.rotation / .pi * 180.0
),
venue: MediaArea.Venue(
latitude: entity.location.latitude,
longitude: entity.location.longitude,
venue: entity.location.venue,
queryId: entity.queryId,
resultId: entity.resultId
)
)
default:
return nil
}
}
}
extension CodableDrawingEntity: Codable {