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

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

转载于:https://blog.51cto.com/fengyuzaitu/1961908

AGG第二十课 agg::ellipse 方法approximation_scale()相关推荐

  1. 第二十课 Django Admin后台管理

    第二十课 Admin后台管理 1. admin创建用户 创建管理员账号: python manage.py createsuperuser# 按提示输入用户名.邮箱.密码 2. 注册模型 如果只是在a ...

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

    1 提供如下的代码结构渲染字体 agg::conv_transform<...> conv (path,matrix); agg::conv_curve<...> curve ...

  3. AGG第十一课 agg::ellipse 渲染椭圆和多边形

    8.1引言 圆是椭圆的一种,只不过是长短轴半径相等而已.在AGG中,必须给定椭圆的长短半轴的半径,才能够绘制椭圆.将横坐标半径称为rx,纵坐标半径称为ry.并且可以指定绘制的方向,是顺时针,还是逆时针 ...

  4. 进化论的再思《基督教与科学》第二十课

    黄牧师 一.介绍四位学者 潘柏韬博士.弗兰斯‧科林博士.赛门康威‧莫里斯博士(不要与亨利莫里斯混淆,亨利博士是已故土木工程师.赛门康威•莫里斯博士是现任剑桥大学古生物学系主任,是世界首席的寒武纪大爆炸 ...

  5. Python界面编程第二十课:Pyside2 (Qt For Python)文本编辑框QTextEdit

    先看完整代码: from PySide2.QtWidgets import QApplication, QMainWindow, QAction, QTextEdit import sys from ...

  6. 第二十课 【ERC1155实践】欧阳询书法复制品从确权设计到买卖测试

    1,摘要 [本文目标] 通过本文学习,了解以太坊ERC1155标准规范和ERC1155Mintable可增发智能合约函数功能,并通过一个有趣的故事完成功能测试. [前置条件] 1)对以太坊ERC20( ...

  7. C语言第二十课:实用调试技巧

    目录 前言: 一.Bug: 二.调试: 1.调试是什么: 2.调试的基本步骤: 3. Debug 与 Release : 三.在Windows环境下进行调试: 1.调试环境的准备: 2.调试的快捷键: ...

  8. 大三小学期进阶课程第二十课:Understand More on the MP Difficulty

    第20课.Understand More on the MP Difficulty EM是一个在已知部分相关变量的情况下,估计未知变量的迭代技术,EM的算法流程如下: (1)初始化分布参数: (2)重 ...

  9. 第二十课.DeepGraphLibrary(一)

    目录 DGL安装 图 图与图的创建 从外部源创建图 异构图 在GPU上运行DGL 消息传递范式 内置函数和消息传递API 消息函数 聚合函数 更新函数 单独调用Edge-wise更新边特征 在子图上进 ...

最新文章

  1. 编译系统总结篇-Android10.0编译系统(十一)
  2. 架构师必备技能:Maven Archetype生成项目模板
  3. 一键安装MySQL5.6.43脚本
  4. VC++动态链接库(DLL)编程深入浅出(zz)
  5. facebook工具xhprof的安装与使用-分析php执行性能
  6. Modularity(模块化-CommonJS规范)
  7. Python开发利器PyCharm 2.7附注册码
  8. 电脑控制iphone_用iPhone别再傻傻地直接盯屏幕,按下这个按钮,屏幕放大10倍不止...
  9. TensorFlow 三岁了,你想对它说点什么?
  10. 零基础如何用 15 行 Python 代码搞定网易云热门歌单?
  11. python生成验证码_Python快速生成验证码
  12. [转载]资深程序员点评当前某些对Lotus Domino 的不实评论
  13. 数据结构上机实践第三周项目3- 求集合并集
  14. 华为STP相关功能配置
  15. python 视频保存_通过Python保存央视频某主题的视频地址
  16. CTOD安悦系统目录转移软件
  17. 现代控制工程(三)状态方程的解
  18. [剑指Offer]:翻转单词顺序
  19. 小学-综合素质【3】
  20. ensp 防火墙 pat 映射

热门文章

  1. 安装Adventure Works 2008 R2演示数据库
  2. WCF duplex service + silverlight 聊天代码
  3. 计算机的存储系统,全方面、最详细
  4. cin.get()和cin.getline()之间的区别
  5. Javascript事件模型系列(二)事件的捕获-冒泡机制及事件委托机制
  6. 黑马程序员-面向对象-06天-3(static-静态代码块)
  7. 一个普通ERROR 1135 (HY000)错误引发的血案:
  8. PHP——获取上传文件的后缀名
  9. Hibernate 之父:是时候升级到 Java EE 6 了!
  10. anaconda能跑c语言哪,anaconda环境下实现SiamCAR