Microsoft KB Archive/42421

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:22, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q42421 to Microsoft KB Archive/42421 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Sample Animation Code Supplied with QuickC 1.01 Is Incorrect PSS ID Number: Q42421 Article last modified on 05-02-1989 PSS database name: S_QuickC

1.01

MS-DOS

Summary:

Microsoft Quick C Version 1.01 supplies a sample animation program C04_15.C, which is described on Page 109 of “Microsoft QuickC Compiler Programmer’s Guide.” The code that comes with the C04_15.C package does not erase the figure after drawing it. The example in the manual on Page 109 contains the correct code.

More Information:

The following is the corrected animation program:

  1. include <malloc.h> /* needed for buffer use */ #include <stdio.h> #include <graph.h> #include <math.h> #include <conio.h>

struct videoconfig vc; char error_message [] = “This video mode is not supported”; char far buffer; / used with _getimage & _putimage */

main() { if (_setvideomode(_MRES4COLOR) == 0) { printf (“%s”, error_message); exit(0); } _getvideoconfig (&vc); hypcycle(); /* call drawing function */ _clearscreen(_GCLEARSCREEN); _setvideomode (_DEFAULTMODE); /* restore video mode / } hypcycle() { float pi=3.14159; / declare and initialize */ float a,h,b,r,x0,y0,x,y, ang; int i,j; x0 = vc.numxpixels/2 -1; y0 = vc.numypixels/2 -1; printf (“Enter circle ratio (>=1):”); scanf (“%f”, &r); printf (“pen position (>1):”); scanf (“%f”,&h);

draw_and_store_figure(); /* place figure in buffer */ _clearscreen (_GCLEARSCREEN);

_setcolor (1); _moveto (x0,0); /* draw axes */ _lineto (x0,vc.numypixels); _moveto (0,y0); _lineto (vc.numxpixels,y0);

a = 0.5rvc.numypixels/(r+h-1); b = a/r; h = h*b; _setcolor (2); ang = 0; while (!kbhit()) { /* draw hypocycloid / for (i=1; i<= 20; i++) { ang = ang + 2pi/100; x = x0+(a-b)cos(ang)+hcos(ang(a-b)/b); y = y0-(a-b)sin(ang)+hsin(ang(a-b)/b); _putimage (x,y,buffer,_GXOR); for (j=1; j<=6000; j++) ; _putimage (x,y,buffer,_GXOR); } } } draw_and_store_figure() { _setbkcolor (0L); _setcolor (1); _rectangle (_GBORDER,0,0,10,10); _setcolor (2); _rectangle (_GFILLINTERIOR,1,1,9,9); _setcolor (3); _moveto (1,1); _lineto (9,9); _moveto (1,9); _lineto (9,1); buffer=(char far *)malloc((unsigned int)_imagesize(0,0,10,10)); _getimage (0,0,10,10, buffer); }

Copyright Microsoft Corporation 1989.