SDXFrameWork  0.04
SDXFrameWork
 全て クラス ネームスペース 関数 変数 ページ
Color.h
1 #pragma once
2 
3 namespace SDX
4 {
6 class Color
8 {
9 private:
10  ColorData data;
11 #ifdef DXLIB
12  int alpha;
13 #endif
14 public :
16  Color(int 赤,int 緑,int 青 , int 透過率 = 255)
18  {
19  SetColor(赤,緑,青,透過率);
20  }
21 
22  void SetColor(int 赤, int 緑, int 青, int 透過率 = 255)
23  {
24  #ifdef DXLIB
25  data = (赤 << 16) + (緑 << 8) + 青;
26  alpha = 透過率;
27  #elif defined(SDL)
28  data = { 赤, 緑, 青, 透過率 };
29  #endif
30  }
31 
33  int GetRed() const
34  {
35  #ifdef DXLIB
36  return (data >> 16) % 256;
37  #elif defined(SDL)
38  return data.r;
39  #endif
40  }
41 
43  int GetGreen() const
44  {
45  #ifdef DXLIB
46  return (data >> 8) % 256;
47  #elif defined(SDL)
48  return data.g;
49  #endif
50  }
51 
53  int GetBlue() const
54  {
55  #ifdef DXLIB
56  return data % 256;
57  #elif defined(SDL)
58  return data.b;
59  #endif
60  }
61 
62  int GetAlpha() const
63  {
64  #ifdef DXLIB
65  return alpha;
66  #elif defined(SDL)
67  return data.a;
68  #endif
69  }
70 
71  operator ColorData()
72  {
73  return data;
74  }
75 
76  bool operator==(Color 比較色) {
77  return (
78  GetRed() == 比較色.GetRed() &&
79  GetBlue() == 比較色.GetBlue() &&
80  GetGreen() == 比較色.GetGreen() &&
81  GetAlpha() == 比較色.GetAlpha()
82  );
83  }
84 
85  static const Color Black;
86  static const Color Dilver;
87  static const Color Gray;
88  static const Color White;
89  static const Color Maroon;
90  static const Color Red;
91  static const Color Purple;
92  static const Color Fuchsia;
93  static const Color Green;
94  static const Color Lime;
95  static const Color Olive;
96  static const Color Yellow;
97  static const Color Navy;
98  static const Color Blue;
99  static const Color Teal;
100  static const Color Aqua;
101 };
102 
103 }
int GetGreen() const
緑の要素を取得.
Definition: Color.h:43
int GetBlue() const
青の要素を取得.
Definition: Color.h:53
Color(int 赤, int 緑, int 青, int 透過率=255)
RGB値から色に変換.
Definition: Color.h:17
int GetRed() const
赤の要素を取得.
Definition: Color.h:33