QPainterPath绘图路径

本文引用http://blog.chinaunix.net/uid-24219701-id-4044473.html

绘图路径(painter path)由基本图元(矩形,椭圆,直线,曲线)组成,绘图路径可以是闭合的路径,如矩形和圆,或者是非闭合的路径,如直线和曲线。

绘图路径在Qt中使用QPainterPth类表示,它提供了绘图操作的容器,可以使图形能够复用。绘图路径可以进行填充,显示轮廓和裁剪。要生成可填充的轮廓的绘图路径,可以使用QPainterPathStroker类.

使用QPainterPath的优点是复杂的图形只需创建一次,就可以多次使用。QPainterPath对象可以时只有起点的空路径,或者从其他QPainterPath对象复制,创建了QPainterPath对象后,可以使用lineTo(),cubicTo(),quadTo() 函数将直线和曲线添加到路径中来,直线和曲线从currentPosition()开始绘制。currentPosition()总是返回最后的子路经绘制的终点。使用moveTo()函数可以在不增加路径的情况下移动currentPositon(),它关闭了一个子路经,开始一个新的子路经。closeSubPath()也可以关闭当前路径,并从currentPosition()连接一条直线到绘图路径的起点。

QPainter可以使用addEllipse(),addPath(),addRect(),addRegion(),addText()将Qt的一些基本图元加入绘图路径。一个已有的绘图路径可以通过connectPath()函数加入到另一个绘图路径中。如下代码绘制了一个箭头:

QPainterPath path;
path.moveTo(10,100);
path.cubicTo(10,100,100,10,200,70);
path.lineTo(200,50);
path.lineTo(220,80);
path.lineTo(200,110);
path.lineTo(200,90);
path.cuticTo(200,100,100,50,50,100);
QPainter painter(this);
QPen pen(QColor(255,0,0),2);
painter.setPen(pen);
painter.drawPath(path);

Qt提供了两种填充方式,Qt::OddEventFill和Qt::WindingFill.Qt::OddEvent时默认的填充规则,它指定QPainterPath使用奇偶填充规则,该规则判断一个点是否在论经图形内的方法是从该店画一条水平线到路径外,计算水平线和路径的交点数,如果交点时奇数个则说明该点在路径图形内。QPainterPath还有一些函数可以获取路径信息,如elementAt()函数可以取出指定的子路经元素,
isEmpty() 函数判断当前路径是否为空。controlPointRect()函数返回路径中所有的点和控制点的矩形,该函数运行速度比返回精确包容框 boundingRect()函数快得多。contains()函数判断一个点或一个矩形是否在路径内。intersects()判断指定的矩形与路径是 否相交.QPainterPath可以将矩形图形转换为其他图形,如使用toFillPolygon(), toFillPolygon(),toSubpathPOlygons()函数将路径转化为多边形。

QPainterPath还可以使用文字作为路径,下面的代码演示了文字路径,并使用线性渐变填充。

QLinearGradient linearGrad(QPointF(200,0),QPointF(1000,0));
linearGrad.setColorAt(0,Qt::black);
linearGrad.setColorAt(1,Qt::white);
QFont font("隶书",80);
font.setBold(true);
QPainterPath textPath();
textPath.addText(200,300,font,tr("电子工业出版社"));
painter.setBrush(linearGrad);
painter.drawPath(textPath);

 

Whether you are making a road, a ramp, a path or a river, Path Painter makes terrain based path creation and texturing a breeze! Path Painter allows you to: - Create paths; - Create ramps; - Create roads; - Create plateaus for secret forts; - Create lake and river beds; - Change terrain elevation along path; - Re-texture along path embankments; - Clear grass and trees along path; - Use various algorithms for natural clearing; - Standard Unity terrain compatible! Path Painter is a collaboration between Frank Slater and Procedural Worlds, and we are very excited to be working together. Note: This asset is provided in DLL form rather than with source code. If you would also like to purchase the source then please contact us directly. Our Product Suite: Gaia - A world generation system for creating, texturing, planting and populating scenes from low poly mobile, VR and through to high end desktop. GeNa 2 - A sophisticated localised level design tool that augments Gaia’s broad brush strokes, by working intuitively to give fine grained control. Path Painter - A powerful path and easy to use road, path and river bed painting system for Unity 3D. CTS - Nominated by Unity of as one of the best assets in 2017, a PBR terrain shading system that significantly improves terrain look, performance and usability. SECTR - A suite of performance-enhancing tools that enable open world streaming, massive mobile games and includes the latest techniques in audio occlusion and propagation. Pegasus - A system that can drive anything along a path. Great for cut-scenes, and even has an ambient ai that supports formations, animation and local avoidance for your npc's and animals! Want To Know More ? Unity Forum Path Painter Tutorials Have A Chat Ticketed Support NOTE: Path Painter does not create meshes, so if you are making rivers you would typically also use another tool as well to shade the river component.
智慧旅游解决方案利用云计算、物联网和移动互联网技术,通过便携终端设备,实现对旅游资源、经济、活动和旅游者信息的智能感知和发布。这种技术的应用旨在提升游客在旅游各个环节的体验,使他们能够轻松获取信息、规划行程、预订票务和安排食宿。智慧旅游平台为旅游管理部门、企业和游客提供服务,包括政策发布、行政管理、景区安全、游客流量统计分析、投诉反馈等。此外,平台还提供广告促销、库存信息、景点介绍、电子门票、社交互动等功能。 智慧旅游的建设规划得到了国家政策的支持,如《国家中长期科技发展规划纲要》和国务院的《关于加快发展旅游业的意见》,这些政策强调了旅游信息服务平台的建设和信息化服务的重要性。随着技术的成熟和政策环境的优化,智慧旅游的时机已经到来。 智慧旅游平台采用SaaS、PaaS和IaaS等云服务模式,提供简化的软件开发、测试和部署环境,实现资源的按需配置和快速部署。这些服务模式支持旅游企业、消费者和管理部门开发高性能、高可扩展的应用服务。平台还整合了旅游信息资源,提供了丰富的旅游产品创意平台和统一的旅游综合信息库。 智慧旅游融合应用面向游客和景区景点主管机构,提供无线城市门户、智能导游、智能门票及优惠券、景区综合安防、车辆及停车场管理等服务。这些应用通过物联网和云计算技术,实现了旅游服务的智能化、个性化和协同化,提高了旅游服务的自由度和信息共享的动态性。 智慧旅游的发展标志着旅游信息化建设的智能化和应用多样化趋势,多种技术和应用交叉渗透至旅游行业的各个方面,预示着全面的智慧旅游时代已经到来。智慧旅游不仅提升了游客的旅游体验,也为旅游管理和服务提供了高效的技术支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值