xtd_c - Reference Guide 0.2.0
xtd_drawing_color Struct Reference

#include <color.h>

Definition

Represents an ARGB (alpha, red, green, blue) color.

Library
xtd_c.drawing
Remarks
Named colors are represented by using the properties of the xtd_drawing_color structure. For more information about these colors, see Colors by Name.
The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. The alpha component specifies the transparency of the color: 0 is fully transparent, and 255 is fully opaque. To determine the alpha, red, green, or blue component of a color, use the xtd_drawing_color::a, xtd_drawing_color::r, xtd_drawing_color::g, or xtd_drawing_color::b property, respectively. You can create a custom color by using one of the xtd_drawing_color::from_argb methods
Examples
The following code example demonstrates the xtd_drawing_color::a, xtd_drawing_color::r, xtd_drawing_color::g, and B properties of a xtd_drawing_color, and the Implicit(size to size_f) member.
This example is designed to be used with a Windows Form (xtd::forms). Paste the code into the form and call the show_properties_of_slate_blue method from the form's xtd::forms::control::paint event-handling method, passing e as xtd::forms::paint_event_args.
void show_properties_of_slate_blue(xtd_forms_paint_event_args e) {
color slate_blue = xtd_drawing_color_from_name("slate blue");
byte_t a = slate_blue.a;
byte_t r = slate_blue.r;
byte_t g = slate_blue.g;
byte_t b = slate_blue.b;
char text[256];
sprintf(text, "Slate blue has these ARGB values: alpha:%d, red:%d, green:%d, blue:%d", a, r, g, b);
e.graphics->draw_string(text, xtd_drawing_font(xtd_forms_control_get_font(main_form), xtd_drawing_font_style_italic), xtd_drawing_solid_brush_create(slate_blue), xtd_drawing_rectangle_f_create_from_point_f_and_size_f(xtd_drawing_point_f(0.0f, 0.0f), (xtd_drawing_size_f){xtd_forms_control_get_size().x, xtd_forms_control_get_size().y});
}

Data Fields

bool __empty__
 Must be set to false. More...
 
intptr_t __handle__
 Must be set to 0. More...
 
xtd_drawing_known_color __known_color__
 Must be set to 0. More...
 
byte_t a
 Gets or sets the alpha component value of this xtd_drawing_color struct. More...
 
byte_t b
 Gets or sets the blue component value of this xtd_drawing_color struct. More...
 
byte_t g
 Gets or sets the green component value of this xtd_drawing_color struct. More...
 
byte_t r
 Gets or sets the red component value of this xtd_drawing_color struct. More...
 

The documentation for this struct was generated from the following file: