温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

AGG第十课 agg::conv_stroke 渲染轮廓线

发布时间:2020-07-03 15:10:55 来源:网络 阅读:615 作者:fengyuzaitu 栏目:系统运维

1前言

轮廓线就是图形的边界,任何封闭的顶点源跳过agg::conv_stroke阶段,将会描绘实心的图形,填充的颜色和边界保持一致。如果不封闭的顶点源一旦跳过agg::conv_stroke就什么也不绘制。agg::conv_stroke就是用来描绘图形边界的。

agg::conv_contour对比可知,agg::conv_contour是扩展图形的轮廓线,通俗一点就是拓展图形的边界,对图形的边界进行放缩(但是和agg::trans_affine不同,这是中心位置不变的缩放)。

摘自: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

官方例子

      执行examples/conv_stroke例程,提供如下的控制:

1)线段端点的切换

2)线段之间的连接方式

3)线段宽度

4miter limit工件的链接切口

轮廓线属性的设置

1)线段端点的形状

  enum line_cap_e

    {

      butt_cap,//按钮形状,实际和方形形状并无二致

      square_cap,//设置之后,长度比butt_cap长一些

      round_cap//半圆形状

};

设置函数:voidline_cap(line_cap_e lc)

2)线段的宽度

设置函数:voidwidth(double w)

3)介绍stroke的默认参数

当然我们可以不调用line_cap,也可以不调用width,因为stroke有默认的构造器,指定了默认的参数如下:

      m_width(0.5),

      m_width_abs(0.5),

      m_width_eps(0.5/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)

4agg::conv_stroke的线段样式

采用的是实线的渲染方式,是否我们可以通过替换她,描述虚线:agg::conv_dash

结果发现:什么也没有渲染出来!!agg::conv_dash会单独描述!!

例子

ras.reset();

  agg::path_storage ps1;

  ps1.move_to(200,200);

  ps1.line_to(300,300);

 

  agg::line_cap_e cap = agg::round_cap;//设置线段端点的形状

  agg::conv_stroke<agg::path_storage> stroke(ps1);//线段的样式

  stroke.line_cap(cap);

  stroke.width(50);//设置线段的宽度

  ras.add_path(stroke);

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

5 shorten函数的用法

1说明

         conv_strokeconv_dash对象中添加了缩短路径的方法。对于渲染带粗线的箭头非常有效。同时也有一个agg_conv_shorten_path转换器对象,可以单独使用。

2示例

m_slider1(80, 250,    600-10,276,    !flip_y)

                 add_ctrl(m_slider1);

                 m_slider1.range(0,300);

 

                 m_slider1.num_steps(30);

                 m_slider1.value(1);

 

       //一种坍塌式的减少过程

       agg::ellipse ell1(230,230,140,150);

       agg::conv_stroke<agg::ellipse> stroke1(ell1);

       stroke1.width(30);

       stroke1.shorten(m_slider1.value());

       ras.add_path(stroke1);

 

 

       //类似于缩短

       agg::path_storage ps;

       ps.move_to(20,30);

       ps.line_to(440,30);

       agg::conv_stroke<agg::path_storage> stroke2(ps);

       stroke2.width(30);

       stroke2.shorten(m_slider1.value());

       ras.add_path(stroke2);


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI