Skip to content

Commit

Permalink
Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Oct 3, 2022
1 parent 9219417 commit 8f244e8
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions Set-HueLight.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,42 @@ function Set-HueLight
[float[]]
$XY,

# The increment in saturation. This will adjust the intensity of the color
# The increment in saturation. This will adjust the intensity of the color.
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sat_inc')]
[ValidateRange(-1,1)]
[ComponentModel.AmbientValue({
if ($_ -lt 0) {
[Math]::max(-254,
([int][Math]::Floor(([Math]::Abs($_) / 1) * [byte]::maxValue)) * -1
)
} elseif ($_ -gt 0) {
[Math]::min(254,
[int][Math]::Floor(($_ / 1) * [byte]::maxValue)
)
} else {
0
}
})]
[float]
$SaturationIncrement,

# An increment in luminance. This will adjust the brightness of the light
# An increment in luminance. This will adjust the brightness of the light.
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('bri_inc')]
[ComponentModel.AmbientValue({
if ($_ -lt 0) {
[Math]::max(-254,
([int][Math]::Floor(([Math]::Abs($_) / 1) * [byte]::maxValue)) * -1
)
} elseif ($_ -gt 0) {
[Math]::min(254,
[int][Math]::Floor(($_ / 1) * [byte]::maxValue)
)
} else {
0
}
})]
[Alias('LuminanceIncrement')]
[ValidateRange(-1,1)]
[float]
Expand Down

0 comments on commit 8f244e8

Please sign in to comment.