Message-ID: <20030129141609.69806.qmail@web13004.mail.yahoo.com> Date: Wed, 29 Jan 2003 06:16:09 -0800 (PST) From: Thomas Tutone Subject: Re: problem with fixed datatype (drawing simple arcs / pie segments) To: djgpp AT delorie DOT com Cc: M DOT Czamai AT gmx DOT net MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: djgpp AT delorie DOT com "Martin Czamai" wrote: > my problem is, that I want to draw a something like > a pie (circle > segment) to some bitmap, but the current code > doesn't work. Can > somebody please tell me how to handle the fixed > class correctly? This > is extraction of the current code: ^^^^^^^^^^ > > typedef struct tagPOINT > { > int x; > int y; > }POINT; > : > typedef struct tagPIE > { POINT ptCenter; // center of drawing > the arc (pie) > int nRadius; // inner > radius > int nDiameter; // width of arc (pie) > float rBeginAngle; // start angle of pie > float rEndAngle; // end angle of pie > }PIE; > : > #define FACTOR_ANGLE_TO_ALLEGRO_ANGLE 0.7111111111 > // 256/360 = > 0.71111... > : > : > somewhere in the code: > : > PIE pie; // this struct is filled with valid > data somewhere else > and > //rBeginAngle < rEndAngle ! > : > fix fixBegin, fixEnd, fixAngle; > fixBegin = ::ftofix(pie.rBeginAngle * > FACTOR_ANGLE_TO_ALLEGRO_ANGLE); > fixEnd = ::ftofix(pie.rEndAngle * > FACTOR_ANGLE_TO_ALLEGRO_ANGLE); int > nCntr = 0; nCoord[14400]; > > // draw contours of pie / circle segment only > for(int nRadius=pie.nRadius; > nRadius <= (pie.nRadius + pie.nDiameter); > nRadius += pie.nDiameter) > { > // the following never starts to run - why?? > for(fixAngle=fixBegin; fixAngle != fixEnd; > fixAngle += ftofix(0.1)) > { > fix fixSIN = sin(fixAngle); > fix fixCOS = cos(fixAngle); > > fix fixX = fixCOS * fix(nRadius); > fix fixY = fixSIN * fix(nRadius); > > nCoord[nCntr++] = (int)pie.ptCenter.x + (int) > fixX; > nCoord[nCntr++] = (int)pie.ptCenter.y + (int) > fixY; > } > } > // use allegro's polygon function to draw the > segment... > polygon(bmpTarget, nCntr/2, nCoord, clColor); > > Maybe I'm too stupid, but I'm really interested in > what's going wrong > here. Please help! Martin, I don't think the problem is that you're too stupid. Rather, the problem is that you are violating the first cardinal rule when asking for help in this (and most other) newsgroups: POST COMPILABLE CODE. That means that we must be able to cut and paste what you provide and compile it ourselves without changes. We can't do that with what you provide. The second cardinal rule is make sure that the compilable code you provide is short - no more than 50 lines is a good rule of thumb. Here you provide an "extraction" - that's good - but it must be a self-contained extraction that we can compile. If we can't recreate your problem, we can't help you. By the way, what the heck is "fix"? Is that a class defined in allegro? And are you coding in C or in C++? It looks like some sort of hybrid. Good luck. Best regards, Tom __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com