xref: /haiku/docs/user/interface/GraphicsDefs.dox (revision dd2a1e350b303b855a50fd64e6cb55618be1ae6a)
1/*
2 * Copyright 2013, 2020 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		John Scipione, jscipione@gmail.com
7 *		Niels Sascha Reedijk, niels.reedijk@gmail.com
8 *
9 * Corresponds to:
10 *		headers/os/interface/GraphicsDefs.h	hrev57597
11 *		src/kits/interface/GraphicsDefs.cpp	hrev49977
12 */
13
14
15/*!
16	\file GraphicsDefs.h
17	\ingroup interface
18	\ingroup libbe
19	\brief Graphics-related functions and variables used by the Interface Kit.
20*/
21
22
23///// Pattern /////
24
25
26/*!
27	\name Patterns
28*/
29
30
31//! @{
32
33
34/*!
35	\struct pattern
36	\ingroup interface
37	\ingroup libbe
38	\brief A pattern to use when drawing.
39
40	\since BeOS R3
41*/
42
43
44/*!
45	\fn bool operator==(const pattern &a, const pattern &b)
46	\brief Comparison operator for two patterns
47
48	\retval true The patterns match
49	\retval false The patterns do not match
50
51	\since Haiku R1
52*/
53
54
55/*!
56	\fn bool operator!=(const pattern &a, const pattern &b)
57	\brief Comparison operator for two patterns
58
59	\retval true The patterns do not match
60	\retval false The patterns match
61
62	\since Haiku R1
63*/
64
65
66/*!
67	\var B_SOLID_HIGH
68
69	Draw using the view's high color.
70
71	\since BeOS R3
72*/
73
74
75/*!
76	\var B_MIXED_COLORS
77
78	Draw a pattern of the view's high and low colors.
79
80	\since BeOS R3
81*/
82
83
84/*!
85	\var B_SOLID_LOW
86
87	Draw using the view's low color.
88
89	\since BeOS R3
90*/
91
92//! @}
93
94
95///// struct rgb_color /////
96
97
98/*!
99	\name RGB Colors
100*/
101
102
103//! @{
104
105
106/*!
107	\struct rgb_color
108	\ingroup interface
109	\ingroup libbe
110	\brief Structure representing a 32 bit RGBA color.
111
112	\since BeOS R3
113*/
114
115
116/*!
117	\var uint8 rgb_color::red
118	\brief Red value for the color.
119
120	\since BeOS R3
121*/
122
123
124/*!
125	\var uint8 rgb_color::green
126	\brief Green value for the color.
127
128	\since BeOS R3
129*/
130
131
132/*!
133	\var uint8 rgb_color::blue
134	\brief Blue value for the color.
135
136	\since BeOS R3
137*/
138
139
140/*!
141	\var uint8 rgb_color::alpha
142	\brief Alpha value for the color.
143
144	\since BeOS R3
145*/
146
147
148/*!
149	\fn rgb_color& rgb_color::set_to(uint8 r, uint8 g, uint8 b, uint8 a=255)
150	\brief Helper method to set all values of the color.
151
152	\param r Red value.
153	\param g Green value.
154	\param b Blue value.
155	\param a Alpha value.
156
157	\return A reference to this object.
158
159	\since Haiku R1
160*/
161
162
163/*!
164	\fn bool rgb_color::operator==(const rgb_color &other) const
165	\brief Comparison operator.
166
167	\param other The other color to compare to.
168
169	\retval true The colors match.
170	\retval false The colors are different.
171
172	\since Haiku R1
173*/
174
175
176/*!
177	\fn bool rgb_color::operator!=(const rgb_color &other) const
178	\brief Comparison operator.
179
180	\param other The other color to compare to.
181
182	\retval true The colors are different.
183	\retval false The colors match.
184
185	\since Haiku R1
186*/
187
188
189/*!
190	\fn rgb_color& rgb_color::operator=(const rgb_color &other)
191	\brief Assign values from another color object.
192
193	\param other The other color to copy.
194
195	\return A reference to this object.
196
197	\since Haiku R1
198*/
199
200
201/*!
202	\fn int32 rgb_color::Brightness() const
203	\brief Calculates a value representing the brightness of this color.
204
205	This method calculates the perceptual brightness of a color.
206
207	\return A value representing the brightness. (0-255)
208
209	\since Haiku R1
210*/
211
212/*!
213	\fn bool rgb_color::IsLight() const
214	\brief Determines if the color is light.
215
216	A color is considered 'light' if its Brightness() is > 127.
217
218	\since Haiku R1
219*/
220
221/*!
222	\fn bool rgb_color::IsDark() const
223	\brief Determines if the color is dark.
224
225	A color is considered 'dark' if its Brightness() is <= 127.
226
227	\since Haiku R1
228*/
229
230/*!
231	\fn static int32 rgb_color::Contrast(rgb_color colorA, rgb_color colorB)
232	\brief Calculates the contrast between two colors.
233
234	This method compares the Brightness of colorA and colorB and returns
235	the Contrast that is between them.
236
237	For example this can used to make sure a color combination is legible
238	on a specifc background.
239
240	\return A value representing the Contrast. (0-255)
241
242	\since Haiku R1
243*/
244
245/*!
246	\fn rgb_color make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha=255)
247	\brief Create a \a rgb_color from RGBA values.
248
249	\param red The value for red.
250	\param green The value for green.
251	\param blue The value for blue.
252	\param alpha The alpha value. Set to opaque by default.
253
254	\return A new rgb_color set to the selected colors.
255
256	\since Haiku R1
257*/
258
259
260/*!
261	\fn rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount)
262	\brief Mix two colors without respect for their alpha values.
263
264	\param color1 First color.
265	\param color2 Second color.
266	\param amount The relative weight of \a color1 to mix in.
267
268	\return The newly-mixed \ref rgb_color.
269
270	\since Haiku R1
271*/
272
273
274/*!
275	\fn rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount)
276	\brief Mix two colors, respecting their alpha values.
277
278	\param color1 First color.
279	\param color2 Second color.
280	\param amount The relative weight of \a color1 to mix in.
281
282	\return The newly-mixed \ref rgb_color.
283
284	\since Haiku R1
285*/
286
287
288/*!
289	\fn rgb_color disable_color(rgb_color color, rgb_color background)
290	\brief Calculate a color for a disabled look.
291
292	\param color The color that it would be if the use of your color is \em not
293		disabled.
294	\param background The background on which will be drawn.
295
296	\return A newly-mixed \ref rgb_color.
297
298	\since Haiku R1
299*/
300
301
302/*!
303	\var const rgb_color B_TRANSPARENT_COLOR
304	\brief A transparent color.
305
306	\since Haiku R1
307*/
308
309
310/*!
311	\var const uint8 B_TRANSPARENT_MAGIC_CMAP8
312	\brief Transparent color.
313
314	\since Haiku R1
315*/
316
317
318/*!
319	\var const uint16 B_TRANSPARENT_MAGIC_RGBA15
320	\brief Transparent color.
321
322	\since Haiku R1
323*/
324
325
326/*!
327	\var const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG
328	\brief Transparent color.
329
330	\since Haiku R1
331*/
332
333
334/*!
335	\var const uint32 B_TRANSPARENT_MAGIC_RGBA32
336	\brief Transparent color.
337
338	\since Haiku R1
339*/
340
341
342/*!
343	\var const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG
344	\brief Transparent color.
345
346	\since Haiku R1
347*/
348
349
350/*!
351	\var const uint8 B_TRANSPARENT_8_BIT
352	\brief Transparent color.
353
354	\since BeOS R3
355*/
356
357
358/*!
359	\var const rgb_color B_TRANSPARENT_32_BIT
360	\brief Transparent color.
361
362	\since BeOS R3
363*/
364
365
366//! @}
367
368
369///// Drawing modes /////
370
371
372/*!
373	\name Drawing Modes
374*/
375
376
377//! @{
378
379
380/*!
381	\enum source_alpha
382	\ingroup interface
383
384	Blending alpha mode constants.
385
386	\since BeOS R3
387*/
388
389
390/*!
391	\var source_alpha B_PIXEL_ALPHA
392
393	Use the alpha value of each pixel when drawing a bitmap.
394
395	\since BeOS R3
396*/
397
398
399/*!
400	\var source_alpha B_CONSTANT_ALPHA
401
402	Use the alpha channel of the view's high color.
403
404	\since BeOS R3
405*/
406
407
408/*!
409	\enum alpha_function
410	\ingroup interface
411
412	Blending alpha function constants.
413
414	\since BeOS R3
415*/
416
417
418/*!
419	\var alpha_function B_ALPHA_OVERLAY
420
421	Used for drawing a image with transparency over an opaque background.
422
423	\since BeOS R3
424*/
425
426
427/*!
428	\var alpha_function B_ALPHA_COMPOSITE
429
430	Used to composite two or more transparent images together offscreen to
431	produce a new image drawn using \c B_ALPHA_OVERLAY mode.
432
433	\since BeOS R3
434*/
435
436
437/*!
438	\var alpha_function B_ALPHA_COMPOSITE_SOURCE_OVER
439
440	Draws source over destination preserving transparency. Same as
441	\c B_ALPHA_COMPOSITE.
442
443	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
444	->
445	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
446	=
447	\image{inline} html B_ALPHA_COMPOSITE_SOURCE_OVER.png "Result"
448
449	\since Haiku R1
450*/
451
452
453/*!
454	\var alpha_function B_ALPHA_COMPOSITE_SOURCE_IN
455
456	Draws source only where destination is not transparent.
457
458	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
459	->
460	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
461	=
462	\image{inline} html B_ALPHA_COMPOSITE_SOURCE_IN.png "Result"
463
464	\since Haiku R1
465*/
466
467
468/*!
469	\var alpha_function B_ALPHA_COMPOSITE_SOURCE_OUT
470
471	Draws source only where destination is transparent.
472
473	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
474	->
475	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
476	=
477	\image{inline} html B_ALPHA_COMPOSITE_SOURCE_OUT.png "Result"
478
479	\since Haiku R1
480*/
481
482
483/*!
484	\var alpha_function B_ALPHA_COMPOSITE_SOURCE_ATOP
485
486	Draws source only where destination is not transparent. Colors from both
487	are used in the result.
488
489	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
490	->
491	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
492	=
493	\image{inline} html B_ALPHA_COMPOSITE_SOURCE_ATOP.png "Result"
494
495	\since Haiku R1
496*/
497
498
499/*!
500	\var alpha_function B_ALPHA_COMPOSITE_DESTINATION_OVER
501
502	Draws source where destination is transparent, making it appear as if it
503	is drawn behind.
504
505	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
506	->
507	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
508	=
509	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION_OVER.png "Result"
510
511	\since Haiku R1
512*/
513
514
515/*!
516	\var alpha_function B_ALPHA_COMPOSITE_DESTINATION_IN
517
518	Blends source alpha channel with destination.
519
520	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
521	->
522	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
523	=
524	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION_IN.png "Result"
525
526	\since Haiku R1
527*/
528
529
530/*!
531	\var alpha_function B_ALPHA_COMPOSITE_DESTINATION_OUT
532
533	Blends inverse of source alpha channel with destination. Result appears as
534	if source was cut out of destination.
535
536	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
537	->
538	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
539	=
540	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION_OUT.png "Result"
541
542	\since Haiku R1
543*/
544
545
546/*!
547	\var alpha_function B_ALPHA_COMPOSITE_DESTINATION_ATOP
548
549	Draws source only where it is not transparent. Destination is blended on
550	top of it. Colors from both are used in the result.
551
552	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
553	->
554	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
555	=
556	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION_ATOP.png "Result"
557
558	\since Haiku R1
559*/
560
561
562/*!
563	\var alpha_function B_ALPHA_COMPOSITE_XOR
564
565	Result is transparent only where both source and destination are transparent
566	or opaque.
567
568	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
569	->
570	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
571	=
572	\image{inline} html B_ALPHA_COMPOSITE_XOR.png "Result"
573
574	\since Haiku R1
575*/
576
577
578/*!
579	\var alpha_function B_ALPHA_COMPOSITE_CLEAR
580
581	Erases destination to full transparency, regardless of source alpha value.
582
583	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
584	->
585	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
586	=
587	\image{inline} html B_ALPHA_COMPOSITE_CLEAR.png "Result"
588
589	\since Haiku R1
590*/
591
592
593/*!
594	\var alpha_function B_ALPHA_COMPOSITE_DIFFERENCE
595
596	Subtracts both inputs in a way that always yields positive result.
597
598	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
599	->
600	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
601	=
602	\image{inline} html B_ALPHA_COMPOSITE_DIFFERENCE.png "Result"
603
604	\since Haiku R1
605*/
606
607
608/*!
609	\var alpha_function B_ALPHA_COMPOSITE_LIGHTEN
610
611	Retains lighter pixels of both inputs.
612
613	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
614	->
615	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
616	=
617	\image{inline} html B_ALPHA_COMPOSITE_LIGHTEN.png "Result"
618
619	\since Haiku R1
620*/
621
622
623/*!
624	\var alpha_function B_ALPHA_COMPOSITE_DARKEN
625
626	Retains darker pixels of both inputs.
627
628	\image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source"
629	->
630	\image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination"
631	=
632	\image{inline} html B_ALPHA_COMPOSITE_DARKEN.png "Result"
633
634	\since Haiku R1
635*/
636
637
638//! @}
639