VOID WarpExample(HDC hdc)
{
Graphics graphics(hdc);
// Create a path.
PointF points[] ={
PointF(20.0f, 60.0f),
PointF(30.0f, 90.0f),
PointF(15.0f, 110.0f),
PointF(15.0f, 145.0f),
PointF(55.0f, 145.0f),
PointF(55.0f, 110.0f),
PointF(40.0f, 90.0f),
PointF(50.0f, 60.0f)};
GraphicsPath path;
path.AddLines(points, 8);
path.CloseFigure();
// Draw the path before applying a warp transformation.
Pen bluePen(Color(255, 0, 0, 255));
graphics.DrawPath(&bluePen, &path);
// Define a warp transformation, and warp the path.
RectF srcRect(10.0f, 50.0f, 50.0f, 100.0f);
PointF destPts[] = {
PointF(220.0f, 10.0f),
PointF(280.0f, 10.0f),
PointF(100.0f, 150.0f),
PointF(400.0f, 150.0f)};
path.Warp(destPts, 4, srcRect);
// Draw the warped path.
graphics.DrawPath(&bluePen, &path);
// Draw the source rectangle and the destination polygon.
Pen blackPen(Color(255, 0, 0, 0));
graphics.DrawRectangle(&blackPen, srcRect);
graphics.DrawLine(&blackPen, destPts[0], destPts[1]);
graphics.DrawLine(&blackPen, destPts[0], destPts[2]);
graphics.DrawLine(&blackPen, destPts[1], destPts[3]);
graphics.DrawLine(&blackPen, destPts[2], destPts[3]);
}