# Last question for today - how to draw withAPI circle of N pixels radius - Adobe Acrobat SDK

Hi, While I'm bit of exhausted while fighting with those paths movement (see my other thread in this forum) - I'd like to ask maybe someone has code snippet, which shows how to draw a circle of N pixels/N mm/inches radius? There is one helper function for that inside SDK samples: PDEPath DrawCurve(ASFixed x, ASFixed y, ASFixed x1, ASFixed y1, ASFixed x2, ASFixed y2, ASFixed x3, ASFixed y3, int lineWidth, int r, int g, int b) but I'm just out of my mind for today what parameters should be provided and how many calls of it I should write. Any ...

1. ## Last question for today - how to draw withAPI circle of N pixels radius

Hi,

While I'm bit of exhausted while fighting with those paths movement (see my other thread in this forum) - I'd like to ask maybe someone has code snippet, which shows how to draw a circle of N pixels/N mm/inches radius?

There is one helper function for that inside SDK samples:

PDEPath DrawCurve(ASFixed x, ASFixed y, ASFixed x1, ASFixed y1, ASFixed x2, ASFixed y2, ASFixed x3, ASFixed y3, int lineWidth, int r, int g, int b)

but I'm just out of my mind for today what parameters should be provided and how many calls of it I should write.

Any help would be appreciated.

2. ## Re: Last question for today - how to drawwith API circle of N pixels radius

You call it four times...

Here is a snippet that explains the math...

/* 4/3 * (1-cos 45ƒ)/sin 45ƒ = 4/3 * sqrt(2) - 1 */
#define ARC_MAGIC ((ASFixed) 0.552284749)
#define PI ((ASFixed)3.141592654)

void DrawCircle( ASFixed inCenterX, ASFixed inCenterY, ASFixed inRadius )
{
/* draw four Bezier curves to approximate a circle */
MoveTo( inCenterX + inRadius, inCenterY );
CurveTo( inCenterX + inRadius, inCenterY + inRadius*ARC_MAGIC,
inCenterX, inCenterY + inRadius );
CurveTo( inCenterX - inRadius*ARC_MAGIC, inCenterY + inRadius,
inCenterX - inRadius, inCenterY );
CurveTo( inCenterX - inRadius, inCenterY - inRadius*ARC_MAGIC,
inCenterX, inCenterY - inRadius );
CurveTo( inCenterX + inRadius*ARC_MAGIC, inCenterY - inRadius,
inCenterX + inRadius, inCenterY );
Close();
}

3. ## Re: Last question for today - how to drawwith API circle of N pixels radius

Hi Leonard,

Thank you for that snippet!

What is the best way to fill this painted circle with black? Do I need first to fill those curve segments and then draw filled internal rectangle? Or there is any other way for that?

4. ## Re: Last question for today - how to drawwith API circle of N pixels radius

You would follow up the drawing operators will a set color operator ('g') and then a fill operator ('f').

5. ## Re: Last question for today - how to drawwith API circle of N pixels radius

If inRadius is of value 1.4175 (instead of let say 72) - I think it doesn't work with ARC_MAGIC value. I only see 2 segments of whole circle painted correctly in that case. What shold be used for such small radius values?

6. ## Re: Last question for today - how to drawwith API circle of N pixels radius

Sorry, was my mistake with some commented lines. Everything works properly.

7. ## Re: Last question for today - how to drawwith API circle of N pixels radius

CurveTo( inCenterX + inRadius, inCenterY + inRadius*ARC_MAGIC,
inCenterX, inCenterY + inRadius );

Hi All,

I am using above code snippet, but it gives error because MoveTo() & CurveTo() function is not present.

8. ## Re: Last question for today - how to drawwith API circle of N pixels radius

Hi,

Take a look at PDEPathDrawCurveSnip.cpp in Plugins samples.

What you actually need is to have your own function (call it DrawCircle for example) similar to DrawCurve, in which you'll have your own sequence of these statements:

ASFixed pathData[10];
pathData[0] = kPDEMoveTo;
pathData[1] = x;
pathData[2] = y;
pathData[3] = kPDECurveTo;
pathData[4] = x1;
pathData[5] = y1;
pathData[6] = x2;
pathData[7] = y2;
pathData[8] = x3;
pathData[9] = y3;

9. ## Re: Last question for today - how to drawwith API circle of N pixels radius

Hi..
I am create curto() as follows...

void CurveTo(ASFixed x, ASFixed y, ASFixed x1, ASFixed y1, ASFixed x2, ASFixed y2)
{
PDEPath path = PDEPathCreate();
PDEPathSetPaintOp(path, kPDEStroke);

PDEGraphicState gState = SetGraphicState(ASInt32ToFixed(1),
ASInt32ToFixed(1), ASInt32ToFixed(0), ASInt32ToFixed(0));
PDEElementSetGState((PDEElement) path, &gState, sizeof(PDEGraphicState));

ASFixed pathData[10];
pathData[0] = kPDEMoveTo;
pathData[1] = x;
pathData[2] = y;
pathData[3] = kPDECurveTo;
pathData[4] = x1;
pathData[5] = y1;
pathData[6] = x2;
pathData[7] = y2;
PDEPathSetData(path, pathData, sizeof(pathData));
}

but it doesn't work i.e not shown circle.. please reply..

10. ## Re: Last question for today - how to drawwith API circle of N pixels radius

sir i want to generate a small circle while i click a button inside my circle it will count automatically ...so please send me the code.....

11. ## Re: Last question for today - how to drawwith API circle of N pixels radius

sir i want to generate a small circle while i click a button.. inside my circle it should display (one) 1 ...while i clicked each time it will automatically get increamented ..upto 999 if(count=1000) again it will display 1 in the circle..it will count automatically ...so please send me the code.....

12. ## Re: Last question for today - how to drawwith API circle of N pixels radius

You need to look at the doentation for Acrobat forms and JavaScript.

13. ## Re: Last question for today - how to drawwith API circle of N pixels radius

am using acrobat pro can u please tell me how could i create the above task using acrobat pro