vfs: check userland buffers before reading them.
[haiku.git] / docs / develop / servers / app_server / RGBColor.htm
bloba2bc3ef06fc23dce76ba7cb368740a406a029ec7
1 <HTML>
2 <HEAD>
3 <TITLE>RGBColor.htm</TITLE>
4 <style type="text/css">
5 <!--
6 .Default {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 12pt}
7 .OBOS-Function-Def {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 16pt}
8 .OBOS-Title {background-color: rgb(255,255,255); color: rgb(0,128,0); font-family: 'Dutch801 Rm BT'; font-size: 24pt}
9 .Text-Background {background-color: rgb(255,255,255)}
10 .GR-Default {}
11 .Body {margin: 0px}
12 .Footer {margin: 0px}
13 .Header {margin: 0px}
14 .WP-Default {text-align: left; text-indent: 0px; margin-left: 0px; margin-right: 0px}
15 -->
16 </style>
17 </HEAD>
18 <BODY BGCOLOR="#ffffff">
19 <DIV class="sheet" id="Sheet 1">
20 <P class="Body" style="margin: 0px"><span class="OBOS-Title">RGBColor class</span><span style="color: rgb(0,0,0); font-size: 24pt"></span></P>
21 <P class="Body" style="margin: 0px"><BR>
22 </P>
23 <P class="Body" style="margin: 0px">RGBColor objects provide a simplified interface to colors for the app_server, especially the DisplayDriver class</P>
24 <P class="Body" style="margin: 0px"><BR>
25 <BR>
26 <HR>
27 </P>
28 <P class="Body" style="margin: 0px"><BR>
29 Member Functions</P>
30 <P class="Body" style="margin: 0px"><BR>
31 </P>
32 <TABLE WIDTH=617 HEIGHT=264 BORDER=1 CELLPADDING=1 CELLSPACING=2>
33 <TR>
34 <TD WIDTH=203 HEIGHT=32>
35 <P class="Body" style="margin: 0px">RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</P>
36 </TD>
37 <TD WIDTH=260 HEIGHT=32>
38 <P class="Body" style="margin: 0px">RGBColor(rgb_color col)</P>
39 </TD>
40 </TR>
41 <TR>
42 <TD WIDTH=203 HEIGHT=17>
43 <P class="Body" style="margin: 0px">RGBColor(uint16 color16)</P>
44 </TD>
45 <TD WIDTH=260 HEIGHT=17>
46 <P class="Body" style="margin: 0px">RGBColor(uint8 color8)</P>
47 </TD>
48 </TR>
49 <TR>
50 <TD WIDTH=203 HEIGHT=17>
51 <P class="Body" style="margin: 0px">RGBColor(const RGBColor &amp;color)</P>
52 </TD>
53 <TD WIDTH=260 HEIGHT=17>
54 <P class="Body" style="margin: 0px">RGBColor(void)</P>
55 </TD>
56 </TR>
57 <TR>
58 <TD WIDTH=203 HEIGHT=17>
59 <P class="Body" style="margin: 0px">void PrintToStream(void)</P>
60 </TD>
61 <TD WIDTH=260 HEIGHT=17>
62 <P class="Body" style="margin: 0px">uint8 GetColor8(void)</P>
63 </TD>
64 </TR>
65 <TR>
66 <TD WIDTH=203 HEIGHT=17>
67 <P class="Body" style="margin: 0px">uint16 GetColor16(void)</P>
68 </TD>
69 <TD WIDTH=260 HEIGHT=17>
70 <P class="Body" style="margin: 0px">rgb_color GetColor32(void)</P>
71 </TD>
72 </TR>
73 <TR>
74 <TD WIDTH=203 HEIGHT=32>
75 <P class="Body" style="margin: 0px">void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</P>
76 </TD>
77 <TD WIDTH=260 HEIGHT=32>
78 <P class="Body" style="margin: 0px">void SetColor(uint16 color16)</P>
79 </TD>
80 </TR>
81 <TR>
82 <TD WIDTH=203 HEIGHT=17>
83 <P class="Body" style="margin: 0px">void SetColor(uint8 color 8)</P>
84 </TD>
85 <TD WIDTH=260 HEIGHT=17>
86 <P class="Body" style="margin: 0px">void SetColor(rgb_color color)</P>
87 </TD>
88 </TR>
89 <TR>
90 <TD WIDTH=203 HEIGHT=17>
91 <P class="Body" style="margin: 0px">void SetColor(const RGBColor &amp;col)</P>
92 </TD>
93 <TD WIDTH=260 HEIGHT=17>
94 <P class="Body" style="margin: 0px">Operators: =,==,!=</P>
95 </TD>
96 </TR>
97 <TR>
98 <TD WIDTH=203 HEIGHT=32>
99 <P class="Body" style="margin: 0px">RGBColor MakeBlendColor( RGBColor c, float position)</P>
100 </TD>
101 <TD WIDTH=260 HEIGHT=32>
102 &nbsp;
103 </TD>
104 </TR>
105 </TABLE>
106 <P class="Body" style="margin: 0px"><BR>
107 <BR>
108 <HR>
109 </P>
110 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</span><span style="font-size: 16pt"></span></P>
111 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(rgb_color col)</span><span style="font-size: 16pt"></span></P>
112 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(uint16 color16)</span><span style="font-size: 16pt"></span></P>
113 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(uint8 color8)</span><span style="font-size: 16pt"></span></P>
114 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(const RGBColor &amp;color)</span><span style="font-size: 16pt"></span></P>
115 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">RGBColor(void)</span><span style="font-size: 16pt"></span></P>
116 <P class="Body" style="margin: 0px"><BR>
117 1) In all cases, extract the color data by calling SetColor. Void version sets to (0,0,0,0)</P>
118 <P class="Body" style="margin: 0px"><BR>
119 <BR>
120 <span class="OBOS-Function-Def">void PrintToStream(void)</span></P>
121 <P class="Body" style="margin: 0px"><BR>
122 Prints the color values of the color32 member via printf()</P>
123 <P class="Body" style="margin: 0px"><BR>
124 <span class="OBOS-Function-Def">uint8 GetColor8(void)</span><span style="font-size: 16pt"></span></P>
125 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">uint16 GetColor16(void)</span><span style="font-size: 16pt"></span></P>
126 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">rgb_color GetColor32(void)</span><span style="font-size: 16pt"></span></P>
127 <P class="Body" style="margin: 0px"><BR>
128 These are for obtaining space-specific versions of the color assigned to the object.</P>
129 <P class="Body" style="margin: 0px"><BR>
130 1) In all cases, return the internal color storage members </P>
131 <P class="Body" style="margin: 0px"><BR>
132 <BR>
133 <span class="OBOS-Function-Def">void SetColor(const RGBColor &amp;color)</span><span style="font-size: 16pt"></span></P>
134 <P class="Body" style="margin: 0px"><span class="Default"><BR>
135 Copy all internal members to the current object.</span></P>
136 <P class="Body" style="margin: 0px"><span class="Default"><BR>
137 <BR>
138 </span><span class="OBOS-Function-Def">void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)</span><span style="font-size: 16pt"></span></P>
139 <P class="Body" style="margin: 0px"><span class="OBOS-Function-Def">void SetColor(rgb_color col)</span><span style="font-size: 16pt"></span></P>
140 <P class="Body" style="margin: 0px"><span class="Default"><BR>
141 </span><span class="Default">1) Assign parameters to internal rgb_color</span></P>
142 <P class="Body" style="margin: 0px"><span class="Default">2) call SetRGBAColor15()</span></P>
143 <P class="Body" style="margin: 0px"><span class="Default">3) call SystemPalette::FindClosestColor()</span></P>
144 <P class="Body" style="margin: 0px"><span class="Default"><BR>
145 </span><span class="Default"><BR>
146 </span><span class="OBOS-Function-Def">void SetColor(uint16 color16)</span><span style="font-size: 16pt"></span></P>
147 <P class="Body" style="margin: 0px"><span class="Default"><BR>
148 1) Assign parameter to internal uint16</span></P>
149 <P class="Body" style="margin: 0px"><span class="Default">2) call SetRGBAColor32()</span></P>
150 <P class="Body" style="margin: 0px"><span class="Default">3) call SystemPalette::FindClosestColor()</span></P>
151 <P class="Body" style="margin: 0px"><span style="font-size: 16pt"><BR>
152 <BR>
153 </span><span class="OBOS-Function-Def">void SetColor(uint8 color8)</span><span style="font-size: 16pt"></span></P>
154 <P class="Body" style="margin: 0px"><span style="font-size: 16pt"><BR>
155 </span><span class="Default">1) Assign parameter to internal uint8</span></P>
156 <P class="Body" style="margin: 0px"><span class="Default">2) Get the 32-bit value from the palette and assign it to the internal rgb_color</span></P>
157 <P class="Body" style="margin: 0px"><span class="Default">3) call SetRGBAColor16()</span></P>
158 <P class="Body" style="margin: 0px"><span style="font-size: 16pt"><BR>
159 <BR>
160 </span><span class="OBOS-Function-Def">RGBColor &amp; operator=(const RGBColor &amp;from)</span><span style="font-size: 16pt"></span></P>
161 <P class="Body" style="margin: 0px"><span class="Default"><BR>
162 Copy all data members over and return the value of this (return *this;)</span></P>
163 <P class="Body" style="margin: 0px"><span class="Default"><BR>
164 </span><span class="OBOS-Function-Def">bool operator==(const RGBColor &amp;from)</span><span style="font-size: 16pt"></span></P>
165 <P class="Body" style="margin: 0px"><span class="Default"><BR>
166 </span><span class="Default">Compare rgb_colors and if all members are equal, return true. Otherwise, return false.</span></P>
167 <P class="Body" style="margin: 0px"><span class="Default"><BR>
168 </span><span class="OBOS-Function-Def">bool operator!=(const RGBColor &amp;from)</span><span style="font-size: 16pt"></span></P>
169 <P class="Body" style="margin: 0px"><BR>
170 Compare rgb_colors and if all are equal, return false. <span class="Default">Otherwise, return true.</span></P>
171 <P class="Body" style="margin: 0px"><BR>
172 <span class="OBOS-Function-Def">RGBColor MakeBlendColor(RGBColor c, float position)</span></P>
173 <P class="Body" style="margin: 0px"><BR>
174 Returns a color which is (position * 100) of the way from the current color to the one passed to it. This would be an easy way to generate color gradients, for example, but with more control.</P>
175 <P class="Body" style="margin: 0px"><BR>
176 1) Clip position to the range 0&lt;=position&lt;=1</P>
177 <P class="Body" style="margin: 0px">2) For each color component,</P>
178 <P class="Body" style="margin: 0px"> a) calculate the delta (delta=int16(c.component-thiscolor.component))</P>
179 <P class="Body" style="margin: 0px"> b) calculate the modifier (mod=thiscolor.component+(delta * position))</P>
180 <P class="Body" style="margin: 0px"> c) clip modifier to the range 0 &lt;= modifier &lt;= 255</P>
181 <P class="Body" style="margin: 0px"> d) assign modifier to the component (thiscolor.component=int8(mod))</P>
182 <P class="Body" style="margin: 0px">3) return a new RGBColor constructed around the new color</P>
183 <P class="Body" style="margin: 0px"><BR>
184 </P>
185 <DIV class="layer" id="Layer 1">
186 </DIV>
187 </DIV>
188 </BODY>
189 </HTML>