File: Color.custom

package info (click to toggle)
clutter-sharp 1.0.0~alpha3~git20090817.r1.349dba6-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 4,104 kB
  • ctags: 2,193
  • sloc: xml: 23,456; cs: 9,946; sh: 3,393; perl: 1,213; makefile: 270; awk: 50; sed: 13
file content (199 lines) | stat: -rw-r--r-- 5,817 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// 
// Color.custom
//  
// Author:
//   Aaron Bockover <abockover@novell.com>
// 
// Copyright 2009 Novell, Inc.
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

private byte _r;
private byte _g;
private byte _b;
private byte _a;

public byte R { get { return _r; } set { _r = value; } }
public byte G { get { return _g; } set { _g = value; } }
public byte B { get { return _b; } set { _b = value; } }
public byte A { get { return _a; } set { _a = value; } }

public Color (byte r, byte g, byte b, byte a)
{
    _r = r;
    _g = g;
    _b = b;
    _a = a;
}

public Color (byte r, byte g, byte b) : this (r, g, b, 0xff)
{
}

public Color (float r, float g, float b, float a)
    : this ((byte)(r * 0xff), (byte)(g * 0xff), (byte)(b * 0xff), (byte)(a * 0xff))
{
}

public Color (float r, float g, float b) : this (r, g, b, 1.0f)
{
}

public Color (double r, double g, double b, double a)
    : this ((byte)(r * 0xff), (byte)(g * 0xff), (byte)(b * 0xff), (byte)(a * 0xff))
{

}

public Color (double r, double g, double b) : this (r, g, b, 1.0)
{
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_lighten (ref Color color, ref Color result);

public Color Lighten ()
{
    Color result = new Color ();
    clutter_color_lighten (ref this, ref result);
    return result;
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_darken (ref Color color, ref Color result);

public Color Darken ()
{
    Color result = new Color ();
    clutter_color_darken (ref this, ref result);
    return result;
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_shade (ref Color color, double factor, ref Color result);

public Color Shade (double factor)
{
    Color result = new Color ();
    clutter_color_shade (ref this, factor, ref result);
    return result;
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_add (ref Color color, ref Color b, ref Color result);

public Color Add (Color b)
{
    Color result = new Color ();
    clutter_color_add (ref this, ref b, ref result);
    return result;
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_subtract (ref Color color, ref Color b, ref Color result);

public Color Subtract (Color b)
{
    Color result = new Color ();
    clutter_color_subtract (ref this, ref b, ref result);
    return result;
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_from_hls (ref Color color, float hue, float luminance, float saturation);

public void FromHls (float hue, float luminance, float saturation)
{
    clutter_color_from_hls (ref this, hue, luminance, saturation);
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_to_hls (ref Color color, out float hue, out float luminance, out float saturation);

public void ToHls (out float hue, out float luminance, out float saturation)
{
    clutter_color_to_hls (ref this, out hue, out luminance, out saturation);
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern uint clutter_color_to_pixel (ref Color color);

public uint ToPixel ()
{
    return clutter_color_to_pixel (ref this);
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern void clutter_color_from_pixel (ref Color color, uint pixel);

public void FromPixel (uint pixel)
{
    clutter_color_from_pixel (ref this, pixel);
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern bool clutter_color_from_string (ref Color color, IntPtr str);

public bool FromString (string str)
{
    IntPtr str_ptr = IntPtr.Zero;
    try {
        str_ptr = GLib.Marshaller.StringToPtrGStrdup (str);
        return clutter_color_from_string (ref this, str_ptr);
    } finally {
        GLib.Marshaller.Free (str_ptr);
    }
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern IntPtr clutter_color_to_string (ref Color color);

public override string ToString ()
{
    return GLib.Marshaller.PtrToStringGFree (clutter_color_to_string (ref this));
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern bool clutter_color_equal (ref Color a, ref Color b);

public override bool Equals (object obj)
{
    if (obj is Color) {
        Color c = (Color)obj;
        return clutter_color_equal (ref this, ref c);
    }
    
    return false;
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern uint clutter_color_hash (ref Color color);

public override int GetHashCode ()
{
    return (int)clutter_color_hash (ref this);
}

[DllImport ("libclutter-win32-1.0-0.dll")]
private static extern IntPtr clutter_color_get_type ();

public static GLib.GType GType { 
    get { return new GLib.GType (clutter_color_get_type ()); }
}