From 165c334854200d3b8e124c8b5bd95ac53cf2727e Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 16 Dec 2019 17:21:18 +0400 Subject: [PATCH] Fix gradient wallpaper rotation --- .../Sources/ChatControllerBackgroundNode.swift | 2 +- .../Sources/PresentationThemeCodable.swift | 2 +- .../Sources/WallpaperResources.swift | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift b/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift index 6d231719cf..91ae63e582 100644 --- a/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift +++ b/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift @@ -54,7 +54,7 @@ public func chatControllerBackgroundImage(theme: PresentationTheme?, wallpaper i context.rotate(by: CGFloat(settings.rotation ?? 0) * CGFloat.pi / 180.0) context.translateBy(x: -320.0, y: -640.0) - context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) + context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]) }) case let .image(representations, settings): if let largest = largestImageRepresentation(representations) { diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index a660f372ff..272a430f22 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -63,7 +63,7 @@ extension TelegramWallpaper: Codable { } } - self = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings(blur: blur, motion: motion)) + self = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings(blur: blur, motion: motion, rotation: rotation)) } else { var slug: String? var color: Int32? diff --git a/submodules/WallpaperResources/Sources/WallpaperResources.swift b/submodules/WallpaperResources/Sources/WallpaperResources.swift index a9ff275f7d..a9d81b1bf4 100644 --- a/submodules/WallpaperResources/Sources/WallpaperResources.swift +++ b/submodules/WallpaperResources/Sources/WallpaperResources.swift @@ -469,7 +469,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da c.rotate(by: CGFloat(customArguments.rotation ?? 0) * CGFloat.pi / -180.0) c.translateBy(x: -arguments.drawingSize.width / 2.0, y: -arguments.drawingSize.height / 2.0) - c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: arguments.drawingSize.height), options: CGGradientDrawingOptions()) + c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: arguments.drawingSize.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]) c.restoreGState() } @@ -496,7 +496,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da c.rotate(by: CGFloat(customArguments.rotation ?? 0) * CGFloat.pi / -180.0) c.translateBy(x: -arguments.drawingSize.width / 2.0, y: -arguments.drawingSize.height / 2.0) - c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: arguments.drawingSize.height), options: CGGradientDrawingOptions()) + c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: arguments.drawingSize.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]) } } } @@ -555,7 +555,7 @@ public func gradientImage(_ colors: [UIColor], rotation: Int32 = 0) -> Signal<(T } } return .single({ arguments in - let context = DrawingContext(size: arguments.drawingSize, clear: true) + let context = DrawingContext(size: arguments.drawingSize, clear: !arguments.corners.isEmpty) context.withContext { c in let gradientColors = colors.map { $0.cgColor } as CFArray @@ -572,7 +572,7 @@ public func gradientImage(_ colors: [UIColor], rotation: Int32 = 0) -> Signal<(T c.rotate(by: CGFloat(rotation) * CGFloat.pi / 180.0) c.translateBy(x: -arguments.drawingSize.width / 2.0, y: -arguments.drawingSize.height / 2.0) - c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: arguments.drawingSize.height), options: CGGradientDrawingOptions()) + c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: arguments.drawingSize.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]) } addCorners(context, arguments: arguments) @@ -755,7 +755,7 @@ public func drawThemeImage(context c: CGContext, theme: PresentationTheme, wallp var locations: [CGFloat] = [0.0, 1.0] let colorSpace = CGColorSpaceCreateDeviceRGB() let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)! - c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: drawingRect.height), end: CGPoint(x: 0.0, y: 0.0), options: CGGradientDrawingOptions()) + c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: drawingRect.height), end: CGPoint(x: 0.0, y: 0.0), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]) case .file: c.setFillColor(theme.chatList.backgroundColor.cgColor) c.fill(drawingRect)