The program of this section demonstrates drawing of various types of figures supported by the graphics engine. The output of the program is shown below.
The program draws:
It should be apparent from the output that certain of the primitives fill the area enclosed within. The portion of the program that draws the figures is shown below.
case message::paint: { paint paint_struct; handle device_context = begin_paint(window,&paint_struct); select_object(device_context,create_solid_brush(0x0000ff)); draw_rectangle(device_context, width_of_client/8, height_of_client/8, 7*width_of_client/8, 7*height_of_client/8); move_to(device_context,0,0); draw_line_to(device_context,width_of_client,height_of_client); move_to(device_context,0,height_of_client); draw_line_to(device_context,width_of_client,0); delete_object(select_object(device_context,create_solid_brush(0x00ff00))); draw_ellipse(device_context, width_of_client/8, height_of_client/8, 7*width_of_client/8, 7*height_of_client/8); delete_object(select_object(device_context,create_solid_brush(0xff0000))); draw_rounded_rectangle(device_context, width_of_client/4, height_of_client/4, 3*width_of_client/4, 3*height_of_client/4, width_of_client/4, height_of_client/4); end_paint(window_handle,&paint_struct); } break;
Drawn first is a rectangle from 1/8 to 7/8 the size of the client window (in both directions). Next, two lines that form the diagonals of the client are drawn. An ellipse with the given coordinates is overlaid, covering from 1/8 to 7/8 of the client (in both the vertical and horizontal directions). Finally, an elliptically rounded rectangle of the given dimensions is drawn. It should be apparent from the structure of the display that certain of the primitives are overlaid (hence their interiors are drawn).