@@ -326,7 +326,7 @@ function sample(wv)
326
326
end
327
327
return i
328
328
end
329
- function rand_argmin (a, tor= 50 )
329
+ function rand_argmin (a, tor= 10 )
330
330
th = minimum (a) * tor
331
331
ind_weight = [(i, 1 / (ai + 1e-6 )^ 2 ) for (i, ai) in enumerate (a) if ai <= th]
332
332
i = sample (last .(ind_weight))
@@ -346,9 +346,9 @@ function randommaskcolor(colors)
346
346
colors = [(c. h, c. s, c. l) for c in colors]
347
347
rl = 77 # 256*0.3
348
348
rl2 = 102 # 256*0.4
349
- l_slots = zeros (256 + 2 rl2) .+ 0.01
349
+ l_slots = zeros (256 + 2 rl2) .+ 0.00625
350
350
rh = 30
351
- h_slots = zeros (360 ) .+ 0.05
351
+ h_slots = zeros (360 ) .+ 0.00625
352
352
s2max = 0.6
353
353
win_l = window (2 rl + 1 )
354
354
win_l2 = window (2 rl2 + 1 )
@@ -391,7 +391,10 @@ function randommaskcolor(colors)
391
391
w[51 : end - 51 ] .+ = window (256 - 101 , 7 ) # 中间调回避
392
392
array_max! (@view (w[1 : end ÷ 2 ]), 3 ) # 高亮偏好
393
393
l_slots .*= w
394
- l2 = rand_argmin (l_slots) / 255
394
+ l2 = (rand_argmin (l_slots, 10 ) - 1 ) / 255
395
+ # 10 > max(3, 1+7),不会截断概率,故高亮和中间调仅是偏好策略
396
+ # 0.00625*8*10=0.5,截断最高能达到明度避让策略最高点(1.0)的一半,
397
+ # 相对应地,保证明度差起码有sqrt(1-0.5/1.0)*(77/256)=0.21
395
398
s2 = rand () * s2max
396
399
" #" * hex (HSL (h2, s2, l2))
397
400
end
0 commit comments