Professional Web Applications Themes

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. #1

    Default 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.
    Andrejus_Chaliapinas@adobeforums.com Guest

  2. #2

    Default 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 + inRadius*ARC_MAGIC, inCenterY + inRadius,
    inCenterX, inCenterY + inRadius );
    CurveTo( inCenterX - inRadius*ARC_MAGIC, inCenterY + inRadius,
    inCenterX - inRadius, inCenterY + inRadius*ARC_MAGIC,
    inCenterX - inRadius, inCenterY );
    CurveTo( inCenterX - inRadius, inCenterY - inRadius*ARC_MAGIC,
    inCenterX - inRadius*ARC_MAGIC, inCenterY - inRadius,
    inCenterX, inCenterY - inRadius );
    CurveTo( inCenterX + inRadius*ARC_MAGIC, inCenterY - inRadius,
    inCenterX + inRadius, inCenterY - inRadius*ARC_MAGIC,
    inCenterX + inRadius, inCenterY );
    Close();
    }
    Leonard_Rosenthol@adobeforums.com Guest

  3. #3

    Default 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?
    Andrejus_Chaliapinas@adobeforums.com Guest

  4. #4

    Default 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').
    Leonard_Rosenthol@adobeforums.com Guest

  5. #5

    Default 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?
    Andrejus_Chaliapinas@adobeforums.com Guest

  6. #6

    Default 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.
    Andrejus_Chaliapinas@adobeforums.com Guest

  7. #7

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

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

    Hi All,

    I am using above code snippet, but it gives error because MoveTo() & CurveTo() function is not present.
    please reply..
    Madhav@adobeforums.com Guest

  8. #8

    Default 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;
    Andrejus_Chaliapinas@adobeforums.com Guest

  9. #9

    Default 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..
    Thanks in Advance..
    Madhav@adobeforums.com Guest

  10. #10

    Default 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.....
    kirubasankar@adobeforums.com Guest

  11. #11

    Default 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.....
    kirubasankar@adobeforums.com Guest

  12. #12

    Default 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.
    Leonard_Rosenthol@adobeforums.com Guest

  13. #13

    Default 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
    kirubasankar@adobeforums.com Guest

Similar Threads

  1. new user question-no pixels selected pop-up
    By maryellen in forum Adobe Photoshop Elements
    Replies: 3
    Last Post: August 31st, 10:57 PM
  2. Draw a circle/rectangle dynamically
    By drkshih in forum Macromedia Flex General Discussion
    Replies: 8
    Last Post: July 29th, 05:33 PM
  3. Adjusting ruler increments from every 12 pixels to every 10 pixels?
    By RobAbbott@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 2
    Last Post: April 15th, 10:39 PM
  4. Question concerning pixels, Please help!!
    By Lostboy24 webforumsuser@macromedia.com in forum Macromedia Freehand
    Replies: 2
    Last Post: January 20th, 04:36 PM
  5. Replies: 0
    Last Post: November 29th, 06:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139