## Color
```cpp
struct Color {
float r, g, b, a; // components in [0,1], NOT 0..255
Color(float r=0, float g=0, float b=0, float a=1.0f);
static Color FromArgb(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
D2D1_COLOR_F ToD2D() const;
static Color Lerp(const Color& c1, const Color& c2, float t);
};
```
###block_orange_start
###block_red_start
**Pitfall**
- components are floats in **[0,1]**; `Color(255,0,0)` is wrong (over-bright). For integer input use `Color::FromArgb(255,255,0,0)`.
###block_red_end
## Rect
```cpp
struct Rect {
float x, y, width, height;
Rect(float x=0, float y=0, float w=0, float h=0);
bool Contains(float px, float py) const; // half-open: x<=px<x+w
D2D1_RECT_F ToD2D() const;
};
```
- `Contains` is **half-open [left,right)**; hit-testing relies on it.
## Thickness
```cpp
struct Thickness { float left, top, right, bottom; Thickness(float l=0,float t=0,float r=0,float b=0); };
```
## Size
```cpp
struct Size { float width, height; Size(float w=0, float h=0); };
```Basic types
Color, Rect, Thickness, Size
Color
cpp
struct Color {
float r, g, b, a; // components in [0,1], NOT 0..255
Color(float r=0, float g=0, float b=0, float a=1.0f);
static Color FromArgb(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
D2D1_COLOR_F ToD2D() const;
static Color Lerp(const Color& c1, const Color& c2, float t);
};
block_orange_start
Pitfall
- components are floats in [0,1];
Color(255,0,0)is wrong (over-bright). For integer input useColor::FromArgb(255,255,0,0).
Rect
cpp
struct Rect {
float x, y, width, height;
Rect(float x=0, float y=0, float w=0, float h=0);
bool Contains(float px, float py) const; // half-open: x<=px<x+w
D2D1_RECT_F ToD2D() const;
};
Containsis half-open [left,right); hit-testing relies on it.
Thickness
cpp
struct Thickness { float left, top, right, bottom; Thickness(float l=0,float t=0,float r=0,float b=0); };
Size
cpp
struct Size { float width, height; Size(float w=0, float h=0); };