Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed Jul 28, 2024
1 parent f6d44ee commit 3e2de5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions Dev/Sources/SwiftUIDemo/DemoFilterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct DemoFilterView: View {

struct MotionBlurFilter: Filtering {

let kernel = CIKernel(source:
let kernel = CIKernel(source:
"""
kernel vec4 motionBlur(sampler image, vec2 size, float sampleCount, float start, float blur) {
int sampleCountInt = int(floor(sampleCount));
Expand All @@ -63,11 +63,18 @@ struct DemoFilterView: View {

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

let base = Double(sqrt(pow(image.extent.width, 2) + pow(image.extent.height, 2)))
let c = base / 20
let radius = c * 10 / 10

let args = [image,
CIVector(x: image.extent.width, y: image.extent.height),
CIVector(
x: image.extent.width,
y: image.extent.height
),
20,
0.2,
20,
radius,
] as [Any]

return kernel.apply(
Expand Down Expand Up @@ -102,7 +109,7 @@ struct DemoFilterView: View {

ViewHost(instantiated: ImagePreviewView(editingStack: editingStack))

SwiftUICropView(editingStack: editingStack)
SwiftUICropView(editingStack: editingStack, contentInset: .zero)
.clipped()

VStack {
Expand Down
2 changes: 1 addition & 1 deletion Sources/BrightroomUI/Shared/Components/Crop/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ extension CropView {

let size = PixelAspectRatio(crop.cropExtent.size)
.sizeThatFits(in: bounds.size)

return .init(
origin: .init(
x: contentInset.left + ((bounds.width - size.width) / 2) /* centering offset */,
Expand Down

0 comments on commit 3e2de5e

Please sign in to comment.