Skip to content

Commit

Permalink
[TextStyle@init()] Fix: Remove unintentional recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
guhungry committed Jul 13, 2024
1 parent 341eb3c commit 8eae300
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions WCPhotoManipulator/Models/TextStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import UIKit
/// - shadowOffsetX: The horizontal offset of the shadow. Default is 0.
/// - shadowOffsetY: The vertical offset of the shadow. Default is 0.
/// - shadowColor: The color of the shadow. Default is nil.
@objc public init(color: UIColor, font: UIFont, thickness: CGFloat = 0, rotation: CGFloat = 0, shadowRadius: CGFloat = 0, shadowOffsetX: Int = 0, shadowOffsetY: Int = 0, shadowColor: UIColor? = nil) {
@objc public init(color: UIColor, font: UIFont, thickness: CGFloat, rotation: CGFloat, shadowRadius: CGFloat, shadowOffsetX: Int, shadowOffsetY: Int, shadowColor: UIColor?) {
self.color = color
self.font = font
self.thickness = thickness
Expand All @@ -61,7 +61,7 @@ import UIKit
/// - color: The color of the text.
/// - font: The font of the text.
@objc public convenience init(color: UIColor, font: UIFont) {
self.init(color: color, font: font)
self.init(color: color, font: font, thickness: 0)
}

/// Convenience initializer with color, font, and thickness.
Expand All @@ -71,7 +71,7 @@ import UIKit
/// - font: The font of the text.
/// - thickness: The thickness of the text.
@objc public convenience init(color: UIColor, font: UIFont, thickness: CGFloat) {
self.init(color: color, font: font, thickness: thickness)
self.init(color: color, font: font, thickness: thickness, rotation: 0)
}

/// Convenience initializer with color, font, thickness, and rotation.
Expand All @@ -82,7 +82,7 @@ import UIKit
/// - thickness: The thickness of the text.
/// - rotation: The rotation angle of the text in degrees.
@objc public convenience init(color: UIColor, font: UIFont, thickness: CGFloat, rotation: CGFloat) {
self.init(color: color, font: font, thickness: thickness, rotation: rotation)
self.init(color: color, font: font, thickness: thickness, rotation: rotation, shadowRadius: 0, shadowOffsetX: 0, shadowOffsetY: 0, shadowColor: nil)
}

/// Convenience initializer with color, size, and other optional properties.
Expand All @@ -96,7 +96,7 @@ import UIKit
/// - shadowOffsetX: The horizontal offset of the shadow. Default is 0.
/// - shadowOffsetY: The vertical offset of the shadow. Default is 0.
/// - shadowColor: The color of the shadow. Default is nil.
@objc public convenience init(color: UIColor, size: CGFloat, thickness: CGFloat = 0, rotation: CGFloat = 0, shadowRadius: CGFloat = 0, shadowOffsetX: Int = 0, shadowOffsetY: Int = 0, shadowColor: UIColor? = nil) {
@objc public convenience init(color: UIColor, size: CGFloat, thickness: CGFloat, rotation: CGFloat, shadowRadius: CGFloat, shadowOffsetX: Int, shadowOffsetY: Int, shadowColor: UIColor?) {
self.init(color: color, font: UIFont.systemFont(ofSize: size), thickness: thickness, rotation: rotation, shadowRadius: shadowRadius, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowColor: shadowColor)
}

Expand All @@ -106,7 +106,7 @@ import UIKit
/// - color: The color of the text.
/// - size: The size of the text's font.
@objc public convenience init(color: UIColor, size: CGFloat) {
self.init(color: color, size: size)
self.init(color: color, size: size, thickness: 0)
}

/// Convenience initializer with color, size, and thickness.
Expand All @@ -116,7 +116,7 @@ import UIKit
/// - size: The size of the text's font.
/// - thickness: The thickness of the text.
@objc public convenience init(color: UIColor, size: CGFloat, thickness: CGFloat) {
self.init(color: color, size: size, thickness: thickness)
self.init(color: color, size: size, thickness: thickness, rotation: 0)
}

/// Convenience initializer with color, size, thickness, and rotation.
Expand All @@ -127,7 +127,7 @@ import UIKit
/// - thickness: The thickness of the text.
/// - rotation: The rotation angle of the text in degrees.
@objc public convenience init(color: UIColor, size: CGFloat, thickness: CGFloat, rotation: CGFloat) {
self.init(color: color, size: size, thickness: thickness, rotation: rotation)
self.init(color: color, size: size, thickness: thickness, rotation: rotation, shadowRadius: 0, shadowOffsetX: 0, shadowOffsetY: 0, shadowColor: nil)
}

public override var description: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class UIImage_PhotoManipulatorSwiftTests: XCTestCase {
image = UIImage.init(namedTest: "background.jpg")
XCTAssertNotNil(image)

let style = TextStyle(color: .blue, font: UIFont.systemFont(ofSize: 102), rotation: 14, shadowRadius: 3, shadowOffsetX: 4, shadowOffsetY: 10, shadowColor: UIColor.green)
let style = TextStyle(color: .blue, font: UIFont.systemFont(ofSize: 102), thickness: 0, rotation: 14, shadowRadius: 3, shadowOffsetX: 4, shadowOffsetY: 10, shadowColor: UIColor.green)
image = image.drawText("Draw Shadow", position: CGPoint(x: 15, y: 66), style: style)
XCTAssertNotNil(image)
XCTAssertEqual(image.size, CGSize(width: 800, height: 530))
Expand Down

0 comments on commit 8eae300

Please sign in to comment.