Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed May 28, 2024
1 parent c5851c4 commit b9a4fe9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
7 changes: 2 additions & 5 deletions Dev/Sources/SwiftUIDemo/DemoFilterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import UIKit
struct DemoFilterView: View {

struct InvertFilter: Filtering {

let key: FilterKey = .init(rawValue: String(describing: InvertFilter.self))

func apply(to image: CIImage, sourceImage: CIImage) -> CIImage {
image
.applyingFilter("CIColorInvert")
Expand All @@ -37,9 +34,9 @@ struct DemoFilterView: View {
.onChange(of: toggle) { newValue in
editingStack.set(filters: {
if newValue {
$0.additionalFilters[invertFilter.key] = invertFilter.asAny()
$0.additionalFilters = [invertFilter.asAny()]
} else {
$0.additionalFilters[invertFilter.key] = nil
$0.additionalFilters = []
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/BrightroomEngine/Core/EditingStack.Edit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension EditingStack {
public var vignette: FilterVignette?
public var fade: FilterFade?

public var additionalFilters: [FilterKey : AnyFilter] = [:]
public var additionalFilters: [AnyFilter] = []

func makeFilters() -> [AnyFilter] {
return (
Expand Down Expand Up @@ -95,7 +95,7 @@ extension EditingStack {
vignette?.asAny(),

] as [AnyFilter?])
+ Array(additionalFilters.values)
+ additionalFilters
)
.compactMap { $0 }
}
Expand Down
10 changes: 0 additions & 10 deletions Sources/BrightroomEngine/Core/Filtering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ enum RadiusCalculator {
}
}

public struct FilterKey: Hashable {

public let rawValue: String

public init(rawValue: String) {
self.rawValue = rawValue
}

}

public protocol Filtering: Hashable {

func apply(to image: CIImage, sourceImage: CIImage) -> CIImage
Expand Down

0 comments on commit b9a4fe9

Please sign in to comment.