Skip to content

Commit

Permalink
Add DOCC documentation
Browse files Browse the repository at this point in the history
Add SwiftPackageIndex configueration file
  • Loading branch information
Eskils committed Dec 7, 2023
1 parent 6ba1ca5 commit 80d722c
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1
builder:
configs:
- documentation_targets: [Target1, Target2]
platform: ios
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,4 @@ OutputImage

## Contributing to VariableBlurImageView

Contributions are welcome and encouraged. Feel free to check out the project, submit issues and code patches.
Contributions are welcome and encouraged. Feel free to check out the project, submit issues and code patches.
32 changes: 32 additions & 0 deletions Sources/VariableBlurImageView/Documentation.docc/Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ``VariableBlurImageView``

Add variable blur to images on iOS and MacCatalyst. Works with UIKit using Metal.

## Overview

This frameworks provides an UIImageView subclass and a class to apply variable blur to CGImages.

![iOS app with a vertical variable blur from the top to the middle](iOSAppDemo1.png)

#### Vertical
![Vertical progressive blur](VariableBlurTestImage-VerticalBlur.png)

#### Horizontal
![Horizontal progressive blur](VariableBlurTestImage-HorizontalBlur.png)

#### Between two points
![Progressive blur between two points](VariableBlurTestImage-VariableBlur.png)

## Topics

### Variable blur ImageView

- ``VariableBlurImageView/VariableBlurImageView/variableBlur(image:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurImageView/VariableBlurImageView/verticalVariableBlur(image:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurImageView/VariableBlurImageView/horizontalVariableBlur(image:startPoint:endPoint:startRadius:endRadius:)``

### Applying variable blur to images

- ``VariableBlurEngine/applyVariableBlur(toImage:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurEngine/applyVerticalVariableBlur(toImage:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurEngine/applyHorizontalVariableBlur(toImage:startPoint:endPoint:startRadius:endRadius:)``
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ``VariableBlurImageView/VariableBlurEngine``

Apply variable blur to CGImages.

## Overview

You provide a CGImage, start point, end point, and their respective blur radiuses. A new CGImage is returned with the variable blur effect.

### Example

```swift
let variableBlurEngine = VariableBlurEngine()
let leavesImage = UIImage(resource: .leaves)
let blurredImage = variableBlurEngine.applyVerticalVariableBlur(
toImage: leavesImage,
startPoint: 0,
endPoint: leavesImage.size.height / 4,
startRadius: 15,
endRadius: 0
)
```

## Topics

- ``VariableBlurEngine/applyVariableBlur(toImage:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurEngine/applyVerticalVariableBlur(toImage:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurEngine/applyHorizontalVariableBlur(toImage:startPoint:endPoint:startRadius:endRadius:)``
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ``VariableBlurImageView/VariableBlurImageView``

Subclass of `UIImageView` which asynchronously applies the wanted progressive blur.

## Overview

You provide an image, start point, end point, and their respective blur radiuses.

### Example

```swift
let imageView = VariableBlurImageView()
imageView.contentMode = .scaleAspectFill
let backgroundImage = UIImage(resource: .onboardingBackground)
imageView.verticalVariableBlur(
image: backgroundImage,
startPoint: 0,
endPoint: backgroundImage.size.height / 4,
startRadius: 15,
endRadius: 0
)
```

## Topics

- ``VariableBlurImageView/VariableBlurImageView/variableBlur(image:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurImageView/VariableBlurImageView/verticalVariableBlur(image:startPoint:endPoint:startRadius:endRadius:)``
- ``VariableBlurImageView/VariableBlurImageView/horizontalVariableBlur(image:startPoint:endPoint:startRadius:endRadius:)``
23 changes: 23 additions & 0 deletions Sources/VariableBlurImageView/VariableBlurEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public struct VariableBlurEngine {

public init() {}

/// Adds a vertical variable blur to your image.
/// This method works asynchronously.
/// - Parameters:
/// - image: The image to blur.
/// - startPoint: The vertical start point. In UIKit coordinates.
/// - endPoint: The vertical end point. In UIKit coordinates.
/// - startRadius: The blur radius at the start point.
/// - endRadius: The blur radius ar the end point.
public func applyVerticalVariableBlur(toImage image: CGImage, startPoint: CGFloat, endPoint: CGFloat, startRadius: CGFloat, endRadius: CGFloat) throws -> CGImage {
return try variableBlurMetal.variableBlurVertical(
image: image,
Expand All @@ -24,6 +32,14 @@ public struct VariableBlurEngine {
)
}

/// Adds a horizontal variable blur to your image.
/// This method works asyncronously.
/// - Parameters:
/// - image: The image to blur.
/// - startPoint: The horizontal start point. In UIKit coordinates.
/// - endPoint: The horizontal end point. In UIKit coordinates.
/// - startRadius: The blur radius at the start point.
/// - endRadius: The blur radius ar the end point.
public func applyHorizontalVariableBlur(toImage image: CGImage, startPoint: CGFloat, endPoint: CGFloat, startRadius: CGFloat, endRadius: CGFloat) throws -> CGImage {
return try variableBlurMetal.variableBlurHorizontal(
image: image,
Expand All @@ -34,6 +50,13 @@ public struct VariableBlurEngine {
)
}

/// Adds a variable blur between two points to your image.
/// - Parameters:
/// - image: The image to blur.
/// - startPoint: The start point. In UIKit coordinates.
/// - endPoint: The end point. In UIKit coordinates.
/// - startRadius: The blur radius at the start point.
/// - endRadius: The blur radius ar the end point.
public func applyVariableBlur(toImage image: CGImage, startPoint: CGPoint, endPoint: CGPoint, startRadius: CGFloat, endRadius: CGFloat) throws -> CGImage {
return try variableBlurMetal.variableBlur(
image: image,
Expand Down
24 changes: 24 additions & 0 deletions Sources/VariableBlurImageView/VariableBlurImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ open class VariableBlurImageView: UIImageView {

private let variableBlurEngine = VariableBlurEngine()

/// Adds a vertical variable blur to your image.
/// This method works asynchronously.
/// - Parameters:
/// - image: The image to blur.
/// - startPoint: The vertical start point. In UIKit coordinates.
/// - endPoint: The vertical end point. In UIKit coordinates.
/// - startRadius: The blur radius at the start point.
/// - endRadius: The blur radius ar the end point.
public func verticalVariableBlur(image: UIImage, startPoint: CGFloat, endPoint: CGFloat, startRadius: CGFloat, endRadius: CGFloat) {
transformAllVariations(ofImage: image, variationTransformMode: .sequential) { cgImage in
try self.variableBlurEngine.applyVerticalVariableBlur(
Expand All @@ -23,6 +31,14 @@ open class VariableBlurImageView: UIImageView {
}
}

/// Adds a horizontal variable blur to your image.
/// This method works asyncronously.
/// - Parameters:
/// - image: The image to blur.
/// - startPoint: The horizontal start point. In UIKit coordinates.
/// - endPoint: The horizontal end point. In UIKit coordinates.
/// - startRadius: The blur radius at the start point.
/// - endRadius: The blur radius ar the end point.
public func horizontalVariableBlur(image: UIImage, startPoint: CGFloat, endPoint: CGFloat, startRadius: CGFloat, endRadius: CGFloat) {
transformAllVariations(ofImage: image, variationTransformMode: .sequential) { cgImage in
try self.variableBlurEngine.applyHorizontalVariableBlur(
Expand All @@ -35,6 +51,14 @@ open class VariableBlurImageView: UIImageView {
}
}

/// Adds a variable blur between two points to your image.
/// This method works asyncronously.
/// - Parameters:
/// - image: The image to blur.
/// - startPoint: The start point. In UIKit coordinates.
/// - endPoint: The end point. In UIKit coordinates.
/// - startRadius: The blur radius at the start point.
/// - endRadius: The blur radius ar the end point.
public func variableBlur(image: UIImage, startPoint: CGPoint, endPoint: CGPoint, startRadius: CGFloat, endRadius: CGFloat) {
transformAllVariations(ofImage: image, variationTransformMode: .sequential) { cgImage in
try self.variableBlurEngine.applyVariableBlur(
Expand Down

0 comments on commit 80d722c

Please sign in to comment.