diff --git a/TICoreGraphicsUtils/Sources/Drawing/Operations/TemplateDrawingOperation.swift b/TICoreGraphicsUtils/Sources/Drawing/Operations/TemplateDrawingOperation.swift index 6b34ea73..ed7fe282 100644 --- a/TICoreGraphicsUtils/Sources/Drawing/Operations/TemplateDrawingOperation.swift +++ b/TICoreGraphicsUtils/Sources/Drawing/Operations/TemplateDrawingOperation.swift @@ -22,15 +22,22 @@ import CoreGraphics -public struct TemplateDrawingOperation: DrawingOperation { - private let image: CGImage - private let imageSize: CGSize - private let color: CGColor +public struct TemplateDrawingOperation: OrientationAwareDrawingOperation { + + public var image: CGImage + public var imageSize: CGSize + public var color: CGColor + public var flipHorizontallyDuringDrawing: Bool + + public init(image: CGImage, + imageSize: CGSize, + color: CGColor, + flipHorizontallyDuringDrawing: Bool = true) { - public init(image: CGImage, imageSize: CGSize, color: CGColor) { self.image = image self.imageSize = imageSize self.color = color + self.flipHorizontallyDuringDrawing = flipHorizontallyDuringDrawing } public func affectedArea(in context: CGContext?) -> CGRect { @@ -40,13 +47,11 @@ public struct TemplateDrawingOperation: DrawingOperation { public func apply(in context: CGContext) { let imageRect = CGRect(origin: .zero, size: imageSize) - context.setFillColor(color) - - context.translateBy(x: 0, y: imageSize.height) - context.scaleBy(x: 1, y: -1) - context.clip(to: imageRect, mask: image) - context.fill(imageRect) - - context.setBlendMode(.multiply) + apply(in: context) { + $0.setFillColor(color) + $0.clip(to: imageRect, mask: image) + $0.fill(imageRect) + $0.setBlendMode(.multiply) + } } } diff --git a/TICoreGraphicsUtils/TICoreGraphicsUtils.app/Contents/MacOS/TICoreGraphicsUtils.playground/Sources/NefTest.swift b/TICoreGraphicsUtils/TICoreGraphicsUtils.app/Contents/MacOS/TICoreGraphicsUtils.playground/Sources/NefTest.swift deleted file mode 100644 index fe15078e..00000000 --- a/TICoreGraphicsUtils/TICoreGraphicsUtils.app/Contents/MacOS/TICoreGraphicsUtils.playground/Sources/NefTest.swift +++ /dev/null @@ -1,47 +0,0 @@ -import Foundation -import XCTest - -public extension Nef { - - static func run(testCase class: T.Type) { - startTestObserver() - T.defaultTestSuite.run() - } - - static private func startTestObserver() { - _ = testObserverInstalled - } - - static private var testObserverInstalled = { () -> NefTestFailObserver in - let testObserver = NefTestFailObserver() - XCTestObservationCenter.shared.addTestObserver(testObserver) - return testObserver - }() -} - -// MARK: enrich the output for XCTest -fileprivate class NefTestFailObserver: NSObject, XCTestObservation { - - private var numberOfFailedTests = 0 - - func testSuiteWillStart(_ testSuite: XCTestSuite) { - numberOfFailedTests = 0 - } - - func testSuiteDidFinish(_ testSuite: XCTestSuite) { - if numberOfFailedTests > 0 { - print("💢 Test Suite '\(testSuite.name)' finished with \(numberOfFailedTests) failed \(numberOfFailedTests > 1 ? "tests" : "test").") - } else { - print("🔅 Test Suite '\(testSuite.name)' finished successfully.") - } - } - - func testCase(_ testCase: XCTestCase, - didFailWithDescription description: String, - inFile filePath: String?, - atLine lineNumber: Int) { - - numberOfFailedTests += 1 - print("❗️Test Fail '\(testCase.name)':\(UInt(lineNumber)): \(description.description)") - } -} diff --git a/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec b/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec index 454ee312..b2754d8d 100644 --- a/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec +++ b/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec @@ -19,5 +19,5 @@ Pod::Spec.new do |s| s.exclude_files = s.name + '/*.app' end - s.framework = 'CoreGraphics' + s.framework = 'CoreGraphics' end diff --git a/TIMapUtils/Sources/IconProviders/DefaultClusterIconRenderer.swift b/TIMapUtils/Sources/IconProviders/DefaultClusterIconRenderer.swift index b869e063..ca538679 100644 --- a/TIMapUtils/Sources/IconProviders/DefaultClusterIconRenderer.swift +++ b/TIMapUtils/Sources/IconProviders/DefaultClusterIconRenderer.swift @@ -75,14 +75,11 @@ open class DefaultClusterIconRenderer { } open func textDrawingOperation(for text: String) -> TextDrawingOperation { - let ctFont = CTFontCreateWithFontDescriptorAndOptions(textAttributes.font.fontDescriptor, - textAttributes.font.pointSize, - nil, - []) - - return TextDrawingOperation(text: text, - font: ctFont, - textColor: textAttributes.color.cgColor) + TextDrawingOperation(text: text, + textAttributes: [ + .font: textAttributes.font, + .foregroundColor: textAttributes.color + ]) } open func backgroundDrawingOperation(iconSize: CGSize, diff --git a/TIYandexMapUtils/Sources/YandexMapManager.swift b/TIYandexMapUtils/Sources/YandexMapManager.swift index e45074e8..de3d6d3d 100644 --- a/TIYandexMapUtils/Sources/YandexMapManager.swift +++ b/TIYandexMapUtils/Sources/YandexMapManager.swift @@ -60,14 +60,15 @@ open class YandexMapManager: BaseMapManager? = nil, + iconFactory: DefaultMarkerIconFactory, clusterIconFactory: DefaultClusterMarkerIconFactory? = nil, selectPlacemarkHandler: @escaping SelectPlacemarkHandler) where DataModel: MapLocatable, DataModel.Position == YMKPoint { self.init(map: map, positionGetter: { $0.position }, - defaultMarkerIcon: defaultMarkerIcon, + iconFactory: iconFactory, + clusterIconFactory: clusterIconFactory, selectPlacemarkHandler: selectPlacemarkHandler) }