File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -447,6 +447,25 @@ function! quickui#palette#name2index(name, ...)
447447endfunc
448448
449449
450+ " ----------------------------------------------------------------------
451+ " alpha blend
452+ " ----------------------------------------------------------------------
453+ function ! quickui#palette#blend (c1, c2, alpha)
454+ let c1 = a: c1
455+ let c2 = a: c2
456+ let alpha = a: alpha
457+ if type (c1) == 0 && type (c2) == 0
458+ return (c1 * (255 - alpha) + c2 * alpha) / 255
459+ endif
460+ let dst = quickui#palette#hex2rgb (c1)
461+ let src = quickui#palette#hex2rgb (c2)
462+ let r = (dst[0 ] * (255 - alpha) + src [0 ] * alpha) / 255
463+ let g = (dst[1 ] * (255 - alpha) + src [1 ] * alpha) / 255
464+ let b = (dst[2 ] * (255 - alpha) + src [2 ] * alpha) / 255
465+ return printf (' #%02x%02x%02x' , r , g , b )
466+ endfunc
467+
468+
450469" ----------------------------------------------------------------------
451470" benchmark
452471" ----------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments