Various fixes

This commit is contained in:
Ilya Laktyushin 2022-12-19 16:08:43 +04:00
parent 29f7c8c9f0
commit 8a9a557870
5 changed files with 31 additions and 14 deletions

View File

@ -718,19 +718,9 @@ private func generateSpectrumImage(size: CGSize) -> UIImage? {
if let image = UIImage(bundleImageName: "Media Editor/Spectrum") {
context.draw(image.cgImage!, in: CGRect(origin: .zero, size: size))
}
let colorSpace = CGColorSpaceCreateDeviceRGB()
var colors = [UIColor(rgb: 0xffffff).cgColor, UIColor(rgb: 0xffffff, alpha: 0.0).cgColor, UIColor(rgb: 0xffffff, alpha: 0.0).cgColor]
var locations: [CGFloat] = [0.0, 0.45, 1.0]
var gradient = CGGradient(colorsSpace: colorSpace, colors: colors as CFArray, locations: &locations)!
context.drawLinearGradient(gradient, start: CGPoint(), end: CGPoint(x: size.width, y: 0.0), options: [.drawsAfterEndLocation])
colors = [UIColor(rgb: 0x000000, alpha: 0.0).cgColor, UIColor(rgb: 0x000000, alpha: 0.0).cgColor, UIColor(rgb: 0x000000).cgColor]
locations = [0.0, 0.5, 1.0]
gradient = CGGradient(colorsSpace: colorSpace, colors: colors as CFArray, locations: &locations)!
context.drawLinearGradient(gradient, start: CGPoint(), end: CGPoint(x: size.width, y: 0.0), options: [.drawsAfterEndLocation])
if let image = UIImage(bundleImageName: "Media Editor/Grayscale") {
context.draw(image.cgImage!, in: CGRect(origin: .zero, size: size))
}
})
}

View File

@ -308,7 +308,9 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak view] _ in
view?.removeFromSuperview()
})
view.layer.animateScale(from: 0.0, to: -0.99, duration: 0.2, removeOnCompletion: false, additive: true)
if !(view.entity is DrawingVectorEntity) {
view.layer.animateScale(from: 0.0, to: -0.99, duration: 0.2, removeOnCompletion: false, additive: true)
}
}
} else {

View File

@ -268,6 +268,10 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
}
if let renderLayer = newElement.setupRenderLayer() {
if let currentDrawingLayer = strongSelf.currentDrawingLayer {
strongSelf.currentDrawingLayer = nil
currentDrawingLayer.removeFromSuperlayer()
}
strongSelf.currentDrawingView.layer.addSublayer(renderLayer)
strongSelf.currentDrawingLayer = renderLayer
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "grayscale.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B