ios - Fill front and back sides of the path with different color in context of iOS CoreGraphics
问题描述
Provided we have a path that is "twisted" meaning part of it is oriented front side and part is back side. For example:
The path is build by lines between points A, B, C and D. From the docs I know there is CGPathFillRule.winding
mode that is close to what I need:
This rule plots a ray from the interior of the region to be evaluated toward the bounds of the drawing, and sums the closed path elements that the ray crosses: +1 for counterclockwise paths, -1 for clockwise. If the sum is zero, the region is left empty; if the sum is nonzero, the region is filled.
But it fills the area if the described condition "is nonzero", and I need to separate it: "if greater than zero" and "if less than zero".
Is there a way to draw only front side at first then switch to other color and draw the back side. I know that this approach is possible and widely used in OpenGL graphics where polygons have front and back faces depending on CW or CCW points order.
解决方案
推荐阅读
- c# - 如何使用 ContentPresenter 的内容创建一个按钮的模板,该内容具有可以通过按钮的 VisualState 更改的不同前景
- xslt - 如何在 xslt 中对 value-of 进行排序?
- git - GIT 将更改从 Master 推送到所有其他分支 Devops /Visual Studio
- php - Laravel 模型继承:如何从父级实例化正确类型的模型
- excel - 从 excel 中的谷歌搜索返回一个数字
- java - 在Java中处理criteriaBuilder的“in”子句中的空列表
- git - 如何推送审核?
- python - 关于从文件中读取数据和将数据写入文件
- docker - 如何创建自定义 Docker 映像并将其用作 GitLab CI/CD 服务?
- gremlin - 尝试使用`with`在gremlin查询上设置唯一请求ID时的空指针