3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Graphical programming will be demonstrated with an Analog Clock program called "AClock".

Microsoft Visual C++ and MFC have an unbelievably large number of functions related to graphical programming. There are functions for color, size, shape, attributes, and modes of various objects. You can type in one color and draw lines and shapes in another. Viewports can be scaled and modified. Coordinate functions can be in convenient units. You can draw lines, arcs, polylines, beziers, circles, pies, rectangles, and other figures. These may be empty or filled with color. Bitmaps can be inserted. Fonts can be changed.

The program for this month's meeting will demonstrate only a few of these possibilities. However, it will attempt to be useful. The subject is an analog clock. Some of the issues to be discussed include color, lines, circles, text and filling. In addition, some basic programming challenges must be considered. These include the basic algorithm for the clock, floating-point mathematics, speed and smoothness of the display, processor utilization (or lack thereof), and other topics.

At the meeting on Tuesday night we will be discussing the utility and the source code.

SAMPLE CODE =========== void TimePiece::hand(double size, double angle) /* draw hand */ { struct FPOINT p1, p2, p3, center; double ang1, ang2, half; half = size/3.0; ang1 = angle + (20.0/size-10.0); /* P3 */ ang2 = angle - (20.0/size-10.0); /* /\ */ center.wx = center.wy = 0.0; /* / \ */ p3.wx = size * sin( angle*2.0*PI/360.0); /* P1/ \P2 */ p3.wy = size * cos( angle*2.0*PI/360.0); /* \ / */ p1.wx = half * sin( ang1 *2.0*PI/360.0); /* \ / */ p1.wy = half * cos( ang1 *2.0*PI/360.0); /* \/ */ p2.wx = half * sin( ang2 *2.0*PI/360.0); /* CENTER */ p2.wy = half * cos( ang2 *2.0*PI/360.0); POINT Points[5]; Points[0].x = (long)(center.wx*1000); Points[0].y = (long)(center.wy*1000); Points[1].x = (long)(p1.wx*1000); Points[1].y = (long)(p1.wy*1000); Points[2].x = (long)(p3.wx*1000); Points[2].y = (long)(p3.wy*1000); Points[3].x = (long)(p2.wx*1000); Points[3].y = (long)(p2.wy*1000); Points[4].x = (long)(center.wx*1000); Points[0].y = (long)(center.wy*1000); pdc->Polygon(&Points[0], 4); } void TimePiece::face() /* add circles for hour marks */ { struct FPOINT p1; int x1, y1, x2, y2, i; double deg,r,ul_x, ul_y, lr_x, lr_y; for (r=0.09,i=0; i<12; i++) { deg = (double)i*30.0; p1.wx = 0.9*sin( deg*2.0*PI/360.0); p1.wy = 0.9*cos( deg*2.0*PI/360.0); ul_x = p1.wx-r; ul_y = p1.wy+r; lr_x = p1.wx+r; lr_y = p1.wy-r; x1 = (int)(ul_x*1000); y1 = (int)(ul_y*1000); x2 = (int)(lr_x*1000); y2 = (int)(lr_y*1000); pdc->Ellipse(x1, y1, x2, y2); } }

"Random Access" questions start at 7:30 Tuesday night.

Back to C++ Main Page