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
 
41
        TColor() {};
42
 
43
        static COLOR_T getAMXColor(const std::string& color);
44
        static void setPalette(TPalette *pal) { mPalette = pal; }
45
        static COLOR_T splitColors(PDATA_T& pd);
46
        static SkColor getSkiaColor(const std::string& color);
5 andreas 47
        static ulong getColor(const std::string& color);
7 andreas 48
        static std::string colorToString(ulong color);
49
        static std::string colorToString(SkColor color);
4 andreas 50
 
5 andreas 51
        static int getRed(ulong color) { return ((color >> 24) & 0x000000ff); }
8 andreas 52
        static SkColor getRed(SkColor color) { return SkColorGetR(color); }
5 andreas 53
        static int getGreen(ulong color) { return ((color >> 16) & 0x000000ff); }
8 andreas 54
        static SkColor getGreen(SkColor color) { return SkColorGetG(color); }
5 andreas 55
        static int getBlue(ulong color) { return ((color >> 8) & 0x000000ff); }
8 andreas 56
        static SkColor getBlue(SkColor color) { return SkColorGetB(color); }
5 andreas 57
        static int getAlpha(ulong color) { return (color & 0x000000ff); }
8 andreas 58
        static SkColor getAlpha(SkColor color) { return SkColorGetA(color); }
5 andreas 59
 
8 andreas 60
        static int setAlpha(ulong color, int alpha);
61
        static SkColor setAlpha(SkColor color, int alpha);
62
        static int calcAlpha(int alpha1, int alpha2);
63
        static ulong setAlphaTreshold(ulong color, int alpha);
64
        static SkColor setAlphaTreshold(SkColor color, int alpha);
65
 
4 andreas 66
    private:
67
        static TPalette *mPalette;
68
};
69
 
70
#endif