Drawing custom shape using lines in Direct2D

thebluetropics 1,046 Reputation points
2022-10-06T01:18:48.567+00:00

In Direct2D, is it possible to create a custom shape using lines? Here is the pseudo code:

   d2dDeviceContext->BeginShape(10, 10);  
   d2dDeviceContext->LineTo(32, 42);  
   d2dDeviceContext->LineTo(10, 74);  
   d2dDeviceContext->LineTo(10, 10);  
   d2dDeviceContext->FillShape(blackBrush);  

Note that I don't want to draw the lines, just filling the shape with a color.

Also, is it possible to make it hit-detectable by using ID2D1Geometry::FillContainsPoint()?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,523 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,637 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 12,231 Reputation points Microsoft Vendor
    2022-10-06T03:05:33.673+00:00

    Yes and Use ID2D1PathGeometry to build a shape and test hit. see GitHub TouchHitTesting sample.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful