mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
[Demo] Sticker dust effect
This commit is contained in:
@@ -2952,6 +2952,23 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
override public func contentFrame() -> CGRect {
|
override public func contentFrame() -> CGRect {
|
||||||
return self.imageNode.frame
|
return self.imageNode.frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public func makeContentSnapshot() -> (UIImage, CGRect)? {
|
||||||
|
UIGraphicsBeginImageContextWithOptions(self.imageNode.view.bounds.size, false, 0.0)
|
||||||
|
let context = UIGraphicsGetCurrentContext()!
|
||||||
|
|
||||||
|
context.translateBy(x: -self.imageNode.frame.minX, y: -self.imageNode.frame.minY)
|
||||||
|
self.view.layer.render(in: context)
|
||||||
|
|
||||||
|
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||||
|
UIGraphicsEndImageContext()
|
||||||
|
|
||||||
|
guard let image else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return (image, self.imageNode.frame)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct AnimatedEmojiSoundsConfiguration {
|
public struct AnimatedEmojiSoundsConfiguration {
|
||||||
|
|||||||
@@ -2052,4 +2052,21 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
override public func contentFrame() -> CGRect {
|
override public func contentFrame() -> CGRect {
|
||||||
return self.imageNode.frame
|
return self.imageNode.frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public func makeContentSnapshot() -> (UIImage, CGRect)? {
|
||||||
|
UIGraphicsBeginImageContextWithOptions(self.imageNode.view.bounds.size, false, 0.0)
|
||||||
|
let context = UIGraphicsGetCurrentContext()!
|
||||||
|
|
||||||
|
context.translateBy(x: -self.imageNode.frame.minX, y: -self.imageNode.frame.minY)
|
||||||
|
self.view.layer.render(in: context)
|
||||||
|
|
||||||
|
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||||
|
UIGraphicsEndImageContext()
|
||||||
|
|
||||||
|
guard let image else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return (image, self.imageNode.frame)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ public final class DustEffectLayer: MetalEngineSubjectLayer, MetalEngineSubject
|
|||||||
if let item = Item(frame: frame, image: image) {
|
if let item = Item(frame: frame, image: image) {
|
||||||
self.items.append(item)
|
self.items.append(item)
|
||||||
self.updateNeedsAnimation()
|
self.updateNeedsAnimation()
|
||||||
|
self.setNeedsUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user