Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Variable-ind committed Oct 25, 2024
1 parent 04ef4e6 commit 00127dc
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/Palette/Palette.gd
Original file line number Diff line number Diff line change
Expand Up @@ -292,23 +292,30 @@ func sort(option: Palettes.SortOptions) -> void:
# gdlint: ignore=max-line-length
# https://github.com/bottosson/bottosson.github.io/blob/master/misc/colorpicker/colorconversion.js#L519
sort_method = func(a: PaletteColor, b: PaletteColor):
# function that returns OKHSL luminance
var lum : Callable = func(c: Color):
# function that returns OKHSL lightness
var lum: Callable = func(c: Color):
var l = 0.4122214708 * (c.r) + 0.5363325363 * (c.g) + 0.0514459929 * (c.b)
var m = 0.2119034982 * (c.r) + 0.6806995451 * (c.g) + 0.1073969566 * (c.b)
var s = 0.0883024619 * (c.r) + 0.2817188376 * (c.g) + 0.6299787005 * (c.b);
var l_ = pow(l, 1/3.0);
var m_ = pow(m, 1/3.0);
var s_ = pow(s, 1/3.0);
var s = 0.0883024619 * (c.r) + 0.2817188376 * (c.g) + 0.6299787005 * (c.b)
var l_ = pow(l, 1/3.0)
var m_ = pow(m, 1/3.0)
var s_ = pow(s, 1/3.0)
var oklab_l = 0.2104542553 * l_ + 0.7936177850 * m_ - 0.0040720468 * s_
# calculating toe
var k_1 = 0.206
var k_2 = 0.03
var k_3 = (1+k_1)/(1+k_2)
return 0.5 * (
k_3 * oklab_l - k_1
+ sqrt(
(k_3 * oklab_l - k_1) * (k_3 * oklab_l - k_1) + 4 * k_2 * k_3 * oklab_l)
var k_3 = (1 + k_1) / (1 + k_2)
return (
0.5
* (
k_3 * oklab_l
- k_1
+ sqrt(
(
k_3 * oklab_l - k_1) * (k_3 * oklab_l - k_1)
+ 4 * k_2 * k_3 * oklab_l
)
)
)
return lum.call(a.color.srgb_to_linear()) < lum.call(b.color.srgb_to_linear())
Palettes.SortOptions.RED:
Expand Down

0 comments on commit 00127dc

Please sign in to comment.