Skip to content

Commit

Permalink
Add protocol OrderedDitheringThresholdConfiguration for Bayer and W…
Browse files Browse the repository at this point in the history
…hiteNoise dithering settings
  • Loading branch information
Eskils committed Oct 18, 2023
1 parent c75e434 commit e93fb44
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Sources/DitheringEngine/PaletteSettingsConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,17 @@ public class FloydSteinbergSettingsConfiguration: PaletteSettingsConfiguration,

}

public class BayerSettingsConfiguration: PaletteSettingsConfiguration {
public protocol OrderedDitheringThresholdConfiguration: PaletteSettingsConfiguration {
var thresholdMapSize: CurrentValueSubject<Int, Never> { get }
var size: Int { get }
}

public class BayerSettingsConfiguration: PaletteSettingsConfiguration, OrderedDitheringThresholdConfiguration {

/// Exponent for size of threshold map m=2^n. mxm. Value between 1 and 6. Default value is 5.
public let thresholdMapSize: CurrentValueSubject<Int, Never>

var size: Int {
public var size: Int {
let exponent = thresholdMapSize.value
return 2 << (exponent - 1)
}
Expand All @@ -301,12 +306,12 @@ public class BayerSettingsConfiguration: PaletteSettingsConfiguration {

}

public class WhiteNoiseSettingsConfiguration: PaletteSettingsConfiguration {
public class WhiteNoiseSettingsConfiguration: PaletteSettingsConfiguration, OrderedDitheringThresholdConfiguration {

/// Exponent for size of threshold map m=2^n. mxm. Value between 7 and 10. Default value is 7.
public let thresholdMapSize: CurrentValueSubject<Int, Never>

var size: Int {
public var size: Int {
let exponent = thresholdMapSize.value
return 2 << (exponent - 1)
}
Expand Down

0 comments on commit e93fb44

Please sign in to comment.