How to draw transparent graphics using Direct2D

81 Views Asked by At
//ID2D1DCRenderTarget* pDCRT;
//ID2D1SolidColorBrush* pBrush;
 
pDCRT->Clear(D2D1::ColorF(D2D1::ColorF(0, 0, 1, 0.5f)));
 
D2D1_ELLIPSE pe1 = D2D1::Ellipse(D2D1::Point2F(200, 200), 150, 150); 
D2D1_ELLIPSE pe2 = D2D1::Ellipse(D2D1::Point2F(350, 200), 150, 150);
 
pDCRT->CreateSolidColorBrush(D2D1::ColorF(1, 0, 0, 1), &pBrush);    
pDCRT->FillEllipse(pe1, pBrush); 
     
pDCRT->CreateSolidColorBrush(D2D1::ColorF(0, 1, 0, 0.5f), &pBrush);       
pDCRT->FillEllipse(pe2, pBrush);

image description

This is a window that supports transparency. The left circle is opaque and the right circle is translucent. The left circle and the window background color can be seen through the right circle (which is translucent).

Now, when I draw the right circle, I want to clear this position first and then draw it, so that the desktop can be seen through the right circle. How should I achieve this?

0

There are 0 best solutions below