mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-17 16:07:44 +03:00
Use r instead of radius as a universal Macaw shortcut
This commit is contained in:
parent
071bd77bf5
commit
768abfcc47
@ -24,10 +24,10 @@ class FiltersViewController: UIViewController {
|
||||
with: ColorMatrix(values: [0.33, 0, 0, 0, 0.33,
|
||||
0.5, 0.5, 0, 0, 0,
|
||||
0.33, 0.33, 0.33, 0, 1,
|
||||
1, 1, 1, 1, 0])).blur(radius: 4).blend()
|
||||
1, 1, 1, 1, 0])).blur(r: 4).blend()
|
||||
|
||||
let circle = Shape(form: Circle(cx: 30, cy: 70, r: 50), fill: Color.navy, place: Transform(m11: 1, m12: 0, m21: 0, m22: 1, dx: 50, dy: 50))
|
||||
circle.effect = .dropShadow(dx: 10, dy: 10, radius: 5, color: .teal)
|
||||
circle.effect = .dropShadow(dx: 10, dy: 10, r: 5, color: .teal)
|
||||
macawView.node = Group(contents: [yellowRect, rect, circle])
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ open class Effect {
|
||||
self.input = input
|
||||
}
|
||||
|
||||
public static func dropShadow(dx: Double = 0, dy: Double = -3, radius: Double = 3, color: Color = .black) -> Effect? {
|
||||
return OffsetEffect(dx: dx, dy: dy).setColor(to: color).blur(radius: radius).blend()
|
||||
public static func dropShadow(dx: Double = 0, dy: Double = -3, r: Double = 3, color: Color = .black) -> Effect? {
|
||||
return OffsetEffect(dx: dx, dy: dy).setColor(to: color).blur(r: r).blend()
|
||||
}
|
||||
|
||||
public func offset(dx: Double, dy: Double) -> Effect {
|
||||
@ -22,8 +22,8 @@ open class Effect {
|
||||
return ColorMatrixEffect(matrix: ColorMatrix(color: color), input: self)
|
||||
}
|
||||
|
||||
public func blur(radius: Double) -> Effect {
|
||||
return GaussianBlur(radius: radius, input: self)
|
||||
public func blur(r: Double) -> Effect {
|
||||
return GaussianBlur(r: r, input: self)
|
||||
}
|
||||
|
||||
public func blend() -> Effect {
|
||||
|
@ -1,9 +1,9 @@
|
||||
open class GaussianBlur: Effect {
|
||||
|
||||
open let radius: Double
|
||||
open let r: Double
|
||||
|
||||
public init(radius: Double = 0, input: Effect? = nil) {
|
||||
self.radius = radius
|
||||
public init(r: Double = 0, input: Effect? = nil) {
|
||||
self.r = r
|
||||
super.init(input: input)
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class NodeRenderer {
|
||||
var inset: Double = 0
|
||||
for effect in effects {
|
||||
if let blur = effect as? GaussianBlur {
|
||||
inset = min(blur.radius * 6 + 1, 150)
|
||||
inset = min(blur.r * 6 + 1, 150)
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ class NodeRenderer {
|
||||
fileprivate func applyBlur(_ image: CIImage, blur: GaussianBlur) -> CIImage {
|
||||
let filter = CIFilter(name: "CIGaussianBlur")!
|
||||
filter.setDefaults()
|
||||
filter.setValue(Int(blur.radius), forKey: kCIInputRadiusKey)
|
||||
filter.setValue(Int(blur.r), forKey: kCIInputRadiusKey)
|
||||
filter.setValue(image, forKey: kCIInputImageKey)
|
||||
return filter.outputImage!
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ open class SVGParser {
|
||||
}
|
||||
case "feGaussianBlur":
|
||||
if let radius = getDoubleValue(element, attribute: "stdDeviation") {
|
||||
resultingEffect = GaussianBlur(radius: radius, input: currentEffect)
|
||||
resultingEffect = GaussianBlur(r: radius, input: currentEffect)
|
||||
}
|
||||
case "feColorMatrix":
|
||||
if let type = element.allAttributes["type"]?.text {
|
||||
|
Loading…
Reference in New Issue
Block a user