The program of this section demonstrates the drawing of curvilinear figures. The output of the program is shown below.

Theoretically, all drawing to a device context may be achieved through use of the functions:

However, the overhead of making a function call for each pixel is prohibitive. A device context has capabilities of drawing figures for this reason. This example makes use of the function DrawLines to draw a sine curve by estimating it with 1000 points. Many curves can be drawn by approximating with a series of points. This method hints of calculus.

void OnPaint(object source, PaintEventArgs e) { DeviceContext deviceContext = new DeviceContext(this); System.Drawing.Size sizeClient = ClientSize; deviceContext.CurrentPosition = new Point(0,sizeClient.Height/2); deviceContext.DrawLineTo(sizeClient.Width,sizeClient.Height/2); Array<Point> SineLines = new Array<Point>(); int NumberOfPoints = 1000; for (int i=0; i<NumberOfPoints; i++) SineLines[i] = new Point(i * sizeClient.Width/NumberOfPoints, (int)(sizeClient.Height/2 * (1 - Math.Sin(2*Maths.Pi*i/NumberOfPoints)))); deviceContext.DrawLines(SineLines); }

Using DrawLines to draw the 1000 points approximating a sine curve is much quicker than making 1000 individual calls to the graphics subsystem. Many mathematical functions may be approximated in this fashion.

Note that the method Gdi::DrawLines accepts an array of points. The class Array is a collection class of considerable importance. Quite a few of the Win+ APIs make use of this class. Dynamic arrays are of such significance that future operating system will make extensive use of them. In a managed environment, there are also system arrays. When creating a system array, the dimension of the array needs to be known in advance. Dynamic arrays have no such restriction.