|
1 | 1 | local MER, F, E, I, V, P, G, L = unpack(ElvUI_MerathilisUI) |
| 2 | +F.Color = {} |
2 | 3 |
|
3 | 4 | local _G = _G |
4 | | -local pairs, select, tonumber, unpack = pairs, select, tonumber, unpack |
| 5 | +local pairs, select = pairs, select |
5 | 6 | local abs = abs |
6 | 7 | local min = min |
7 | | -local format = format |
8 | | -local strsub = strsub |
9 | 8 |
|
10 | 9 | local CreateColor = CreateColor |
11 | 10 | local GetClassColor = GetClassColor |
|
403 | 402 |
|
404 | 403 | function F.UnitColor(unit) |
405 | 404 | local r, g, b = 1, 1, 1 |
| 405 | + |
406 | 406 | if UnitIsPlayer(unit) then |
407 | 407 | local class = select(2, UnitClass(unit)) |
408 | 408 | if class then |
@@ -625,19 +625,49 @@ function F.GradientNameCustom(name, unitclass, isTarget) |
625 | 625 | end |
626 | 626 | end |
627 | 627 |
|
628 | | -function F.SetGradient(obj, orientation, minColor, maxColor) |
| 628 | +function F.Color.SetGradient(obj, orientation, minColor, maxColor) |
629 | 629 | if not obj then |
630 | 630 | return |
631 | 631 | end |
632 | 632 |
|
633 | | - local min = minColor or "#000000" |
634 | | - local max = maxColor or "#FFFFFF" |
| 633 | + if not minColor.r or not minColor.g or not minColor.b then |
| 634 | + return |
| 635 | + end |
| 636 | + if not maxColor.r or not maxColor.g or not maxColor.b then |
| 637 | + return |
| 638 | + end |
| 639 | + |
| 640 | + obj:SetGradient(orientation, minColor, maxColor) |
| 641 | +end |
635 | 642 |
|
636 | | - obj:SetGradient(orientation, min, max) |
| 643 | +function F.Color.SetGradientRGB(obj, orientation, r1, g1, b1, a1, r2, g2, b2, a2) |
| 644 | + F.Color.SetGradient(obj, orientation, CreateColor(r1, g1, b1, a1), CreateColor(r2, g2, b2, a2)) |
637 | 645 | end |
638 | 646 |
|
639 | | -function F.SetGradientRGB(obj, orientation, r1, g1, b1, a1, r2, g2, b2, a2) |
640 | | - F.SetGradient(obj, orientation, CreateColor(r1, g1, b1, a1), CreateColor(r2, g2, b2, a2)) |
| 647 | +function F.Color.UpdateGradient(obj, perc, minColor, maxColor) |
| 648 | + if not minColor.r or not minColor.g or not minColor.b then |
| 649 | + return |
| 650 | + end |
| 651 | + if not maxColor.r or not maxColor.g or not maxColor.b then |
| 652 | + return |
| 653 | + end |
| 654 | + |
| 655 | + if perc >= 1 then |
| 656 | + local r, g, b = maxColor:GetRGBA() |
| 657 | + obj:SetRGBA(r, g, b, 1) |
| 658 | + return |
| 659 | + elseif perc <= 0 then |
| 660 | + local r, g, b = minColor:GetRGBA() |
| 661 | + obj:SetRGBA(r, g, b, 1) |
| 662 | + return |
| 663 | + end |
| 664 | + |
| 665 | + obj:SetRGBA( |
| 666 | + (maxColor.r * perc) + (minColor.r * (1 - perc)), |
| 667 | + (maxColor.g * perc) + (minColor.g * (1 - perc)), |
| 668 | + (maxColor.b * perc) + (minColor.b * (1 - perc)), |
| 669 | + 1 |
| 670 | + ) |
641 | 671 | end |
642 | 672 |
|
643 | 673 | local progressColor = { |
|
0 commit comments