Page 1 of 1

Failure on wand function: DrawPathEllipticArcAbsolute

Posted: 2010-07-09T09:44:49-07:00
by hightman
When I use DrawPathEllipticArcAbsolute() for a small arcline which degree smaller than 40/360, nothing can be drew on the DrawingWand.
ImageMagick version: 6.6.3-0 (newest, but old version 6.5.3-6 works well)

Test C code:

Code: Select all

#define RADIUS                  50
#define DEG2RAD(d)              (((float)(d)) / 180.0 * 3.14)
#include <MagickWand.h>
#include <math.h>

MagickWand *mgck_wnd;
DrawingWand *drw_wnd;
PixelWand *pxl_wnd;

void draw_sector(int sd, int ed)
{
        // ox=100, oy=100, raidus = 50
        int sx, sy, ex, ey;

        sx = 100 + (int)(cos(DEG2RAD(sd)) * 50);
        sy = 100 + (int)(sin(DEG2RAD(sd)) * 50);

        ex = 100 + (int)(cos(DEG2RAD(ed)) * 50);
        ey = 100 + (int)(sin(DEG2RAD(ed)) * 50);

        // draw the secotr path
        DrawPathStart(drw_wnd);
        DrawPathMoveToAbsolute(drw_wnd, 100, 100);
        DrawPathLineToAbsolute(drw_wnd, ex, ey);
        DrawPathMoveToAbsolute(drw_wnd, 100, 100);
        DrawPathLineToAbsolute(drw_wnd, sx, sy);
        DrawPathEllipticArcAbsolute(drw_wnd, 50, 50, 0, (ed - sd) >= 180 ? MagickTrue : MagickFalse, MagickTrue, ex, ey);
        DrawPathClose(drw_wnd);
        DrawPathFinish(drw_wnd);
}

int main(int argc, char *argv[])
{
        MagickWandGenesis();
        mgck_wnd = NewMagickWand();
        drw_wnd = NewDrawingWand();
        pxl_wnd = NewPixelWand();

        // 
        PixelSetColor(pxl_wnd, "red");
        DrawSetFillColor(drw_wnd, pxl_wnd);

        // try draw some sector (from 0 -> endDegree)
        draw_sector(0, 30);     // failure
        draw_sector(40, 90);    // OK!
        draw_sector(90, 110);   // failure
        draw_sector(120, 200);  // OK!
        // create picture & drawing it
        PixelSetColor(pxl_wnd, "white");
        MagickNewImage(mgck_wnd, 200, 200, pxl_wnd);
        MagickDrawImage(mgck_wnd, drw_wnd);

        // output the image
        MagickSetFormat(mgck_wnd, "GIF");
        MagickWriteImagesFile(mgck_wnd, stdout);

        // destroy
        DestroyPixelWand(pxl_wnd);
        DestroyDrawingWand(drw_wnd);
        DestroyMagickWand(mgck_wnd);
        MagickWandTerminus();
        exit(0);
}