@@ -125,7 +125,12 @@ function Color.from_hex(c)
125
125
end
126
126
end
127
127
128
- return Color .init (bit .rshift (n , 24 ) / 0xff , bit .band (bit .rshift (n , 16 ), 0xff ) / 0xff , bit .band (bit .rshift (n , 8 ), 0xff ) / 0xff , bit .band (n , 0xff ) / 0xff )
128
+ return Color .init (
129
+ bit .rshift (n , 24 ) / 0xff ,
130
+ bit .band (bit .rshift (n , 16 ), 0xff ) / 0xff ,
131
+ bit .band (bit .rshift (n , 8 ), 0xff ) / 0xff ,
132
+ bit .band (n , 0xff ) / 0xff
133
+ )
129
134
end
130
135
131
136
--- Create a Color from HSV value
217
222
--- @return integer
218
223
function Color :to_hex (with_alpha )
219
224
local ls , bor , fl = bit .lshift , bit .bor , math.floor
220
- local n = bor (bor (ls (fl ((self .red * 0xff ) + 0.5 ), 16 ), ls (fl ((self .green * 0xff ) + 0.5 ), 8 )), fl ((self .blue * 0xff ) + 0.5 ))
225
+ local n = bor (
226
+ bor (ls (fl ((self .red * 0xff ) + 0.5 ), 16 ), ls (fl ((self .green * 0xff ) + 0.5 ), 8 )),
227
+ fl ((self .blue * 0xff ) + 0.5 )
228
+ )
221
229
return with_alpha and bit .lshift (n , 8 ) + (self .alpha * 0xff ) or n
222
230
end
223
231
251
259
--- @param f number Float [0,1]. 0 being this and 1 being other
252
260
--- @return Color
253
261
function Color :blend (other , f )
254
- return Color .init ((other .red - self .red ) * f + self .red , (other .green - self .green ) * f + self .green , (other .blue - self .blue ) * f + self .blue , self .alpha )
262
+ return Color .init (
263
+ (other .red - self .red ) * f + self .red ,
264
+ (other .green - self .green ) * f + self .green ,
265
+ (other .blue - self .blue ) * f + self .blue ,
266
+ self .alpha
267
+ )
255
268
end
256
269
257
270
--- Returns a new shaded color.
@@ -261,7 +274,12 @@ function Color:shade(f)
261
274
local t = f < 0 and 0 or 1.0
262
275
local p = f < 0 and f * - 1.0 or f
263
276
264
- return Color .init ((t - self .red ) * p + self .red , (t - self .green ) * p + self .green , (t - self .blue ) * p + self .blue , self .alpha )
277
+ return Color .init (
278
+ (t - self .red ) * p + self .red ,
279
+ (t - self .green ) * p + self .green ,
280
+ (t - self .blue ) * p + self .blue ,
281
+ self .alpha
282
+ )
265
283
end
266
284
267
285
--- Adds value of `v` to the `value` of the current color. This returns either
0 commit comments