1cb93a386Sopenharmony_ci--- 2cb93a386Sopenharmony_cititle: 'SkPath Overview' 3cb93a386Sopenharmony_cilinkTitle: 'SkPath Overview' 4cb93a386Sopenharmony_ci 5cb93a386Sopenharmony_ciweight: 270 6cb93a386Sopenharmony_ci--- 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> contains 9cb93a386Sopenharmony_ci<a href='undocumented#Line'>Lines</a> and 10cb93a386Sopenharmony_ci<a href='undocumented#Curve'>Curves</a> which can be stroked or filled. 11cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a> is composed of a series of connected 12cb93a386Sopenharmony_ci<a href='undocumented#Line'>Lines</a> and 13cb93a386Sopenharmony_ci<a href='undocumented#Curve'>Curves</a>. 14cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> may contain zero, one, 15cb93a386Sopenharmony_cior more <a href='#Contour'>Contours</a>. Each 16cb93a386Sopenharmony_ci<a href='undocumented#Line'>Line</a> and <a href='undocumented#Curve'>Curve</a> 17cb93a386Sopenharmony_ciare described by Verb, 18cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Points</a>, and optional 19cb93a386Sopenharmony_ci<a href='#Path_Conic_Weight'>Path_Conic_Weight</a>. 20cb93a386Sopenharmony_ci 21cb93a386Sopenharmony_ciEach pair of connected <a href='undocumented#Line'>Lines</a> and 22cb93a386Sopenharmony_ci<a href='undocumented#Curve'>Curves</a> share common 23cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Point</a>; for instance, 24cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> containing two 25cb93a386Sopenharmony_ciconnected <a href='undocumented#Line'>Lines</a> are described the 26cb93a386Sopenharmony_ci<a href='#Path_Verb'>Path_Verb</a> sequence: 27cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kMove_Verb'>kMove_Verb</a>, 28cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kLine_Verb'>kLine_Verb</a>, 29cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kLine_Verb'>kLine_Verb</a>; 30cb93a386Sopenharmony_ciand a <a href='https://api.skia.org/structSkPoint.html'>Point</a> sequence with 31cb93a386Sopenharmony_cithree entries, sharing the middle entry as the end of the first 32cb93a386Sopenharmony_ci<a href='undocumented#Line'>Line</a> and the start of the second 33cb93a386Sopenharmony_ci<a href='undocumented#Line'>Line</a>. 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> components 36cb93a386Sopenharmony_ci<a href='undocumented#Arc'>Arc</a>, 37cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html#af037025a1adad16072abbbcd83b621f2'>Rect</a>, 38cb93a386Sopenharmony_ci<a href='#RRect'>Round_Rect</a>, <a href='undocumented#Circle'>Circle</a>, and 39cb93a386Sopenharmony_ci<a href='undocumented#Oval'>Oval</a> are composed of 40cb93a386Sopenharmony_ci<a href='undocumented#Line'>Lines</a> and 41cb93a386Sopenharmony_ci<a href='undocumented#Curve'>Curves</a> with as many 42cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html#ac36f638ac96f3428626e993eacf84ff0'>Verbs</a> 43cb93a386Sopenharmony_ciand <a href='https://api.skia.org/structSkPoint.html'>Points</a> required for an 44cb93a386Sopenharmony_ciexact description. Once added to 45cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a>, these components may 46cb93a386Sopenharmony_cilose their identity; although 47cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> can be inspected to 48cb93a386Sopenharmony_cidetermine if it describes a single 49cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html#af037025a1adad16072abbbcd83b621f2'>Rect</a>, 50cb93a386Sopenharmony_ci<a href='undocumented#Oval'>Oval</a>, <a href='#RRect'>Round_Rect</a>, and so 51cb93a386Sopenharmony_cion. 52cb93a386Sopenharmony_ci 53cb93a386Sopenharmony_ci### Example 54cb93a386Sopenharmony_ci 55cb93a386Sopenharmony_ci<div><fiddle-embed name="93887af0c1dac49521972698cf04069c"><div><a href='https://api.skia.org/classSkPath.html'>Path</a> contains three <a href='#Contour'>Contours</a>: <a href='undocumented#Line'>Line</a>, <a href='undocumented#Circle'>Circle</a>, and <a href='https://api.skia.org/classSkPath.html#ad75d5a934476ac6543d6d7ddd8dbb90a'>Quad</a>. <a href='undocumented#Line'>Line</a> is stroked but 56cb93a386Sopenharmony_cinot filled. <a href='undocumented#Circle'>Circle</a> is stroked and filled; <a href='undocumented#Circle'>Circle</a> stroke forms a loop. <a href='https://api.skia.org/classSkPath.html#ad75d5a934476ac6543d6d7ddd8dbb90a'>Quad</a> 57cb93a386Sopenharmony_ciis stroked and filled, but since it is not closed, <a href='https://api.skia.org/classSkPath.html#ad75d5a934476ac6543d6d7ddd8dbb90a'>Quad</a> does not stroke a loop. 58cb93a386Sopenharmony_ci</div></fiddle-embed></div> 59cb93a386Sopenharmony_ci 60cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> contains a 61cb93a386Sopenharmony_ci<a href='#Path_Fill_Type'>Path_Fill_Type</a> which determines whether 62cb93a386Sopenharmony_cioverlapping <a href='#Contour'>Contours</a> form fills or holes. 63cb93a386Sopenharmony_ci<a href='#Path_Fill_Type'>Path_Fill_Type</a> also determines whether area inside 64cb93a386Sopenharmony_cior outside <a href='undocumented#Line'>Lines</a> and 65cb93a386Sopenharmony_ci<a href='undocumented#Curve'>Curves</a> is filled. 66cb93a386Sopenharmony_ci 67cb93a386Sopenharmony_ci### Example 68cb93a386Sopenharmony_ci 69cb93a386Sopenharmony_ci<div><fiddle-embed name="36a995442c081ee779ecab2962d36e69"><div><a href='https://api.skia.org/classSkPath.html'>Path</a> is drawn filled, then stroked, then stroked and filled. 70cb93a386Sopenharmony_ci</div></fiddle-embed></div> 71cb93a386Sopenharmony_ci 72cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> contents are never 73cb93a386Sopenharmony_cishared. Copying <a href='https://api.skia.org/classSkPath.html'>Path</a> by 74cb93a386Sopenharmony_civalue effectively creates a new 75cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> independent of the 76cb93a386Sopenharmony_cioriginal. Internally, the copy does not duplicate its contents until it is 77cb93a386Sopenharmony_ciedited, to reduce memory use and improve performance. 78cb93a386Sopenharmony_ci 79cb93a386Sopenharmony_ci<a name='Contour'></a> 80cb93a386Sopenharmony_ci 81cb93a386Sopenharmony_ci--- 82cb93a386Sopenharmony_ci 83cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a> contains one or more 84cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html#ac36f638ac96f3428626e993eacf84ff0'>Verbs</a>, 85cb93a386Sopenharmony_ciand as many <a href='https://api.skia.org/structSkPoint.html'>Points</a> as are 86cb93a386Sopenharmony_cirequired to satisfy <a href='#Path_Verb_Array'>Path_Verb_Array</a>. First 87cb93a386Sopenharmony_ci<a href='#Path_Verb'>Path_Verb</a> in 88cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>Path</a> is always 89cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kMove_Verb'>kMove_Verb</a>; 90cb93a386Sopenharmony_cieach 91cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kMove_Verb'>kMove_Verb</a> 92cb93a386Sopenharmony_cithat follows starts a new <a href='#Contour'>Contour</a>. 93cb93a386Sopenharmony_ci 94cb93a386Sopenharmony_ci### Example 95cb93a386Sopenharmony_ci 96cb93a386Sopenharmony_ci<div><fiddle-embed name="0374f2dcd7effeb1dd435205a6c2de6f"><div>Each <a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_moveTo'>moveTo</a> starts a new <a href='#Contour'>Contour</a>, and content after <a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_close'>close()</a> 97cb93a386Sopenharmony_cialso starts a new <a href='#Contour'>Contour</a>. Since <a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_conicTo'>conicTo</a> is not preceded by 98cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_moveTo'>moveTo</a>, the first <a href='https://api.skia.org/structSkPoint.html'>Point</a> of the third <a href='#Contour'>Contour</a> starts at the last <a href='https://api.skia.org/structSkPoint.html'>Point</a> 99cb93a386Sopenharmony_ciof the second <a href='#Contour'>Contour</a>. 100cb93a386Sopenharmony_ci</div></fiddle-embed></div> 101cb93a386Sopenharmony_ci 102cb93a386Sopenharmony_ciIf final <a href='#Path_Verb'>Path_Verb</a> in <a href='#Contour'>Contour</a> is 103cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kClose_Verb'>kClose_Verb</a>, 104cb93a386Sopenharmony_ci<a href='undocumented#Line'>Line</a> connects 105cb93a386Sopenharmony_ci<a href='#Path_Last_Point'>Path_Last_Point</a> in <a href='#Contour'>Contour</a> 106cb93a386Sopenharmony_ciwith first <a href='https://api.skia.org/structSkPoint.html'>Point</a>. A closed 107cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a>, stroked, draws 108cb93a386Sopenharmony_ci<a href='#Paint_Stroke_Join'>Paint_Stroke_Join</a> at 109cb93a386Sopenharmony_ci<a href='#Path_Last_Point'>Path_Last_Point</a> and first 110cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Point</a>. Without 111cb93a386Sopenharmony_ci<a href='https://api.skia.org/classSkPath.html'>SkPath</a>::<a href='#SkPath_kClose_Verb'>kClose_Verb</a> 112cb93a386Sopenharmony_cias final Verb, <a href='#Path_Last_Point'>Path_Last_Point</a> and first 113cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Point</a> are not connected; 114cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a> remains open. An open 115cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a>, stroked, draws 116cb93a386Sopenharmony_ci<a href='#Paint_Stroke_Cap'>Paint_Stroke_Cap</a> at 117cb93a386Sopenharmony_ci<a href='#Path_Last_Point'>Path_Last_Point</a> and first 118cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Point</a>. 119cb93a386Sopenharmony_ci 120cb93a386Sopenharmony_ci### Example 121cb93a386Sopenharmony_ci 122cb93a386Sopenharmony_ci<div><fiddle-embed name="7a1f39b12d2cd8b7f5b1190879259cb2"><div><a href='https://api.skia.org/classSkPath.html'>Path</a> is drawn stroked, with an open <a href='#Contour'>Contour</a> and a closed <a href='#Contour'>Contour</a>. 123cb93a386Sopenharmony_ci</div></fiddle-embed></div> 124cb93a386Sopenharmony_ci 125cb93a386Sopenharmony_ci<a name='Contour_Zero_Length'></a> 126cb93a386Sopenharmony_ci 127cb93a386Sopenharmony_ci--- 128cb93a386Sopenharmony_ci 129cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a> length is distance traveled from first 130cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Point</a> to 131cb93a386Sopenharmony_ci<a href='#Path_Last_Point'>Path_Last_Point</a>, plus, if 132cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a> is closed, distance from 133cb93a386Sopenharmony_ci<a href='#Path_Last_Point'>Path_Last_Point</a> to first 134cb93a386Sopenharmony_ci<a href='https://api.skia.org/structSkPoint.html'>Point</a>. Even if 135cb93a386Sopenharmony_ci<a href='#Contour'>Contour</a> length is zero, stroked 136cb93a386Sopenharmony_ci<a href='undocumented#Line'>Lines</a> are drawn if 137cb93a386Sopenharmony_ci<a href='#Paint_Stroke_Cap'>Paint_Stroke_Cap</a> makes them visible. 138cb93a386Sopenharmony_ci 139cb93a386Sopenharmony_ci### Example 140cb93a386Sopenharmony_ci 141cb93a386Sopenharmony_ci<div><fiddle-embed name="62848df605af6258653d9e16b27d8f7f"></fiddle-embed></div> 142