博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Direct2D 几何计算和几何变幻
阅读量:2502 次
发布时间:2019-05-11

本文共 1439 字,大约阅读时间需要 4 分钟。

D2D不仅可以绘制,还可以对多个几何图形对象进行空间运算。这功能应该在GIS界比较吃香。

这些计算包括:

  • 合并几何对象,可以设置求交还是求并,
  • 边界,加宽边界,查询边界。
  • 几何对象填充的区域是否包含指定点t
  • 笔画是否包含点,
  • 几何对象与指定几何对象之间的交集
  • 创建仅包含直线和(可选)三次方贝塞尔曲线的简化版本的几何对象
  • 网格化,创建一组顺时针缠绕的三角形,
  • 计算几何对象的轮廓(移除交集),
  • 几何对象上指定距离处的点和正切矢量
  • 计算几何对象的面积,
  • 计算几何对象的长度,
写一个合并的例子:对两个圆求并集,并将绘制结果存存储到一个path中,在组成path的关节的过程中需要用sink对象。最后绘制path
pRenderTarget->BeginDraw();	//clear screen	pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White));	//define 2 ellipse	const D2D1_ELLIPSE ellipse1 = Ellipse(Point2F(200,300),150,150);	const D2D1_ELLIPSE ellipse2 = Ellipse(Point2F(200,250),100,200);	//define ellipse geometry for compute	ID2D1EllipseGeometry* pEllipse1 = NULL;	ID2D1EllipseGeometry* pEllipse2 = NULL;	//define path for render the combine result	ID2D1PathGeometry* pPathGeo = NULL;	//define a path container	ID2D1GeometrySink* pGeometrySink = NULL;	//initialize the ellipses and path.	hr = pD2DFactory->CreateEllipseGeometry(ellipse1, &pEllipse1);	hr = pD2DFactory->CreateEllipseGeometry(ellipse2, &pEllipse2);	hr = pD2DFactory->CreatePathGeometry(&pPathGeo);	//begin add path	pPathGeo->Open(&pGeometrySink);	//combine the 2 ellipse and the result go into the sink	pEllipse1->CombineWithGeometry(pEllipse2, D2D1_COMBINE_MODE_UNION, NULL, NULL, pGeometrySink); 	//end add path	pGeometrySink->Close();	//draw the path	pRenderTarget->DrawGeometry(pPathGeo, pBlackBrush);	pRenderTarget->EndDraw();
除此之外,D2D还支持对几何对象的变幻,包括:
  • 旋转,
  • 缩放,
  • 平移,
可以用pRenderTarget的SetTransform来设置。

转载地址:http://qmlgb.baihongyu.com/

你可能感兴趣的文章
Nginx配置文件nginx.conf中文详解(总结)
查看>>
Mysql出现Table 'performance_schema.session_status' doesn't exist
查看>>
MySQL innert join、left join、right join等理解
查看>>
sdc时序约束
查看>>
NoC片上网络
查看>>
开源SoC整理
查看>>
【2020-3-21】Mac安装Homebrew慢,解决办法
查看>>
influxdb 命令行输出时间为 yyyy-MM-dd HH:mm:ss(年月日时分秒)的方法
查看>>
已知子网掩码,确定ip地址范围
查看>>
判断时间或者数字是否连续
查看>>
docker-daemon.json各配置详解
查看>>
Docker(一)使用阿里云容器镜像服务
查看>>
Docker(三) 构建镜像
查看>>
FFmpeg 是如何实现多态的?
查看>>
FFmpeg 新旧版本编码 API 的区别
查看>>
RecyclerView 源码深入解析——绘制流程、缓存机制、动画等
查看>>
Android 面试题整理总结(一)Java 基础
查看>>
Android 面试题整理总结(二)Java 集合
查看>>
学习笔记_vnpy实战培训day02
查看>>
学习笔记_vnpy实战培训day03
查看>>