Primitives and Markers Renderers

Source: Internet
Author: User

Excerpt from: http://www.cnblogs.com/muxue/archive/2010/06/03/1751094.html

A number of renderers for the underlying mapping object (primitives) and markup (marker) are also included inthe AGG. This mechanism allows you to quickly depict common, jagged objects such as lines, rectangles, ellipses, and so on. Markers (marker) can draw someshapes that are common in scatter plots (scatter plots). If you are not going to use them, then you can skip the content of this section.

Primitives Renderer

header file : agg_renderer_primitives.h

Declaration

Template<class baserenderer> classrenderer_primitives

{

Public

typedef baserenderer BASE_REN_TYPE;

typedef typename BASE_REN_TYPE::COLOR_TYPE Color_type;

//.. .

};

Here's Baserenderer can be used renderer_base or renderer_mclip.

Creation

Renderer_primitives (base_ren_type& ren):

M_ren (&ren),

M_fill_color (),

M_line_color (),

M_curr_x (0),

M_curr_y (0)

{}

the overhead of creating is very small, just initializing a pointer to a base renderer object, two color information, and initializing coordinate values, which are used in the move_to and line_to functions.

Member functions

static int coord (double c);

converts the coordinate value of a double type to a sub-pixel precision int . What it does is multiply the double value by the sum and return the integral part of it.

void Fill_color (const color_type& c);

void Line_color (const color_type& c);

Const color_type& Fill_color () const;

Const color_type& Line_color () const;

Gets or sets the color of fill or line. The color can have an alpha value and the value will take effect, so the Base screen object (primitives) can be rendered alpha-blended.

void Rectangle (int x1, int y1, int x2, inty2);

paints a rectangle, but does not fill the color of the line. Using normal pixel coordinates, the width of the boundary is always 1 pixels and cannot be modified.

void Solid_rectangle (int x1, int y1, intx2, int y2);

Paints a solid rectangle with no bounds and fills the color of the line. The pixel coordinates are used.

void Outlined_rectangle (int x1, int y1, intx2, int y2);

paints a solid rectangle with a border. Color lines (colors line) and padding (fill?) are used. .

void ellipse (int x, int y, int rx, int ry);

void Solid_ellipse (int x, int y, int rx,int ry);

void Outlined_ellipse (int x, int y, int rx,int ry);

depicting an ellipse, hollow, solid, or solid with a boundary. Coordinates are integer values, measured in pixels. Rx and ry are oval radii measured in pixels.

void line (int x1, int y1, int x2, int y2,bool last=false);

depicts a Bresenham grating line using subpixel accuracy . The format of the coordinates is 24.8, that is,the pixel precision of the 1/256. last determines whether to paint the final pixel, which is important for using alpha mixed rendering to depict consecutive segments. There should be no pixels to be painted multiple times.

void move_to (int x, int y);

void line_to (int x, int y, boollast=false);

Line () version.

Const base_ren_type& ren () const {return *m_ren;}

base_ren_type& Ren () {return *m_ren;}

returns a reference to the base renderer object.

Const rendering_buffer& RBUF () const {return m_ren->rbuf ();}

rendering_buffer& Rbuf () {returnm_ren->rbuf ();}

Returns a reference to the rendering buffer attached to base renderer .


Provide examples:


Agg::rendering_buffer &rbuf = Rbuf_window ();

Agg::p ixfmt_bgr24 pixf (RBUF);


typedef agg::renderer_base<agg::p ixfmt_bgr24> renderer_base_type;

Renderer_base_type Renb (PIXF);


Agg::renderer_primitives<renderer_base_type> Primitive (RENB);

Primitive.line_color (Agg::rgba8 (255,0,0));//Set the color of the line

Primitive.fill_color (Agg::rgba8 (0,255,0));//Set the color of the fill

Primitive.solid_ellipse (230,230,220,220);//Draw a solid circle

Primitive.solid_rectangle (300,300,400,400);//Draw a solid rectangle


Summary: Rendering_buffer (RGB component)-"pixfmt_bgr24 (pixel)-" renderer_base (pixel operation with clipping area)-"renderer_primitives (draw some simple jagged shapes)


In the above process, it is necessary to think over and over, and now realize the function is not using any of the complex algorithm, are very well-behaved to the pixel point of a series of RGB assignment, in fact, the operation is to render the cached pointer, there is no offset.




Primitives and markers renderers

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.