Advertisement
Guest User

Untitled

a guest
Mar 15th, 2022
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. local Theme = { };
  2.  
  3. --
  4.  
  5. Theme.Settings = { };
  6.  
  7. -- Theme Settings
  8.  
  9. Theme.Settings.Color = { ['R'] = 255; ['G'] = 255; ['B'] = 255; ['A'] = 255; }; --// Red, Green, Blue, Alpha/Transparency.
  10. Theme.Settings.Rainbow = true; --// If true then it will ignore Settings.Color. If false then the menus color will stick to Settings.Color.
  11. Theme.Settings.TransitionSpeed = 10; --// Indicates how many secounds it should take to transition all the way through the colors.
  12. Theme.Settings.Fps = 60; --// Just set your usual fps and it should alighn the transition speed pretty acuratly.
  13.  
  14. -- SetColor
  15.  
  16. function Theme:SetColor( Color )
  17. local R, G, B, Alpha = math.floor( tonumber( Color.R ) ), math.floor( tonumber( Color.G ) ), math.floor( tonumber( Color.B ) ), math.floor( tonumber( Color.A ) );
  18.  
  19. menu.set_color(menu_color.FrameBgActive, R, G, B);
  20.  
  21. menu.set_color(menu_color.SliderGrab, R, G, B);
  22. menu.set_color(menu_color.SliderGrabActive, R, G, B);
  23.  
  24. menu.set_color(menu_color.CheckMark, R, G, B);
  25.  
  26. menu.set_color(menu_color.ScrollbarGrab, R, G, B);
  27. menu.set_color(menu_color.ScrollbarGrabHovered, R, G, B);
  28. menu.set_color(menu_color.ScrollbarGrabActive, R, G, B);
  29.  
  30. menu.set_widget_color(menu_widget_color.Icons, R, G, B, Alpha);
  31. menu.set_widget_color(menu_widget_color.ScrollbarGrab, R, G, B, Alpha );
  32. menu.set_widget_color(menu_widget_color.ScrollbarGrabHovered, R, G, B, Alpha);
  33. menu.set_widget_color(menu_widget_color.ScrollbarGrabActive, R, G, B, Alpha);
  34.  
  35. menu.set_widget_color(menu_widget_color.TitleName, R, G, B, Alpha);
  36. menu.set_widget_color(menu_widget_color.NotifyRectLine, R, G, B, Alpha);
  37. menu.set_widget_color(menu_widget_color.NotifyIcon, R, G, B, Alpha);
  38. menu.set_widget_color(menu_widget_color.NotifyDefault, R, G, B, Alpha);
  39. menu.set_widget_color(menu_widget_color.NotifySuccess, R, G, B, Alpha);
  40.  
  41. menu.set_alpha( Alpha );
  42. end;
  43.  
  44. -- GetNextColor
  45.  
  46. function Theme:GetNextColor( InitPoint )
  47. local function GetPositiveAngleDiff( a, b )
  48. return a < b and a + 360 - b or a - b;
  49. end;
  50.  
  51. local Angle = InitPoint * 360;
  52. local Color = { };
  53.  
  54. for i = 1, 3 do
  55. local Start = ( ( i + 1 ) * 120 ) % 360;
  56. local DiffFromStart = GetPositiveAngleDiff( Angle, Start );
  57.  
  58. if DiffFromStart < 60 then
  59. Color[i] = DiffFromStart / 60 * 255;
  60. elseif DiffFromStart <= 180 then
  61. Color[i] = 255;
  62. elseif DiffFromStart < 240 then
  63. Color[i] = ( 240 - DiffFromStart ) / 60 * 255;
  64. else
  65. Color[i] = 0;
  66. end;
  67. end;
  68.  
  69. return Color[1], Color[2], Color[3];
  70. end
  71.  
  72. -- OnDone
  73.  
  74. function OnDone( )
  75. menu.restore_styles( );
  76. end;
  77.  
  78. -- OnFrame
  79.  
  80. function OnFrame()
  81. if Theme.Settings.Rainbow and menu.is_menu_opened( ) then
  82. local Hue = ( system.ticks( ) + _G.Seed ) % ( (Theme.Settings.Fps * Theme.Settings.TransitionSpeed) * (Theme.Settings.TransitionSpeed) ) / ( (Theme.Settings.Fps * Theme.Settings.TransitionSpeed) * (Theme.Settings.TransitionSpeed) );
  83. local R, G, B = Theme:GetNextColor( Hue );
  84.  
  85. Theme.Settings.Color.R = R;
  86. Theme.Settings.Color.G = G;
  87. Theme.Settings.Color.B = B;
  88.  
  89. Theme:SetColor( Theme.Settings.Color );
  90. end;
  91. end;
  92.  
  93. -- OnInit
  94.  
  95. function OnInit( )
  96. menu.restore_styles( );
  97.  
  98. _G.Seed = math.random( ) * 10;
  99.  
  100. if not Theme.Settings.Rainbow then
  101. Theme:SetColor( Theme.Settings.Color );
  102. end;
  103. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement