Various fixes

This commit is contained in:
Ilya Laktyushin 2022-12-18 21:09:38 +04:00
parent 2d7c7e81f1
commit 056f265511
11 changed files with 137 additions and 67 deletions

View File

@ -97,6 +97,9 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
self.currentEntityView = entityView
return entityView
}
public func prepareForRender() {
}
}
final class DrawingBubbleEntityView: DrawingEntityView {
@ -131,9 +134,9 @@ final class DrawingBubbleEntityView: DrawingEntityView {
self.currentTailPosition = self.bubbleEntity.tailPosition
self.shapeLayer.frame = self.bounds
let cornerRadius = max(10.0, min(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.066)
let smallCornerRadius = max(5.0, min(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.016)
let tailWidth = max(5.0, min(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
let cornerRadius = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.066)
let smallCornerRadius = max(5.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.016)
let tailWidth = max(5.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
self.shapeLayer.path = CGPath.bubble(in: CGRect(origin: .zero, size: size), cornerRadius: cornerRadius, smallCornerRadius: smallCornerRadius, tailPosition: self.bubbleEntity.tailPosition, tailWidth: tailWidth)
}
@ -143,8 +146,8 @@ final class DrawingBubbleEntityView: DrawingEntityView {
self.shapeLayer.fillColor = self.bubbleEntity.color.toCGColor()
self.shapeLayer.strokeColor = UIColor.clear.cgColor
case .stroke:
let minLineWidth = max(10.0, min(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.02)
let maxLineWidth = max(10.0, min(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
let minLineWidth = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.01)
let maxLineWidth = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.bubbleEntity.lineWidth
self.shapeLayer.fillColor = UIColor.clear.cgColor
@ -160,7 +163,7 @@ final class DrawingBubbleEntityView: DrawingEntityView {
}
private var maxLineWidth: CGFloat {
return max(10.0, min(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
return max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {

View File

@ -12,9 +12,11 @@ public protocol DrawingEntity: AnyObject {
var color: DrawingColor { get set }
func duplicate() -> DrawingEntity
var currentEntityView: DrawingEntityView? { get }
func makeView(context: AccountContext) -> DrawingEntityView
func prepareForRender()
}
enum CodableDrawingEntity {
@ -164,8 +166,12 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
}
var entitiesData: Data? {
let entities = self.entities.compactMap({ CodableDrawingEntity(entity: $0) })
if let data = try? JSONEncoder().encode(entities) {
let entities = self.entities
for entity in entities {
entity.prepareForRender()
}
let codableEntities = entities.compactMap({ CodableDrawingEntity(entity: $0) })
if let data = try? JSONEncoder().encode(codableEntities) {
return data
} else {
return nil

View File

@ -215,6 +215,17 @@ private let colorButtonTag = GenericComponentViewTag()
private let addButtonTag = GenericComponentViewTag()
private let toolsTag = GenericComponentViewTag()
private let modeTag = GenericComponentViewTag()
private let flipButtonTag = GenericComponentViewTag()
private let textSettingsTag = GenericComponentViewTag()
private let sizeSliderTag = GenericComponentViewTag()
private let color1Tag = GenericComponentViewTag()
private let color2Tag = GenericComponentViewTag()
private let color3Tag = GenericComponentViewTag()
private let color4Tag = GenericComponentViewTag()
private let color5Tag = GenericComponentViewTag()
private let color6Tag = GenericComponentViewTag()
private let color7Tag = GenericComponentViewTag()
private let color8Tag = GenericComponentViewTag()
private let doneButtonTag = GenericComponentViewTag()
private final class DrawingScreenComponent: CombinedComponent {
@ -759,6 +770,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[0]),
color: presetColors[0],
tag: color1Tag,
action: {
applySwatchColor(presetColors[0])
}
@ -785,6 +797,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[1]),
color: presetColors[1],
tag: color2Tag,
action: {
applySwatchColor(presetColors[1])
}
@ -811,6 +824,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[2]),
color: presetColors[2],
tag: color3Tag,
action: {
applySwatchColor(presetColors[2])
}
@ -837,6 +851,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[3]),
color: presetColors[3],
tag: color4Tag,
action: {
applySwatchColor(presetColors[3])
}
@ -863,6 +878,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[4]),
color: presetColors[4],
tag: color5Tag,
action: {
applySwatchColor(presetColors[4])
}
@ -890,6 +906,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[5]),
color: presetColors[5],
tag: color6Tag,
action: {
applySwatchColor(presetColors[5])
}
@ -916,6 +933,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[6]),
color: presetColors[6],
tag: color7Tag,
action: {
applySwatchColor(presetColors[6])
}
@ -942,6 +960,7 @@ private final class DrawingScreenComponent: CombinedComponent {
component: ColorSwatchComponent(
type: .pallete(state.currentColor == presetColors[7]),
color: presetColors[7],
tag: color8Tag,
action: {
applySwatchColor(presetColors[7])
}
@ -952,8 +971,8 @@ private final class DrawingScreenComponent: CombinedComponent {
context.add(swatch8Button
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch7Button.size.height / 2.0 - 57.0))
.appear(Transition.Appear { _, view, transition in
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.15)
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.15)
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.175)
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.175)
})
.disappear(Transition.Disappear { view, transition, completion in
transition.setScale(view: view, scale: 0.1)
@ -1048,6 +1067,7 @@ private final class DrawingScreenComponent: CombinedComponent {
let textSize = textSize.update(
component: TextSizeSliderComponent(
value: sizeValue ?? state.lastSize,
tag: sizeSliderTag,
updated: { [weak state] size in
if let state = state {
state.updateBrushSize(size)
@ -1196,7 +1216,7 @@ private final class DrawingScreenComponent: CombinedComponent {
}
state.updated(transition: .easeInOut(duration: 0.2))
}
).minSize(CGSize(width: 44.0, height: 44.0)),
).minSize(CGSize(width: 44.0, height: 44.0)).tagged(flipButtonTag),
availableSize: CGSize(width: 33.0, height: 33.0),
transition: .immediate
)
@ -1914,6 +1934,18 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController {
buttonView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
buttonView.layer.animateScale(from: 0.01, to: 1.0, duration: 0.3)
}
var delay: Double = 0.0
let colorTags = [color1Tag, color2Tag, color3Tag, color4Tag, color5Tag, color6Tag, color7Tag, color8Tag]
for tag in colorTags {
if let view = self.componentHost.findTaggedView(tag: tag) {
view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, delay: delay)
view.layer.animateScale(from: 0.01, to: 1.0, duration: 0.3, delay: delay)
delay += 0.025
}
}
if let view = self.componentHost.findTaggedView(tag: sizeSliderTag) {
view.layer.animatePosition(from: CGPoint(x: -33.0, y: 0.0), to: CGPoint(), duration: 0.3, additive: true)
}
}
func animateOut(completion: @escaping () -> Void) {
@ -1944,6 +1976,28 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController {
buttonView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
buttonView.layer.animateScale(from: 1.0, to: 0.01, duration: 0.3)
}
if let buttonView = self.componentHost.findTaggedView(tag: flipButtonTag) {
buttonView.alpha = 0.0
buttonView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
buttonView.layer.animateScale(from: 1.0, to: 0.01, duration: 0.3)
}
if let view = self.componentHost.findTaggedView(tag: sizeSliderTag) {
view.layer.animatePosition(from: CGPoint(), to: CGPoint(x: -33.0, y: 0.0), duration: 0.3, removeOnCompletion: false, additive: true)
}
if let view = self.componentHost.findTaggedView(tag: textSettingsTag) {
view.alpha = 0.0
view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
}
let colorTags = [color1Tag, color2Tag, color3Tag, color4Tag, color5Tag, color6Tag, color7Tag, color8Tag]
for tag in colorTags {
if let view = self.componentHost.findTaggedView(tag: tag) {
view.alpha = 0.0
view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
view.layer.animateScale(from: 1.0, to: 0.01, duration: 0.3)
}
}
if let view = self.componentHost.findTaggedView(tag: toolsTag) as? ToolsComponent.View {
view.animateOut(completion: {
completion()
@ -2282,30 +2336,6 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController {
hasAnimatedEntities = true
break
}
// if let entity = entity as? DrawingStickerEntity {
// let coder = PostboxEncoder()
// coder.encodeRootObject(entity.file)
//
// let baseSize = max(10.0, min(entity.referenceDrawingSize.width, entity.referenceDrawingSize.height) * 0.38)
// if let stickerEntity = TGPhotoPaintStickerEntity(document: coder.makeData(), baseSize: CGSize(width: baseSize, height: baseSize), animated: entity.isAnimated) {
// stickerEntity.position = entity.position
// stickerEntity.scale = entity.scale
// stickerEntity.angle = entity.rotation
// legacyEntities.append(stickerEntity)
// }
// } else if let entity = entity as? DrawingTextEntity, let view = self.entitiesView.getView(for: entity.uuid) as? DrawingTextEntityView {
// let textEntity = TGPhotoPaintStaticEntity()
// textEntity.position = entity.position
// textEntity.angle = entity.rotation
// textEntity.renderImage = view.getRenderImage()
// legacyEntities.append(textEntity)
// } else if let _ = entity as? DrawingSimpleShapeEntity {
//
// } else if let _ = entity as? DrawingBubbleEntity {
//
// } else if let _ = entity as? DrawingVectorEntity {
//
// }
}
let finalImage = generateImage(self.drawingView.imageSize, contextGenerator: { size, context in
@ -2331,7 +2361,6 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController {
}
return TGPaintingData(drawing: nil, entitiesData: self.entitiesView.entitiesData, image: image, stillImage: stillImage, hasAnimation: hasAnimatedEntities)
// return TGPaintingData(painting: nil, image: image, stillImage: stillImage, entities: legacyEntities, undoManager: nil)
}
public func resultImage() -> UIImage! {

View File

@ -103,6 +103,9 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
self.currentEntityView = entityView
return entityView
}
public func prepareForRender() {
}
}
final class DrawingSimpleShapeEntityView: DrawingEntityView {
@ -153,8 +156,8 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
self.shapeLayer.fillColor = self.shapeEntity.color.toCGColor()
self.shapeLayer.strokeColor = UIColor.clear.cgColor
case .stroke:
let minLineWidth = max(10.0, min(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.02)
let maxLineWidth = max(10.0, min(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1)
let minLineWidth = max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.01)
let maxLineWidth = max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.shapeEntity.lineWidth
self.shapeLayer.fillColor = UIColor.clear.cgColor
@ -170,7 +173,7 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
}
private var maxLineWidth: CGFloat {
return max(10.0, min(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1)
return max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1)
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {

View File

@ -95,6 +95,9 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
self.currentEntityView = entityView
return entityView
}
public func prepareForRender() {
}
}
final class DrawingStickerEntityView: DrawingEntityView {

View File

@ -142,16 +142,17 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
public var lineWidth: CGFloat = 0.0
var referenceDrawingSize: CGSize
var position: CGPoint
public var position: CGPoint
var width: CGFloat
var scale: CGFloat
var rotation: CGFloat
public var scale: CGFloat
public var rotation: CGFloat
public var center: CGPoint {
return self.position
}
public var renderImage: UIImage?
public var renderSubEntities: [DrawingStickerEntity]?
init(text: NSAttributedString, style: Style, font: Font, alignment: Alignment, fontSize: CGFloat, color: DrawingColor) {
self.uuid = UUID()
@ -235,6 +236,10 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
self.currentEntityView = entityView
return entityView
}
public func prepareForRender() {
self.renderImage = (self.currentEntityView as? DrawingTextEntityView)?.getRenderImage()
}
}
final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate {
@ -521,8 +526,8 @@ final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate {
}
private var displayFontSize: CGFloat {
let minFontSize = max(10.0, min(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.05)
let maxFontSize = max(10.0, min(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.45)
let minFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.05)
let maxFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.45)
let fontSize = minFontSize + (maxFontSize - minFontSize) * self.textEntity.fontSize
return fontSize
}

View File

@ -53,8 +53,8 @@ final class MarkerTool: DrawingElement {
self.lineWidth = lineWidth
self.arrow = arrow
let minLineWidth = max(10.0, min(drawingSize.width, drawingSize.height) * 0.01)
let maxLineWidth = max(20.0, min(drawingSize.width, drawingSize.height) * 0.09)
let minLineWidth = max(10.0, max(drawingSize.width, drawingSize.height) * 0.01)
let maxLineWidth = max(20.0, max(drawingSize.width, drawingSize.height) * 0.09)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * lineWidth
self.renderLineWidth = lineWidth
@ -244,8 +244,8 @@ final class NeonTool: DrawingElement {
let strokeWidth = min(drawingSize.width, drawingSize.height) * 0.008
let shadowRadius = min(drawingSize.width, drawingSize.height) * 0.03
let minLineWidth = max(1.0, min(drawingSize.width, drawingSize.height) * 0.003)
let maxLineWidth = max(10.0, min(drawingSize.width, drawingSize.height) * 0.09)
let minLineWidth = max(1.0, max(drawingSize.width, drawingSize.height) * 0.003)
let maxLineWidth = max(10.0, max(drawingSize.width, drawingSize.height) * 0.09)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * lineWidth
self.renderStrokeWidth = strokeWidth
@ -378,8 +378,8 @@ final class PencilTool: DrawingElement {
self.lineWidth = lineWidth
self.arrow = arrow
let minLineWidth = max(10.0, min(drawingSize.width, drawingSize.height) * 0.01)
let maxLineWidth = max(20.0, min(drawingSize.width, drawingSize.height) * 0.09)
let minLineWidth = max(10.0, max(drawingSize.width, drawingSize.height) * 0.01)
let maxLineWidth = max(20.0, max(drawingSize.width, drawingSize.height) * 0.09)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * lineWidth
self.renderLineWidth = lineWidth
@ -599,8 +599,8 @@ final class BlurTool: DrawingElement {
self.lineWidth = lineWidth
self.arrow = arrow
let minLineWidth = max(1.0, min(drawingSize.width, drawingSize.height) * 0.003)
let maxLineWidth = max(10.0, min(drawingSize.width, drawingSize.height) * 0.09)
let minLineWidth = max(1.0, max(drawingSize.width, drawingSize.height) * 0.003)
let maxLineWidth = max(10.0, max(drawingSize.width, drawingSize.height) * 0.09)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * lineWidth
self.renderLineWidth = lineWidth
@ -764,8 +764,8 @@ final class EraserTool: DrawingElement {
self.lineWidth = lineWidth
self.arrow = arrow
let minLineWidth = max(1.0, min(drawingSize.width, drawingSize.height) * 0.003)
let maxLineWidth = max(10.0, min(drawingSize.width, drawingSize.height) * 0.09)
let minLineWidth = max(1.0, max(drawingSize.width, drawingSize.height) * 0.003)
let maxLineWidth = max(10.0, max(drawingSize.width, drawingSize.height) * 0.09)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * lineWidth
self.renderLineWidth = lineWidth

View File

@ -113,6 +113,9 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
self.currentEntityView = entityView
return entityView
}
public func prepareForRender() {
}
}
final class DrawingVectorEntityView: DrawingEntityView {
@ -137,15 +140,15 @@ final class DrawingVectorEntityView: DrawingEntityView {
}
private var maxLineWidth: CGFloat {
return max(10.0, min(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.1)
return max(10.0, max(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.1)
}
override func update(animated: Bool) {
self.center = CGPoint(x: self.vectorEntity.drawingSize.width * 0.5, y: self.vectorEntity.drawingSize.height * 0.5)
self.bounds = CGRect(origin: .zero, size: self.vectorEntity.drawingSize)
let minLineWidth = max(10.0, min(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.02)
let maxLineWidth = max(10.0, min(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.1)
let minLineWidth = max(10.0, max(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.01)
let maxLineWidth = max(10.0, max(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.1)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.vectorEntity.lineWidth
self.shapeLayer.path = CGPath.curve(

View File

@ -220,8 +220,8 @@ final class PenTool: DrawingElement {
self.lineWidth = lineWidth
self.arrow = arrow
let minLineWidth = max(1.0, min(drawingSize.width, drawingSize.height) * 0.0015)
let maxLineWidth = max(10.0, min(drawingSize.width, drawingSize.height) * 0.05)
let minLineWidth = max(1.0, max(drawingSize.width, drawingSize.height) * 0.0015)
let maxLineWidth = max(10.0, max(drawingSize.width, drawingSize.height) * 0.05)
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * lineWidth
self.renderLineWidth = lineWidth

View File

@ -618,15 +618,18 @@ private func generateKnobImage() -> UIImage? {
final class TextSizeSliderComponent: Component {
let value: CGFloat
let tag: AnyObject?
let updated: (CGFloat) -> Void
let released: () -> Void
public init(
value: CGFloat,
tag: AnyObject?,
updated: @escaping (CGFloat) -> Void,
released: @escaping () -> Void
) {
self.value = value
self.tag = tag
self.updated = updated
self.released = released
}
@ -638,9 +641,8 @@ final class TextSizeSliderComponent: Component {
return true
}
final class View: UIView, UIGestureRecognizerDelegate {
final class View: UIView, UIGestureRecognizerDelegate, ComponentTaggedView {
private var validSize: CGSize?
private var component: TextSizeSliderComponent?
private let backgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x888888, alpha: 0.3))
private let maskLayer = SimpleShapeLayer()
@ -651,6 +653,17 @@ final class TextSizeSliderComponent: Component {
fileprivate var updated: (CGFloat) -> Void = { _ in }
fileprivate var released: () -> Void = { }
private var component: TextSizeSliderComponent?
public func matches(tag: Any) -> Bool {
if let component = self.component, let componentTag = component.tag {
let tag = tag as AnyObject
if componentTag === tag {
return true
}
}
return false
}
init() {
super.init(frame: CGRect())

View File

@ -242,7 +242,7 @@ private class LegacyPaintTextEntity: LegacyPaintEntity {
}
var angle: CGFloat {
return self.entity.angle
return self.entity.rotation
}
var baseSize: CGSize? {
@ -253,9 +253,9 @@ private class LegacyPaintTextEntity: LegacyPaintEntity {
return false
}
let entity: TGPhotoPaintTextEntity
let entity: DrawingTextEntity
init(entity: TGPhotoPaintTextEntity) {
init(entity: DrawingTextEntity) {
self.entity = entity
}
@ -411,8 +411,13 @@ public final class LegacyPaintEntityRenderer: NSObject, TGPhotoPaintEntityRender
for entity in entities {
if let sticker = entity as? DrawingStickerEntity {
renderEntities.append(LegacyPaintStickerEntity(account: account, entity: sticker))
} else if let _ = entity as? DrawingTextEntity {
// renderEntities.append(LegacyPaintStickerEntity(account: account, entity: sticker))
} else if let text = entity as? DrawingTextEntity {
renderEntities.append(LegacyPaintTextEntity(entity: text))
if let renderSubEntities = text.renderSubEntities {
for entity in renderSubEntities {
renderEntities.append(LegacyPaintStickerEntity(account: account, entity: entity))
}
}
} else if let simpleShape = entity as? DrawingSimpleShapeEntity {
renderEntities.append(LegacyPaintSimpleShapeEntity(entity: simpleShape))
} else if let bubble = entity as? DrawingBubbleEntity {