Andreas
Andreas

Reputation: 23958

Filled imagearc

I'm trying to draw a arc (part of circle) that is filled with semi transparent color. Is that possible?
I have found Imagearc but that only draws the line, and there is the imagefilledarc that draws 3d shaped arcs.
And there is eclipse which draws complete circles.

None of those do what I need. What can I use to get the image from:
enter image description here

To: (please try to look beyond my paint skills)

enter image description here

I have the angle of the main wind which is 150 degrees, and the wind variation 120-190 degrees, but how do I draw that semi transparent filled arc?
EDIT; I also have the centerpoint, and the diameter of the lines.

Upvotes: 2

Views: 513

Answers (1)

timclutton
timclutton

Reputation: 13004

Actually imagefilledarc() is the correct function for this. It doesn't draw 3D shapes - that is simply the example given in the PHP manual.

Using your first image with this code...

imagefilledarc(
    $im, // gd image resource
    512, // centre point x
    325, // centre point y
    285, // width (keep same as height for a perfect circle)
    285, // height (keep same as width for a perfect circle)
    120-90, // start (-90 degrees to start from 12 o'clock)
    190-90, // end (-90 degrees to start from 12 o'clock)
    0x40ff0000, // colour (50% transparent red)
    IMG_ARC_PIE
);

...gives me this result:

enter image description here

All you should need to do is replace the parameters with your calculated values (centre points, diameter, etc.).

Upvotes: 1

Related Questions