How to draw a circle with a specified radius?
Posted: 2017-04-10T05:05:19-07:00
As the documentation says:
Wtf? It doesn't work like this. What's the perimeter gets the Magick::DrawableCircle?
As the Math says:DrawableCircle
double originX_, double originY_, double perimX_, double perimY_
Draw a circle using the stroke color and thickness using specified origin and perimeter coordinates. If a fill color is specified, then the object is filled.
Well, ok:Perimeter of a circle is: 2 * PI * R, where R is states for radius.
Code: Select all
Magick::Image testImg( Magick::Geometry( 500, 500 ), Magick::Color( "white" ) );
testImg.strokeColor( "red" );
testImg.fillColor( Magick::Color( QuantumRange, QuantumRange, QuantumRange, 0 ) );
testImg.strokeWidth( 1 );
float centerX = 100, centerY = 100;
float w = 100, h = 100;
float R = 100;
float circlePerimeter = 2 * M_PI * R;
testImg.draw( Magick::DrawableCircle( centerX, centerY, circlePerimeter, circlePerimeter ) );
testImg.write( "images/test-img.png" );