How are filled paths rendered?

时光毁灭记忆、已成空白 提交于 2019-11-28 08:40:08

问题


What are the standard algorithms used in vector graphics for rendering filled paths?

I'm not only interested in the process of rendering strokes, I also would like to know how the shapes are filled - how it is determined if given point is inside or outside the path (I believe even specifying the rules of what inside and outside mean is not a straightforward thing).


回答1:


  1. find outline (perimeter as polygon)

    this I think you already have

  2. triangulate (or cut to convex polygons)

    there are many approaches like:

    • clip ear
    • Delaunay

    see Wiki Polygon triangulation

  3. fill convex triangles/polygons

    this is easy either use

    • gfx lib like OpenGL,DirectX,...
    • api like GDI
    • rasterize on your own like in how to rasterize convex polygons
  4. style

    This stuff is more complicated then it sound like at the first hear. For:

    1. outline width pen,stroke

      convert outline to polygon by shifting it out or in. For more info see this

    2. outline style pen,stroke

      full,dash dot,dot dot,... for more info see this

    3. filling style brush

      like hatching which is most complicated from all. It involves heavy polygon tweaking similar but much harder then outline width. Some styles are simpler some extremly complicated for example for equidistant line fill simple loop + intersection + inside polygon test will do. To test polygon inside you can use hit test



来源:https://stackoverflow.com/questions/25048711/how-are-filled-paths-rendered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!