#include "StdAfx.h" #include "special.h" // code for the three shapes of Figure 1 int specialDraw(POINT *vp, int buf_size, int *np, char *cp) { if(buf_size < 11) return 0; #ifdef USE_CONV_FUNCTIONS int k = 0; initialize(vp, np, cp); POINT z[4] = { 100, 100, 200, 200}; k += path(z, 2, ELLIPSE_SH); z[0].x += 300; z[1].x += 310; k += path(z, 2, ELLIPSE_SH); POINT za[4] = {250, 100, 350, 200, 295, 100, 305, 100}; k += path(za, 4, ARC_SH); POINT zb[3] = {295, 100, 300, 120, 305, 100}; k += path(zb, 3, POLYLINE_SH); return k; #else vp[0].x = 100; vp[0].y = 100; vp[1].x = 200; vp[1].y = 200; np[0] = 2; cp[0] = 'e'; vp[2].x = 400; vp[2].y = 100; vp[3].x = 510; vp[3].y = 200; np[1] = 2; cp[1] = 'e'; vp[4].x = 250; vp[4].y = 100; vp[5].x = 350; vp[5].y = 200; vp[6].x = 295; vp[6].y = 100; vp[7].x = 305; vp[7].y = 100; np[2] = 4; cp[2] = 'a'; vp[8].x = 295; vp[8].y = 100; vp[9].x = 300; vp[9].y = 120; vp[10].x = 305; vp[10].y = 100; np[3] = 3; cp[3] = 'p'; return 4; #endif }
The shapes are described in the way
that matches the way Windows functions draw each shape. The array np
contains
the number of points for each shape and the array cp
pDC
is a pointer to a
device context, the above example will result to the ultimate (from inside PED) call of the
functions given below to draw the shapes of Figure 1.
pDC->Ellipse(vp[0].x, vp[0].y, vp[1].x, vp[1].y); pDC->Ellipse(vp[2].x, vp[2].y, vp[3].x, vp[3].y); pDC->Arc(vp[4].x, vp[4].y, vp[5].x, vp[5].y, vp[6].x, vp[6].y, vp[7].x, vp[7].y); pDC->Polyline(&(vp[8]), np[3]);