2

Direct2D 有 D2D1_RECT_F

{
    FLOAT left;
    FLOAT top;
    FLOAT right;
    FLOAT bottom;
}

它类似于 GDI RECT 结构,只是它使用浮点值。

typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT;

GDI 提供所有这些 RECT 操作功能,例如

BOOL IntersectRect(
   _Out_  LPRECT lprcDst,
   _In_   const RECT *lprcSrc1,
   _In_   const RECT *lprcSrc2
);

BOOL SubtractRect(
   _Out_  LPRECT lprcDst,
   _In_   const RECT *lprcSrc1,
   _In_   const RECT *lprcSrc2
);

我不敢相信 Direct2D 没有为 D2D1_RECT_F 提供类似的功能。

我想我可以创建矩形几何图形并以任何我想要的方式组合它们,但这是创建和分配对象而不是进行简单的数学运算。或者我想我可能只是创建我自己的版本。

我错过了什么吗?谢谢。

4

1 回答 1

0

For IntersectRect, Direct2D has ID2D1Geometry::CompareWithGeometry which will determine the relationship between two geometries, that's will work for you. note, this function only return the relationship of the two geometries, such as overlap, contains, it will not return the intersection rectangle as what IntersectRect did.

For SubtractRect, Direct2D has no such function, you need to write it yourself.

于 2012-11-30T01:27:38.373 回答