GrapichsByLeo/General/ARGBGenerator.mqh
97 lines
7.7 KiB
MQL5
Nique_372
2025-10-13 07:15:19 -05:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| ARGBGenerator.mqh |
//| Copyright 2025, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372/news |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Niquel Mendoza."
Nique_372
2025-10-13 07:15:19 -05:00
#property link "https://www.mql5.com/es/users/nique_372/news"
Nique_372
2025-10-13 07:15:19 -05:00
#property strict
//+------------------------------------------------------------------+
//| Class CColorGeneratorArgb |
//| Usage: class to generate ARGB colors for charts or objects |
Nique_372
2025-10-13 07:15:19 -05:00
//+------------------------------------------------------------------+
class CColorGeneratorArgb
{
private:
int m_index; // Current index
bool m_generate; // Flag to generate new colors
uint m_current_palette[20]; // Working color palette (ARGB)
Nique_372
2025-10-13 07:15:19 -05:00
static const uint s_default_palette[20]; // Default base palette (ARGB)
uchar m_alpha; // Transparency (0 255)
public:
CColorGeneratorArgb();
Nique_372
2025-10-13 07:15:19 -05:00
//--- Gets the next ARGB color
uint Next(void);
//--- Resets the generator to the original palette
void Reset(void);
//--- Set alpha manually (0 = transparent, 255 = opaque)
Nique_372
2025-10-13 07:15:19 -05:00
void SetAlpha(uchar alpha);
};
//+------------------------------------------------------------------+
//| Default palette (20 harmonious colors, ARGB format) |
//+------------------------------------------------------------------+
const uint CColorGeneratorArgb::s_default_palette[20]=
{
0xFF3366CC,0xFFDC3912,0xFFFF9900,0xFF109618,0xFF990099,
0xFF3B3EAC,0xFF0099C6,0xFFDD4477,0xFF66AA00,0xFFB82E2E,
0xFF316395,0xFF994499,0xFF22AA99,0xFFAAAA11,0xFF6633CC,
0xFFE67300,0xFF8B0707,0xFF329262,0xFF5574A6,0xFF3B3EAC
Nique_372
2025-10-13 07:15:19 -05:00
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
Nique_372
2025-10-13 07:15:19 -05:00
CColorGeneratorArgb::CColorGeneratorArgb():
m_index(0),