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 14 agg::conv_dash rendering dashed lines

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

Share

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

1 file reference and parameter description

File definition: include/agg_conv_dash.h

Class definition:

Template

Conv_dash (VertexSource& vs):

Conv_adaptor_vcgen (vs)

Note: you need to pass the vertex source as a construction parameter.

Void add_dash (double dash_len, double gap_len)

The first parameter is the length of the solid line, and the second parameter is the distance between the two solid lines. By building several solid lines apart from the gap_len, the effect of the dashed line is achieved.

2 experience in use

At the beginning, I thought that agg::conv_stroke and agg::conv_dash conflict with each other, that the former is rendered solid line, the latter is rendered dashed line, in fact, the former is the outline of rendering any graphics, dashed line is also a kind of contour line, but it is just a split bar!

3 exampl

The code is as follows:

Agg::path_storage ps1

Ps1.move_to (200200)

Ps1.line_to (1300, 1300)

Agg::conv_dashdash (ps1)

/ / the first parameter is the length of the solid line, and the second parameter is the distance between the two solid lines.

/ / solid lines with a distance of 25 to achieve the effect of dotted lines

Dash.add_dash (5pm 25); / / you can see the effect by making different adjustments, if it is 5pm 5.

/ / may not have any effect at all!

Agg::conv_strokestroke (dash)

/ / add to the renderer

Ras.add_path (stroke)

/ / render the lines to the memory image, ready to display

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

Ras.reset ()

4 width of the dashed line

If the length of the current dash_len is relatively short, you can cancel anti-aliasing and speed up the rendering. You can compare the results and try to use the stroke.width function to set the width. Dash does not provide a function to set the lineweight.

5 cancel the anti-aliasing of dotted lines

Ras.gamma (agg::gamma_threshold, 0.5)

Examples are as follows:

Ras.reset ()

Agg::path_storage ps

Ps.move_to (30pr 40)

Ps.line_to (1300, 1400)

Agg::conv_dash dash (ps)

Dash.add_dash (10Pol 30)

Agg::conv_strokestroke (dash)

Ras.add_path (stroke)

/ / stroke.width (5); / / Test linewidth

Ras.gamma (agg::gamma_threshold (0.5)); / / Test anti-aliasing

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

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