The following is a test of drawing a diamond using a custom function. Code .
Uses direct2d, d2d1; {custom function for drawing diamond} function getdiamondpath (ptleft, pttop: td2dpoint2f): id2d1pathgeometry; // return path interface var sink: id2d1geometrysink; // The ptright, ptbottom: td2dpoint2f, and begin {calculate the other two points} ptright: = d2d1pointf (pttop. x-ptLeft.x) * 2 + ptleft. x, ptleft. y); ptbottom: = d2d1pointf (pttop. x, (ptleft. y-ptTop.y) * 2 + pttop. y); {build id2d1pathgeometry} d2dfactory. createpathgeometry (result); {create and enable id2d1geometrysink} result. open (sink); {Add graph,} sink. beginfigure (ptleft, d2d1_figure_begin_filled); // option d2d1_figure_begin_filled the logo image can be filled with sink. addline (pttop); sink. addline (ptright); sink. addline (ptbottom); {end the image and close id2d1geometrysink} sink. endfigure (d2d1_figure_end_closed); // option d2d1_figure_end_closed ID image automatically closes the sink. close; end; {draw} procedure tform1.formpaint (Sender: tobject); var path: id2d1pathgeometry; begin path: = getdiamondpath (d2d1pointf (clientwidth/5, clientheight/2 ), d2d1pointf (clientwidth/2, clientheight/5); with tdirect2dcanvas. create (canvas, clientrect) Do begin pen. color: = clred; brush. color: = clyellow; begindraw; fillgeometry (PATH); drawgeometry (PATH); enddraw; free; end; Procedure tform1.formresize (Sender: tobject); begin repaint; end;
: