AGG第二十课 agg::ellipse 方法approximation_scale()

献给:任何一种方案都是一种折中的选择,任何一种替代方案都可能会实现同样的效果。而这完全取决于你是如何思考定位的。请教是学,自学是学,只不过可以站在巨人的肩膀上,你可以看的更加清楚或许走的更远。

摘自:http://franko.github.io/agg-intro/vertex-source.html

In the previous section we have seen agg::path_storage object. While this object is very flexible and can be used to describe all kind of geometric shapes there are a few other vertex source primitive types. Actually there are not so many of them and we will just discuss the agg::ellipse object because it will be also useful to illustrate some important idea.

The agg::ellipse does not share anything with a agg::path_storage in term of C++ class hierarchy, all the they have in common is that they implement the basic methods of a vertex source. You may wonder why the ellipse object can be useful if you can describe it with a agg::path_storage. The answer is that this latter needs to store a fixed number of vertices that approximate the ellipse for all the possible resolution of the image. The problem is that if you draw a small circle a few vertices can be enough but if the circle is big you are going to need a lot of vertices to have a decent approximation. We will see that with an agg::ellipse object the number of points will be adapted on the fly, you just need to use the approximation_scale()method. Actually the agg::ellipse does not store all the coordinates of the vertices but generetes them on the fly when needed using the mathematical equations. As a side effect you will have also a benefit in term of memory usage because an ellipse object will use a very small amount of memory indipendently of the approximation level that you may request.

At this point we need to explain the approximation_scale() method. approximation_scale() we need to go back to the coordinates specifications. The coordinates are actually given as double precision floating point number and they may or may not map directly to pixel coordinates. For example we can map some logical coordinates ranging from 0 to 1 to an huge viewport of size 1280x1280. The problem at this point is that an agg::ellipse object does not know the mapping between logical coordinates and viewport coordinates. So the idea is that to let agg::ellipse adjust correctly the level of approximation you should call the method approximation_scale() and pass as an argument the ratio between the viewport coordinates and the logical coordinates. So in the example of the viewport of size 1280x1280 we would need to use approximation_scale() with an scale argument of 1280.

We will see later that the approximation_scale() is also important with some kind of transformation like Bezier curves that are supposed to generate smooth curves based on a few vertices and some mathematical equations.

时间: 2024-10-09 04:04:46

AGG第二十课 agg::ellipse 方法approximation_scale()的相关文章

AGG第二十一课 agg::conv_contour 扩展轮廓线

1前言 轮廓线就是图形的边界,任何封闭的顶点源跳过agg::conv_stroke阶段,将会描绘实心的图形,填充的颜色和边界保持一致.如果不封闭的顶点源一旦跳过agg::conv_stroke就什么也不绘制.agg::conv_stroke就是用来描绘图形边界的. 和agg::trans_affine对比可知,agg::conv_contour是扩展图形的轮廓线,通俗一点就是拓展图形的边界,对图形的边界进行放缩(但是和agg::trans_affine仿射变换不同,这是中心位置不变的缩放). 2

Kali Linux Web 渗透测试— 第二十课-metasploit.meterpreter

Kali Linux Web 渗透测试— 第二十课-metasploit.meterpreter 原文链接:http://www.xuanhun521.com/Blog/7fc11b7a-b6cb-401d-8641-5202c9b7864a 文/玄魂 目录 Kali Linux Web 渗透测试— 第二十课-metasploit.meterpreter........................ 1 Meterpreter..................................

ali Linux Web 渗透测试视频教—第二十课-利用kali linux光盘或者usb启动盘破解windows密码

Kali Linux Web 渗透测试视频教—第二十课-利用kali linux光盘或者usb启动盘破解windows密码 文/玄魂 目录 Kali Linux Web 渗透测试视频教—第二十课-利用kali linux光盘或者usb启动盘破解windows密码.......................................................................................................................

AGG第二十八课 rasterizer的填充规则

AGG提供了很多额外的接口给SVG调用,因此很多的初学者像我,需要先学习SVG,然后了解接口的意义,才能够真正的掌握该接口,例如miter_join的含义. 1知识储备 字面上理解就是填充的规则,不就是图形的填充吗?哪有什么规则可言.对于单一的图形没有问题,如果是渲染圆环,两个环之间的区域填充颜色,该怎么办?这个时候就需要指定一种规则,一种填充的规则. AGG提供了两种算法来判断该点是否在填充区域内,如果该点在填充区域,然后填充该点.对于一个简单的无交叉的路径,是非常容易判断的.但是,对于一个复

AGG第二十二课 conv_contour函数auto_detect_orientation的字体应用

1 提供如下的代码结构渲染字体 agg::conv_transform<...> conv (path,matrix); agg::conv_curve<...> curve (conv); agg::conv_contour<...> contour(curve); curve.approximaltion_scale (scale); contour.auto_detect_orientation (true); contour.width (bold); 当bol

agg::ellipse 方法approximation_scale()

摘自:http://franko.github.io/agg-intro/vertex-source.html In the previous section we have seen agg::path_storage object. While this object is very flexible and can be used to describe all kind of geometric shapes there are a few other vertex source pri

AGG第二十六课 裁剪功能

AGG有四种类型的裁剪,分别工作在不同的层次 1. 基础渲染器Base Render 除非直接调用基础渲染器的绘制线段的方法,否则在一般情况下,都是在render_scanline的时候被调用,进行裁剪,这个时候已经进行了大量无用的工作.比如顶点源超出屏幕范围,在调用render_scanline函数之前,比如调用rasterizer对象的add_path函数,已经浪费大量的资源 2 光栅器rasterizer rasterizer主要应用于根据顶点源,生成线段的详细信息,这个时候调用裁剪,可以

JAVA学习第二十课(异常的应用和注意事项(三))

十.异常的应用 import java.util.Random; import javax.rmi.CORBA.Stub; /* *老师用电脑上课 *用面向对象思考问题 *问题设计两个对象 *老师,电脑 * *可能发生的问题: *电脑蓝屏.电脑冒烟 */ class Lan extends Exception//蓝屏 { Lan(String problem) { super(problem); } } class Fir extends Exception//冒烟 { Fir(String p

ParisGabriel:Python全栈工程师(0基础到精通)教程 第二十课(包、模块 的导入)

$ pip3 install tensorflow : 第三方模块 tensorflow 的安装 电脑必须有网 命令行自动下载安装dir(模块名): 查看模块所有属性 自定义模块导入 示例: 自定义模块的实现方法 def myfac(n): print('正在计算', n, '的阶乘') def mysum(n): print("正在计算1+2+3+...+%d的和" % n) name1 = "Audi" name2 = "TESLA" pri