mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Misc: Use the ^ operator instead of math.pow (#9550)
And some minor code simplifications, thanks to @zwim ;).
This commit is contained in:
@@ -91,14 +91,12 @@ function SysfsLight:setNaturalBrightness(brightness, warmth)
|
||||
if brightness > 0 then
|
||||
-- On Nickel, the values for white/red/green are roughly linearly dependent
|
||||
-- on the 4th root of brightness and warmth.
|
||||
white = math.min(self.white_gain * math.pow(brightness, self.exponent) *
|
||||
math.pow(100 - warmth, self.exponent) + self.white_offset, 255)
|
||||
white = math.min(self.white_gain * (brightness * (100 - warmth))^self.exponent + self.white_offset, 255)
|
||||
end
|
||||
if warmth > 0 then
|
||||
red = math.min(self.red_gain * math.pow(brightness, self.exponent) *
|
||||
math.pow(warmth, self.exponent) + self.red_offset, 255)
|
||||
green = math.min(self.green_gain * math.pow(brightness, self.exponent) *
|
||||
math.pow(warmth, self.exponent) + self.green_offset, 255)
|
||||
local brightness_warmth_exp = (brightness * warmth)^self.exponent
|
||||
red = math.min(self.red_gain * brightness_warmth_exp + self.red_offset, 255)
|
||||
green = math.min(self.green_gain * brightness_warmth_exp + self.green_offset, 255)
|
||||
end
|
||||
|
||||
white = math.max(white, 0)
|
||||
|
||||
Reference in New Issue
Block a user