Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
/*
21 andreas 2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
4 andreas 3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TCOLOR_H__
20
#define __TCOLOR_H__
21
 
22
#include <string>
23
#include <include/core/SkColor.h>
24
#include "tpalette.h"
25
 
21 andreas 26
#ifdef __ANDROID__
27
typedef unsigned long int ulong;
28
#endif
29
 
4 andreas 30
class TColor
31
{
32
    public:
33
        typedef struct COLOR_T
34
        {
35
            int red{0};
36
            int green{0};
37
            int blue{0};
38
            int alpha{0};
39
        }COLOR_T;
40
 
40 andreas 41
        typedef enum DIRECTION_t
42
        {
43
            DIR_LIGHT_DARK = 1,
44
            DIR_DARK_LIGHT,
45
            DIR_LIGHT_DARK_LIGHT,
46
            DIR_DARK_LIGHT_DARK
47
        }DIRECTION_t;
48
 
4 andreas 49
        TColor() {};
50
 
51
        static COLOR_T getAMXColor(const std::string& color);
52
        static void setPalette(TPalette *pal) { mPalette = pal; }
53
        static COLOR_T splitColors(PDATA_T& pd);
54
        static SkColor getSkiaColor(const std::string& color);
5 andreas 55
        static ulong getColor(const std::string& color);
7 andreas 56
        static std::string colorToString(ulong color);
57
        static std::string colorToString(SkColor color);
40 andreas 58
        static std::vector<SkColor> colorRange(SkColor col, int width, int bandwidth, DIRECTION_t dir);
108 andreas 59
        static bool isValidAMXcolor(const std::string& color);
4 andreas 60
 
5 andreas 61
        static int getRed(ulong color) { return ((color >> 24) & 0x000000ff); }
8 andreas 62
        static SkColor getRed(SkColor color) { return SkColorGetR(color); }
5 andreas 63
        static int getGreen(ulong color) { return ((color >> 16) & 0x000000ff); }
8 andreas 64
        static SkColor getGreen(SkColor color) { return SkColorGetG(color); }
5 andreas 65
        static int getBlue(ulong color) { return ((color >> 8) & 0x000000ff); }
8 andreas 66
        static SkColor getBlue(SkColor color) { return SkColorGetB(color); }
5 andreas 67
        static int getAlpha(ulong color) { return (color & 0x000000ff); }
8 andreas 68
        static SkColor getAlpha(SkColor color) { return SkColorGetA(color); }
5 andreas 69
 
8 andreas 70
        static int setAlpha(ulong color, int alpha);
71
        static SkColor setAlpha(SkColor color, int alpha);
72
        static int calcAlpha(int alpha1, int alpha2);
73
        static ulong setAlphaTreshold(ulong color, int alpha);
74
        static SkColor setAlphaTreshold(SkColor color, int alpha);
75
 
4 andreas 76
    private:
77
        static TPalette *mPalette;
78
};
79
 
80
#endif