Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Specifies the different methods by which two geometries can be combined.
Syntax
typedef enum D2D1_COMBINE_MODE {
D2D1_COMBINE_MODE_UNION = 0,
D2D1_COMBINE_MODE_INTERSECT = 1,
D2D1_COMBINE_MODE_XOR = 2,
D2D1_COMBINE_MODE_EXCLUDE = 3,
D2D1_COMBINE_MODE_FORCE_DWORD = 0xffffffff
} ;
Constants
D2D1_COMBINE_MODE_UNIONValue: 0 The two regions are combined by taking the union of both. Given two geometries, A and B, the resulting geometry is geometry A + geometry B. |
D2D1_COMBINE_MODE_INTERSECTValue: 1 The two regions are combined by taking their intersection. The new area consists of the overlapping region between the two geometries. |
D2D1_COMBINE_MODE_XORValue: 2 The two regions are combined by taking the area that exists in the first region but not the second and the area that exists in the second region but not the first. Given two geometries, A and B, the new region consists of (A-B) + (B-A). |
D2D1_COMBINE_MODE_EXCLUDEValue: 3 The second region is excluded from the first. Given two geometries, A and B, the area of geometry B is removed from the area of geometry A, producing a region that is A-B. |
D2D1_COMBINE_MODE_FORCE_DWORDValue: 0xffffffff |
Remarks
The following illustration shows the different geometry combine modes.
Examples
The following code uses each of the different combine modes to combine two ID2D1EllipseGeometry objects.
HRESULT DemoApp::CreateGeometryResources()
{
HRESULT hr = S_OK;
ID2D1GeometrySink *pGeometrySink = NULL;
// Create the first ellipse geometry to merge.
const D2D1_ELLIPSE circle1 = D2D1::Ellipse(
D2D1::Point2F(75.0f, 75.0f),
50.0f,
50.0f
);
hr = m_pD2DFactory->CreateEllipseGeometry(
circle1,
&m_pCircleGeometry1
);
if (SUCCEEDED(hr))
{
// Create the second ellipse geometry to merge.
const D2D1_ELLIPSE circle2 = D2D1::Ellipse(
D2D1::Point2F(125.0f, 75.0f),
50.0f,
50.0f
);
hr = m_pD2DFactory->CreateEllipseGeometry(circle2, &m_pCircleGeometry2);
}
if (SUCCEEDED(hr))
{
//
// Use D2D1_COMBINE_MODE_UNION to combine the geometries.
//
hr = m_pD2DFactory->CreatePathGeometry(&m_pPathGeometryUnion);
if (SUCCEEDED(hr))
{
hr = m_pPathGeometryUnion->Open(&pGeometrySink);
if (SUCCEEDED(hr))
{
hr = m_pCircleGeometry1->CombineWithGeometry(
m_pCircleGeometry2,
D2D1_COMBINE_MODE_UNION,
NULL,
NULL,
pGeometrySink
);
}
if (SUCCEEDED(hr))
{
hr = pGeometrySink->Close();
}
SafeRelease(&pGeometrySink);
}
}
if (SUCCEEDED(hr))
{
//
// Use D2D1_COMBINE_MODE_INTERSECT to combine the geometries.
//
hr = m_pD2DFactory->CreatePathGeometry(&m_pPathGeometryIntersect);
if (SUCCEEDED(hr))
{
hr = m_pPathGeometryIntersect->Open(&pGeometrySink);
if (SUCCEEDED(hr))
{
hr = m_pCircleGeometry1->CombineWithGeometry(
m_pCircleGeometry2,
D2D1_COMBINE_MODE_INTERSECT,
NULL,
NULL,
pGeometrySink
);
}
if (SUCCEEDED(hr))
{
hr = pGeometrySink->Close();
}
SafeRelease(&pGeometrySink);
}
}
if (SUCCEEDED(hr))
{
//
// Use D2D1_COMBINE_MODE_XOR to combine the geometries.
//
hr = m_pD2DFactory->CreatePathGeometry(&m_pPathGeometryXOR);
if (SUCCEEDED(hr))
{
hr = m_pPathGeometryXOR->Open(&pGeometrySink);
if (SUCCEEDED(hr))
{
hr = m_pCircleGeometry1->CombineWithGeometry(
m_pCircleGeometry2,
D2D1_COMBINE_MODE_XOR,
NULL,
NULL,
pGeometrySink
);
}
if (SUCCEEDED(hr))
{
hr = pGeometrySink->Close();
}
SafeRelease(&pGeometrySink);
}
}
if (SUCCEEDED(hr))
{
//
// Use D2D1_COMBINE_MODE_EXCLUDE to combine the geometries.
//
hr = m_pD2DFactory->CreatePathGeometry(&m_pPathGeometryExclude);
if (SUCCEEDED(hr))
{
hr = m_pPathGeometryExclude->Open(&pGeometrySink);
if (SUCCEEDED(hr))
{
hr = m_pCircleGeometry1->CombineWithGeometry(
m_pCircleGeometry2,
D2D1_COMBINE_MODE_EXCLUDE,
NULL,
NULL,
pGeometrySink
);
}
if (SUCCEEDED(hr))
{
hr = pGeometrySink->Close();
}
SafeRelease(&pGeometrySink);
}
}
return hr;
}
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] |
| Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] |
| Header | d2d1.h |