Agg::ellipse Draw a circle (expand)

Source: Internet
Author: User

Introduction: At the beginning of the Agg::conv_stroke do not understand, think she and Agg::conv_dash is the same goods, and represent solid lines and dashed lines, in fact,Agg::conv_stroke the location of such storage lines , width, line end shape, line connection method and so on , through the use of dashed lines to render the circle, fully understand how they cooperate with each other.

Section one: How to use dashed lines

Examples are as follows:

    //vertex source vertex source, I prefer to call it an endpoint collection, or Point collection matrix      //The first parameter is the x-coordinate of the circle center, the second parameter is the y-coordinate of the circle center     //The third parameter is the X-radius of the circle, and the fourth parameter is the Y-radius of the circle      //according to the third and fourth parameters can be learned that the circle can be a flat circle,     //is not necessarily a well-behaved circular      agg::ellipse ell (200,200,50,100);     //using dashed lines     typedef  agg::conv_dash<agg::ellipse> ell_cd_type;    ell_cd_type cdccell (ell );     cdccell.add_dash (5,5);     typedef agg::conv_stroke<ell_ Cd_type> ell_cc_cs_type;    ell_cc_cs_type csccell (Cdccell);     ras.add_path (Csccell);     rensl.color (Agg::rgba8 (255,0,0));     agg::render_scanlines (RAS,SL,RENSL);     ras.reset (); 

The dashed line is depicted by constructing the Agg::conv_dash template and then creating to Agg::conv_stroke.

Section Two: The transformation of the indentation, offset, rotation

    //vertex source Vertex source, I prefer to call it an endpoint collection, or a point set matrix     //the first parameter is the x-coordinate of the circle center, The second parameter is the y-coordinate of the circle center     //The third parameter is the X-radius of the circle, and the fourth parameter is the Y-radius of the circle     // According to the third and fourth parameters can be learned that the circle can be a flat circle,     //is not necessarily a well-behaved circular     agg::ellipse  Ell (200,200,50,100);     //Coordinate conversion     agg::trans_affine mtx;     mtx.scale (0.5,1);  //x axis shrinks to the original half     mtx.rotate (agg::d Eg2rad (30));// Rotate 30 degrees     mtx.translate (200,200);//x,y coordinates translate 100&NBSP;&NBSP;&NBSP;&NBSP;TYPEDEF&NBSP;AGG:: Conv_transform<agg::ellipse> ell_ct_type;    ell_ct_type ctell (ELL,MTX);  //Matrix Transformation     typedef agg::conv_dash<ell_ct_type> ell_cd_type;     ell_cd_type cdccell (Ctell);     cdccell.add_dash (5,5);     typedef agg::conv_stroke<eLl_cd_type> ell_cc_cs_type;    ell_cc_cs_type csccell (Cdccell); 

Excerpt from: http://www.cnblogs.com/CoolJie/archive/2011/04/27/2030122.html

In this example, there are a lot of articles introduced:Agg::conv_contour, in fact, the removal of this thing, for rendering has no effect, from here can be seen Agg is a very loose rendering tool, she provides a lot of tools, but you can easily render, You can also perform a series of conversions.

The transformation matrix is a very good thing, the core is a series of transformations of the coordinates, in fact, when we build a shape such as a circle, in fact, Agg already know all the point coordinates formed, and then the coordinates of the point to operate.

Note: Trans_affine is not only used for the transformation of the source vertex, it can be seen in many places in the agg library. For example, the line segment (span) generator, which is described later, is able to freely transform the pattern that fills within the polygon through the transformation matrix.

Agg::ellipse Draw a circle (expand)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.