Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

AGG lesson 10 agg::conv_stroke rendering Contour Line

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1 preface

The outline is the boundary of the graph, and any closed vertex source that skips the agg::conv_stroke phase will depict a solid figure with the same color and boundary as the fill. If you don't close the vertex source, once you skip agg::conv_stroke, you don't draw anything. Agg::conv_stroke is used to depict the boundaries of graphics.

Compared with agg::conv_contour, agg::conv_contour is the outline of the extended graphics, and the popular point is to expand the boundaries of the graphics and scale the boundaries of the graphics (but unlike agg::trans_affine, this is a zoom with the same central position).

Extracted from: McSeem

A line is in general more complexobjectthan a polygon. Well, unless it's a simple jagged Bresenham line. All linesareeventually converted into polygons that represent their outlines. So that,inmodern graphics there are no lines,there are * strokes*. And conv_strokedoesthis job

2 official examples

Execute the examples/conv_stroke routine, providing the following control:

1) switching of segment endpoints

2) the connection mode between line segments

3) Segment width

4) Link notch of miter limit artifact

3 setting of contour attributes

1) shape of the end of the segment

Enum line_cap_e

{

The shape of butt_cap,// button is no different from that of square.

After square_cap,// is set, the length is longer than butt_cap.

Round_cap// semicircle shape

}

Setting function: voidline_cap (line_cap_e lc)

2) the width of the segment

Setting function: voidwidth (double w)

3) introduce the default parameters of stroke

Of course, we can not call line_cap or width, because stroke has a default constructor, and the default parameters are specified as follows:

M_width (0.5)

M_width_abs (0.5)

M_width_eps (0.5Accord 1024.0)

M_width_sign (1)

M_miter_limit (4.0)

M_inner_miter_limit (1.01)

M_approx_scale (1.0)

M_line_cap (butt_cap)

M_line_join (miter_join)

M_inner_join (inner_miter)

4) Line segment style of agg::conv_stroke

The rendering mode of solid line is adopted. Can we describe the dashed line by replacing her: agg::conv_dash

It turns out that nothing has been rendered! Agg::conv_dash will describe it separately!

4 examples

Ras.reset ()

Agg::path_storage ps1

Ps1.move_to (200200)

Ps1.line_to (300300)

Agg::line_cap_e cap = agg::round_cap;// sets the shape of the end of the segment

Agg::conv_stroke stroke (ps1); / / the style of the segment

Stroke.line_cap (cap)

Stroke.width (50); / / sets the width of the segment

Ras.add_path (stroke)

Agg::render_scanlines_aa_solid (ras,sl,renb,agg::rgba8 (255j0pl 0))

5 description of the usage of shorten function 1

Methods for shortening paths have been added to conv_stroke and conv_dash objects. It is very effective for rendering arrows with thick lines. There is also an agg_conv_shorten_path converter object that can be used alone.

2 exampl

M_slider1 (80,250,600-101.276,! flip_y)

Add_ctrl (m_slider1)

M_slider1.range (0300)

M_slider1.num_steps (30)

M_slider1.value (1)

/ / A collapse reduction process

Agg::ellipse ell1 (230230140150)

Agg::conv_stroke stroke1 (ell1)

Stroke1.width (30)

Stroke1.shorten (m_slider1.value ())

Ras.add_path (stroke1)

/ / similar to shortening

Agg::path_storage ps

Ps.move_to (20 and 30)

Ps.line_to (440 and 30)

Agg::conv_stroke stroke2 (ps)

Stroke2.width (30)

Stroke2.shorten (m_slider1.value ())

Ras.add_path (stroke2)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report