Skip to content

Commit

Permalink
Rename VariableBlur to VariableBlurEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
Eskils committed Dec 6, 2023
1 parent 0757ab0 commit 70015bf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ let package = Package(
name: "VariableBlurImageView"),
.testTarget(
name: "VariableBlurImageViewTests",
dependencies: ["VariableBlurImageView"],
resources: [.copy("InputImages/VariableBlurTestImageAlt1.png")]),
dependencies: ["VariableBlurImageView"]),

.executableTarget(name: "GenerateTestImages",
dependencies: ["VariableBlurImageView"])
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Framework for adding variable blur, or progressive blur, to images on iOS and Ma
* [Installation](#installation)
* [Usage](#usage)
* [VariableBlurImageView](#variableblurimageview-1)
* [VariableBlur](#variableblur)
* [VariableBlurEngine](#variableblurengine)
* [Roadmap](#roadmap)
* [Project Organization](#project-organization)
* [Implementing new blur types](#implementing-new-blur-types)
Expand Down Expand Up @@ -110,18 +110,18 @@ public func variableBlur(
)
```

### VariableBlur
### VariableBlurEngine

VariableBlur is an object used to apply progressive blur to CGImages.
VariableBlurEngine is an object used to apply progressive blur to CGImages.

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 variableBlur = VariableBlur()
let variableBlurEngine = VariableBlurEngine()
let leavesImage = UIImage(resource: .leaves)
let blurredImage = variableBlur.applyVerticalVariableBlur(
let blurredImage = variableBlurEngine.applyVerticalVariableBlur(
toImage: leavesImage,
startPoint: 0,
endPoint: leavesImage.size.height / 4,
Expand Down Expand Up @@ -205,7 +205,7 @@ func testVerticalVariableBlur() throws {
inputImageName: inputImageName,
expectedImageName: "\(inputImageName)-VerticalBlur...",
afterPerformingImageOperations: { input in
try variableBlur.applyVerticalVariableBlur(
try variableBlurEngine.applyVerticalVariableBlur(
toImage: input,
startPoint: 0,
endPoint: CGFloat(input.height / 2),
Expand All @@ -224,7 +224,7 @@ Measuring performance can be done with the `provideInputImage(inputImageName:)`
func testPerformanceOfVerticalVariableBlur() throws {
let inputImage = try provideInputImage(inputImageName: inputImageName)
measure {
_ = try! variableBlur.applyVerticalVariableBlur(
_ = try! variableBlurEngine.applyVerticalVariableBlur(
toImage: inputImage,
startPoint: 0,
endPoint: CGFloat(inputImage.height / 2),
Expand All @@ -245,7 +245,7 @@ Use the `from(image:named:performingOperations:)` method on OutputImage, and add
// Vertical blur
OutputImage
.from(image: inputImage, named: "\(name)-Vertical...") { input in
try variableBlur.applyVerticalVariableBlur(
try variableBlurEngine.applyVerticalVariableBlur(
toImage: input,
startPoint: 0,
endPoint: CGFloat(input.height / 2),
Expand Down
8 changes: 4 additions & 4 deletions Sources/GenerateTestImages/GenerateImages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import VariableBlurImageView

struct GenerateImages {

let variableBlur = VariableBlur()
let variableBlurEngine = VariableBlurEngine()

func imageTransforms(inputImage: CGImage, name: String, outputImages: inout [OutputImage]) {
// Vertical blur
OutputImage
.from(image: inputImage, named: "\(name)-VerticalBlur-(0,20)-to-(50h,0)") { input in
try variableBlur.applyVerticalVariableBlur(
try variableBlurEngine.applyVerticalVariableBlur(
toImage: input,
startPoint: 0,
endPoint: CGFloat(input.height / 2),
Expand All @@ -29,7 +29,7 @@ struct GenerateImages {
// Horizontal blur
OutputImage
.from(image: inputImage, named: "\(name)-HorizontalBlur-(0,20)-to-(50w,0)") { input in
try variableBlur.applyHorizontalVariableBlur(
try variableBlurEngine.applyHorizontalVariableBlur(
toImage: input,
startPoint: 0,
endPoint: CGFloat(input.width / 2),
Expand All @@ -42,7 +42,7 @@ struct GenerateImages {
// Variable blur
OutputImage
.from(image: inputImage, named: "\(name)-VariableBlur-((10w,15h),20)-to-((60w,40h),0)") { input in
try variableBlur.applyVariableBlur(
try variableBlurEngine.applyVariableBlur(
toImage: input,
startPoint: CGPoint(x: CGFloat(input.width) * 0.1, y: CGFloat(input.height) * 0.15),
endPoint: CGPoint(x: CGFloat(input.width) * 0.6, y: CGFloat(input.height) * 0.4),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// VariableBlur.swift
// VariableBlurEngine.swift
//
//
// Created by Eskil Gjerde Sviggum on 06/12/2023.
Expand All @@ -8,7 +8,7 @@
import Foundation
import CoreGraphics

public struct VariableBlur {
public struct VariableBlurEngine {

private let variableBlurMetal = VariableBlurMetal()

Expand Down
8 changes: 4 additions & 4 deletions Sources/VariableBlurImageView/VariableBlurImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import UIKit

open class VariableBlurImageView: UIImageView {

private let variableBlur = VariableBlur()
private let variableBlurEngine = VariableBlurEngine()

public func verticalVariableBlur(image: UIImage, startPoint: CGFloat, endPoint: CGFloat, startRadius: CGFloat, endRadius: CGFloat) {
transformAllVariations(ofImage: image) { cgImage in
try self.variableBlur.applyVerticalVariableBlur(
try self.variableBlurEngine.applyVerticalVariableBlur(
toImage: cgImage,
startPoint: startPoint,
endPoint: endPoint,
Expand All @@ -25,7 +25,7 @@ open class VariableBlurImageView: UIImageView {

public func horizontalVariableBlur(image: UIImage, startPoint: CGFloat, endPoint: CGFloat, startRadius: CGFloat, endRadius: CGFloat) {
transformAllVariations(ofImage: image) { cgImage in
try self.variableBlur.applyHorizontalVariableBlur(
try self.variableBlurEngine.applyHorizontalVariableBlur(
toImage: cgImage,
startPoint: startPoint,
endPoint: endPoint,
Expand All @@ -37,7 +37,7 @@ open class VariableBlurImageView: UIImageView {

public func variableBlur(image: UIImage, startPoint: CGPoint, endPoint: CGPoint, startRadius: CGFloat, endRadius: CGFloat) {
transformAllVariations(ofImage: image) { cgImage in
try self.variableBlur.applyVariableBlur(
try self.variableBlurEngine.applyVariableBlur(
toImage: cgImage,
startPoint: startPoint,
endPoint: endPoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CoreImage

final class VariableBlurImageViewTests: XCTestCase {

let variableBlur = VariableBlur()
let variableBlurEngine = VariableBlurEngine()

let bundle = Bundle.module

Expand All @@ -19,7 +19,7 @@ final class VariableBlurImageViewTests: XCTestCase {
inputImageName: inputImageName,
expectedImageName: "\(inputImageName)-VerticalBlur-(0,20)-to-(50h,0)",
afterPerformingImageOperations: { input in
try variableBlur.applyVerticalVariableBlur(
try variableBlurEngine.applyVerticalVariableBlur(
toImage: input,
startPoint: 0,
endPoint: CGFloat(input.height / 2),
Expand All @@ -34,7 +34,7 @@ final class VariableBlurImageViewTests: XCTestCase {
func testPerformanceOfVerticalVariableBlur() throws {
let inputImage = try provideInputImage(inputImageName: inputImageName)
measure {
_ = try! variableBlur.applyVerticalVariableBlur(
_ = try! variableBlurEngine.applyVerticalVariableBlur(
toImage: inputImage,
startPoint: 0,
endPoint: CGFloat(inputImage.height / 2),
Expand All @@ -50,7 +50,7 @@ final class VariableBlurImageViewTests: XCTestCase {
inputImageName: inputImageName,
expectedImageName: "\(inputImageName)-HorizontalBlur-(0,20)-to-(50w,0)",
afterPerformingImageOperations: { input in
try variableBlur.applyHorizontalVariableBlur(
try variableBlurEngine.applyHorizontalVariableBlur(
toImage: input,
startPoint: 0,
endPoint: CGFloat(input.width / 2),
Expand All @@ -65,7 +65,7 @@ final class VariableBlurImageViewTests: XCTestCase {
func testPerformanceOfHorizontalVariableBlur() throws {
let inputImage = try provideInputImage(inputImageName: inputImageName)
measure {
_ = try! variableBlur.applyHorizontalVariableBlur(
_ = try! variableBlurEngine.applyHorizontalVariableBlur(
toImage: inputImage,
startPoint: 0,
endPoint: CGFloat(inputImage.width / 2),
Expand All @@ -81,7 +81,7 @@ final class VariableBlurImageViewTests: XCTestCase {
inputImageName: inputImageName,
expectedImageName: "\(inputImageName)-VariableBlur-((10w,15h),20)-to-((60w,40h),0)",
afterPerformingImageOperations: { input in
try variableBlur.applyVariableBlur(
try variableBlurEngine.applyVariableBlur(
toImage: input,
startPoint: CGPoint(x: CGFloat(input.width) * 0.1, y: CGFloat(input.height) * 0.15),
endPoint: CGPoint(x: CGFloat(input.width) * 0.6, y: CGFloat(input.height) * 0.4),
Expand All @@ -96,7 +96,7 @@ final class VariableBlurImageViewTests: XCTestCase {
func testPerformanceOfVariableBlur() throws {
let inputImage = try provideInputImage(inputImageName: inputImageName)
measure {
_ = try! variableBlur.applyVariableBlur(
_ = try! variableBlurEngine.applyVariableBlur(
toImage: inputImage,
startPoint: CGPoint(x: CGFloat(inputImage.width) * 0.1, y: CGFloat(inputImage.height) * 0.15),
endPoint: CGPoint(x: CGFloat(inputImage.width) * 0.6, y: CGFloat(inputImage.height) * 0.4),
Expand Down

0 comments on commit 70015bf

Please sign in to comment.