CGPath.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. { CoreGraphics - CGPath.h
  2. Copyright (c) 2001-2011 Apple Inc.
  3. All rights reserved. }
  4. { Pascal Translation: Peter N Lewis, <[email protected]>, August 2005 }
  5. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  6. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  13. {$mode macpas}
  14. {$packenum 1}
  15. {$macro on}
  16. {$inline on}
  17. {$calling mwpascal}
  18. unit CGPath;
  19. interface
  20. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  21. {$setc GAP_INTERFACES_VERSION := $0308}
  22. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  23. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  24. {$endc}
  25. {$ifc defined CPUPOWERPC and defined CPUI386}
  26. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  27. {$endc}
  28. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  29. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  30. {$endc}
  31. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  32. {$setc __ppc__ := 1}
  33. {$elsec}
  34. {$setc __ppc__ := 0}
  35. {$endc}
  36. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  37. {$setc __ppc64__ := 1}
  38. {$elsec}
  39. {$setc __ppc64__ := 0}
  40. {$endc}
  41. {$ifc not defined __i386__ and defined CPUI386}
  42. {$setc __i386__ := 1}
  43. {$elsec}
  44. {$setc __i386__ := 0}
  45. {$endc}
  46. {$ifc not defined __x86_64__ and defined CPUX86_64}
  47. {$setc __x86_64__ := 1}
  48. {$elsec}
  49. {$setc __x86_64__ := 0}
  50. {$endc}
  51. {$ifc not defined __arm__ and defined CPUARM}
  52. {$setc __arm__ := 1}
  53. {$elsec}
  54. {$setc __arm__ := 0}
  55. {$endc}
  56. {$ifc defined cpu64}
  57. {$setc __LP64__ := 1}
  58. {$elsec}
  59. {$setc __LP64__ := 0}
  60. {$endc}
  61. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  62. {$error Conflicting definitions for __ppc__ and __i386__}
  63. {$endc}
  64. {$ifc defined __ppc__ and __ppc__}
  65. {$setc TARGET_CPU_PPC := TRUE}
  66. {$setc TARGET_CPU_PPC64 := FALSE}
  67. {$setc TARGET_CPU_X86 := FALSE}
  68. {$setc TARGET_CPU_X86_64 := FALSE}
  69. {$setc TARGET_CPU_ARM := FALSE}
  70. {$setc TARGET_OS_MAC := TRUE}
  71. {$setc TARGET_OS_IPHONE := FALSE}
  72. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  73. {$setc TARGET_OS_EMBEDDED := FALSE}
  74. {$elifc defined __ppc64__ and __ppc64__}
  75. {$setc TARGET_CPU_PPC := FALSE}
  76. {$setc TARGET_CPU_PPC64 := TRUE}
  77. {$setc TARGET_CPU_X86 := FALSE}
  78. {$setc TARGET_CPU_X86_64 := FALSE}
  79. {$setc TARGET_CPU_ARM := FALSE}
  80. {$setc TARGET_OS_MAC := TRUE}
  81. {$setc TARGET_OS_IPHONE := FALSE}
  82. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  83. {$setc TARGET_OS_EMBEDDED := FALSE}
  84. {$elifc defined __i386__ and __i386__}
  85. {$setc TARGET_CPU_PPC := FALSE}
  86. {$setc TARGET_CPU_PPC64 := FALSE}
  87. {$setc TARGET_CPU_X86 := TRUE}
  88. {$setc TARGET_CPU_X86_64 := FALSE}
  89. {$setc TARGET_CPU_ARM := FALSE}
  90. {$ifc defined(iphonesim)}
  91. {$setc TARGET_OS_MAC := FALSE}
  92. {$setc TARGET_OS_IPHONE := TRUE}
  93. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  94. {$elsec}
  95. {$setc TARGET_OS_MAC := TRUE}
  96. {$setc TARGET_OS_IPHONE := FALSE}
  97. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  98. {$endc}
  99. {$setc TARGET_OS_EMBEDDED := FALSE}
  100. {$elifc defined __x86_64__ and __x86_64__}
  101. {$setc TARGET_CPU_PPC := FALSE}
  102. {$setc TARGET_CPU_PPC64 := FALSE}
  103. {$setc TARGET_CPU_X86 := FALSE}
  104. {$setc TARGET_CPU_X86_64 := TRUE}
  105. {$setc TARGET_CPU_ARM := FALSE}
  106. {$setc TARGET_OS_MAC := TRUE}
  107. {$setc TARGET_OS_IPHONE := FALSE}
  108. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  109. {$setc TARGET_OS_EMBEDDED := FALSE}
  110. {$elifc defined __arm__ and __arm__}
  111. {$setc TARGET_CPU_PPC := FALSE}
  112. {$setc TARGET_CPU_PPC64 := FALSE}
  113. {$setc TARGET_CPU_X86 := FALSE}
  114. {$setc TARGET_CPU_X86_64 := FALSE}
  115. {$setc TARGET_CPU_ARM := TRUE}
  116. { will require compiler define when/if other Apple devices with ARM cpus ship }
  117. {$setc TARGET_OS_MAC := FALSE}
  118. {$setc TARGET_OS_IPHONE := TRUE}
  119. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  120. {$setc TARGET_OS_EMBEDDED := TRUE}
  121. {$elsec}
  122. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  123. {$endc}
  124. {$ifc defined __LP64__ and __LP64__ }
  125. {$setc TARGET_CPU_64 := TRUE}
  126. {$elsec}
  127. {$setc TARGET_CPU_64 := FALSE}
  128. {$endc}
  129. {$ifc defined FPC_BIG_ENDIAN}
  130. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  131. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  132. {$elifc defined FPC_LITTLE_ENDIAN}
  133. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  134. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  135. {$elsec}
  136. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  137. {$endc}
  138. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  139. {$setc CALL_NOT_IN_CARBON := FALSE}
  140. {$setc OLDROUTINENAMES := FALSE}
  141. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  142. {$setc OPAQUE_UPP_TYPES := TRUE}
  143. {$setc OTCARBONAPPLICATION := TRUE}
  144. {$setc OTKERNEL := FALSE}
  145. {$setc PM_USE_SESSION_APIS := TRUE}
  146. {$setc TARGET_API_MAC_CARBON := TRUE}
  147. {$setc TARGET_API_MAC_OS8 := FALSE}
  148. {$setc TARGET_API_MAC_OSX := TRUE}
  149. {$setc TARGET_CARBON := TRUE}
  150. {$setc TARGET_CPU_68K := FALSE}
  151. {$setc TARGET_CPU_MIPS := FALSE}
  152. {$setc TARGET_CPU_SPARC := FALSE}
  153. {$setc TARGET_OS_UNIX := FALSE}
  154. {$setc TARGET_OS_WIN32 := FALSE}
  155. {$setc TARGET_RT_MAC_68881 := FALSE}
  156. {$setc TARGET_RT_MAC_CFM := FALSE}
  157. {$setc TARGET_RT_MAC_MACHO := TRUE}
  158. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  159. {$setc TYPE_BOOL := FALSE}
  160. {$setc TYPE_EXTENDED := FALSE}
  161. {$setc TYPE_LONGLONG := TRUE}
  162. uses MacTypes,CGBase,CGAffineTransforms,CFBase,CGGeometry;
  163. {$endc} {not MACOSALLINCLUDE}
  164. {$ALIGN POWER}
  165. type
  166. CGMutablePathRef = ^OpaqueCGMutablePathRef; { an opaque type }
  167. OpaqueCGMutablePathRef = record end;
  168. type
  169. CGPathRef = ^OpaqueCGPathRef; { an opaque type }
  170. OpaqueCGPathRef = record end;
  171. { Line join styles. }
  172. type
  173. CGLineJoin = SInt32;
  174. const
  175. kCGLineJoinMiter = 0;
  176. kCGLineJoinRound = 1;
  177. kCGLineJoinBevel = 2;
  178. { Line cap styles. }
  179. type
  180. CGLineCap = SInt32;
  181. const
  182. kCGLineCapButt = 0;
  183. kCGLineCapRound = 1;
  184. kCGLineCapSquare = 2;
  185. { Return the CFTypeID for CGPathRefs. }
  186. function CGPathGetTypeID: CFTypeID; external name '_CGPathGetTypeID';
  187. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  188. { Create a mutable path. }
  189. function CGPathCreateMutable: CGMutablePathRef; external name '_CGPathCreateMutable';
  190. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  191. { Create a copy of `path'. }
  192. function CGPathCreateCopy( path: CGPathRef ): CGPathRef; external name '_CGPathCreateCopy';
  193. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  194. { Create a copy of `path' transformed by `transform'. }
  195. function CGPathCreateCopyByTransformingPath( path: CGPathRef; const (*var*) transform: CGAffineTransform ): CGPathRef; external name '_CGPathCreateCopyByTransformingPath';
  196. (* CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) *)
  197. { Create a mutable copy of `path'. }
  198. function CGPathCreateMutableCopy( path: CGPathRef ): CGMutablePathRef; external name '_CGPathCreateMutableCopy';
  199. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  200. { Create a mutable copy of `path' transformed by `transform'. }
  201. function CGPathCreateMutableCopyByTransformingPath( path: CGPathRef; const (*var*) transform: CGAffineTransform ): CGMutablePathRef; external name '_CGPathCreateMutableCopyByTransformingPath';
  202. (* CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) *)
  203. { Return a path representing a rectangle bounded by `rect'. The rectangle
  204. forms a complete subpath of the path --- that is, it begins with a "move
  205. to" and ends with a "close subpath" --- oriented in the clockwise
  206. direction. If `transform' is non-NULL, then the lines representing the
  207. rectangle will be transformed by `transform' before they are added to the
  208. path. }
  209. function CGPathCreateWithRect( rect: CGRect; transform: {const} CGAffineTransformPtr ): CGPathRef; external name '_CGPathCreateWithRect';
  210. (* CG_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0) *)
  211. { Return a path representing an ellipse bounded by `rect'. The ellipse is
  212. approximated by a sequence of Bézier curves. The center of the ellipse is
  213. the midpoint of `rect'. If `rect' is square, then the ellipse will be
  214. circular with radius equal to one-half the width (equivalently, one-half
  215. the height) of `rect'. If `rect' is rectangular, then the major- and
  216. minor-axes will be the `width' and `height' of rect. The ellipse forms a
  217. complete subpath of the path --- that is, it begins with a "move to" and
  218. ends with a "close subpath" --- oriented in the clockwise direction. If
  219. `transform' is non-NULL, then the constructed Bézier curves representing
  220. the ellipse will be transformed by `transform' before they are added to
  221. the path. }
  222. function CGPathCreateWithEllipseInRect( rect: CGRect; transform: {const} CGAffineTransformPtr): CGPathRef; external name '_CGPathCreateWithEllipseInRect';
  223. (* CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) *)
  224. { Create a dashed path from `path'. The parameters `phase', `lengths', and
  225. `count' have the same meaning as the corresponding parameters for
  226. `CGContextSetLineDash'. If `transform' is non-NULL, then the elements of
  227. the constructed path will be transformed by `transform' before they are
  228. added to the path. }
  229. function CGPathCreateCopyByDashingPath( path: CGPathRef; transform: {const} CGAffineTransformPtr; phase: CGFloat; {const} lengths: {variable-size-array} CGFloatPtr; count: size_t ): CGPathRef; external name '_CGPathCreateCopyByDashingPath';
  230. (* CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) *)
  231. { Create a stroked path from `path'. The parameters `lineWidth', `lineCap',
  232. `lineJoin', and `miterLimit' have the same meaning as the corresponding
  233. CGContext parameters. If `transform' is non-NULL, then the elements of
  234. the constructed path will be transformed by `transform' before they are
  235. added to the path. }
  236. function CGPathCreateCopyByStrokingPath( path: CGPathRef; transform: {const} CGAffineTransformPtr; lineWidth: CGFloat; lineCap: CGLineCap; lineJoin: CGLineJoin; miterLimit: CGFloat ): CGPathRef; external name '_CGPathCreateCopyByStrokingPath';
  237. (* CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) *)
  238. { Equivalent to `CFRetain(path)', except it doesn't crash (as CFRetain
  239. does) if `path' is NULL. }
  240. function CGPathRetain( path: CGPathRef ): CGPathRef; external name '_CGPathRetain';
  241. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  242. { Equivalent to `CFRelease(path)', except it doesn't crash (as CFRelease
  243. does) if `path' is NULL. }
  244. procedure CGPathRelease( path: CGPathRef ); external name '_CGPathRelease';
  245. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  246. { Return true if `path1' is equal to `path2'; false otherwise. }
  247. function CGPathEqualToPath( path1: CGPathRef; path2: CGPathRef ): CBool; external name '_CGPathEqualToPath';
  248. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  249. {** Path construction functions. **}
  250. { Move the current point to `(x, y)' in `path' and begin a new subpath. If
  251. `m' is non-NULL, then transform `(x, y)' by `m' first. }
  252. procedure CGPathMoveToPoint( path: CGMutablePathRef; m: CGAffineTransformPtr; x: CGFloat; y: CGFloat ); external name '_CGPathMoveToPoint';
  253. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  254. { Append a straight line segment from the current point to `(x, y)' in
  255. `path' and move the current point to `(x, y)'. If `m' is non-NULL, then
  256. transform `(x, y)' by `m' first. }
  257. procedure CGPathAddLineToPoint( path: CGMutablePathRef; m: CGAffineTransformPtr; x: CGFloat; y: CGFloat ); external name '_CGPathAddLineToPoint';
  258. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  259. { Append a quadratic curve from the current point to `(x, y)' with control
  260. point `(cpx, cpy)' in `path' and move the current point to `(x, y)'. If
  261. `m' is non-NULL, then transform all points by `m' first. }
  262. procedure CGPathAddQuadCurveToPoint( path: CGMutablePathRef; m: CGAffineTransformPtr; cpx: CGFloat; cpy: CGFloat; x: CGFloat; y: CGFloat ); external name '_CGPathAddQuadCurveToPoint';
  263. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  264. { Append a cubic Bézier curve from the current point to `(x,y)' with
  265. control points `(cp1x, cp1y)' and `(cp2x, cp2y)' in `path' and move the
  266. current point to `(x, y)'. If `m' is non-NULL, then transform all points
  267. by `m' first. }
  268. procedure CGPathAddCurveToPoint( path: CGMutablePathRef; m: CGAffineTransformPtr; cp1x: CGFloat; cp1y: CGFloat; cp2x: CGFloat; cp2y: CGFloat; x: CGFloat; y: CGFloat ); external name '_CGPathAddCurveToPoint';
  269. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  270. { Append a line from the current point to the starting point of the current
  271. subpath of `path' and end the subpath. }
  272. procedure CGPathCloseSubpath( path: CGMutablePathRef ); external name '_CGPathCloseSubpath';
  273. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  274. {** Path construction convenience functions. **}
  275. { Add `rect' to `path'. If `m' is non-NULL, then first transform `rect' by
  276. `m' before adding it to `path'. }
  277. procedure CGPathAddRect( path: CGMutablePathRef; m: CGAffineTransformPtr; rect: CGRect ); external name '_CGPathAddRect';
  278. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  279. { Add each rectangle specified by `rects', an array of `count' CGRects, to
  280. `path'. If `m' is non-NULL, then first transform each rectangle by `m'
  281. before adding it to `path'. }
  282. procedure CGPathAddRects( path: CGMutablePathRef; m: CGAffineTransformPtr; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGPathAddRects';
  283. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  284. { Move to the first element of `points', an array of `count' CGPoints, and
  285. append a line from each point to the next point in `points'. If `m' is
  286. non-NULL, then first transform each point by `m'. }
  287. procedure CGPathAddLines( path: CGMutablePathRef; m: CGAffineTransformPtr; {const} points: {variable-size-array} CGPointPtr; count: size_t ); external name '_CGPathAddLines';
  288. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  289. { Add an ellipse (an oval) inside `rect' to `path'. The ellipse is
  290. approximated by a sequence of Bézier curves. The center of the ellipse is
  291. the midpoint of `rect'. If `rect' is square, then the ellipse will be
  292. circular with radius equal to one-half the width (equivalently, one-half
  293. the height) of `rect'. If `rect' is rectangular, then the major- and
  294. minor-axes will be the `width' and `height' of rect. The ellipse forms a
  295. complete subpath of `path' --- that is, it begins with a "move to" and
  296. ends with a "close subpath" --- oriented in the clockwise direction. If
  297. `m' is non-NULL, then the constructed Bézier curves representing the
  298. ellipse will be transformed by `m' before they are added to `path'. }
  299. procedure CGPathAddEllipseInRect( path: CGMutablePathRef; m: CGAffineTransformPtr; rect: CGRect ); external name '_CGPathAddEllipseInRect';
  300. (* CG_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) *)
  301. { Add an arc of a circle to `path', possibly preceded by a straight line
  302. segment. The arc is approximated by a sequence of Bézier curves. The
  303. center of the arc is `(x,y)'; `radius' is its radius. `startAngle' is the
  304. angle to the first endpoint of the arc, measured counter-clockwise from
  305. the positive x-axis. `startAngle + delta' is the angle to the second
  306. endpoint of the arc. If `delta' is positive, then the arc is drawn
  307. counter-clockwise; if negative, clockwise. `startAngle' and `delta' are
  308. measured in radians. If `matrix' is non-NULL, then the constructed Bézier
  309. curves representing the arc will be transformed by `matrix' before they
  310. are added to the path. }
  311. procedure CGPathAddRelativeArc( path: CGMutablePathRef; matrix: {const} CGAffineTransformPtr; x: CGFloat; y: CGFloat; radius: CGFloat; startAngle: CGFloat; delta: CGFloat ); external name '_CGPathAddRelativeArc';
  312. (* CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) *)
  313. { Add an arc of a circle to `path', possibly preceded by a straight line
  314. segment. The arc is approximated by a sequence of Bézier curves. `(x, y)'
  315. is the center of the arc; `radius' is its radius; `startAngle' is the
  316. angle to the first endpoint of the arc; `endAngle' is the angle to the
  317. second endpoint of the arc; and `clockwise' is true if the arc is to be
  318. drawn clockwise, false otherwise. `startAngle' and `endAngle' are
  319. measured in radians. If `m' is non-NULL, then the constructed Bézier
  320. curves representing the arc will be transformed by `m' before they are
  321. added to `path'.
  322. Note that using values very near 2π can be problematic. For example,
  323. setting `startAngle' to 0, `endAngle' to 2π, and `clockwise' to true will
  324. draw nothing. (It's easy to see this by considering, instead of 0 and 2π,
  325. the values ε and 2π - ε, where ε is very small.) Due to round-off error,
  326. however, it's possible that passing the value `2 * M_PI' to approximate
  327. 2π will numerically equal to 2π + δ, for some small δ; this will cause a
  328. full circle to be drawn.
  329. If you want a full circle to be drawn clockwise, you should set
  330. `startAngle' to 2π, `endAngle' to 0, and `clockwise' to true. This avoids
  331. the instability problems discussed above. }
  332. procedure CGPathAddArc( path: CGMutablePathRef; m: CGAffineTransformPtr; x: CGFloat; y: CGFloat; radius: CGFloat; startAngle: CGFloat; endAngle: CGFloat; clockwise: CBool ); external name '_CGPathAddArc';
  333. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  334. { Add an arc of a circle to `path', possibly preceded by a straight line
  335. segment. The arc is approximated by a sequence of Bézier curves. `radius'
  336. is the radius of the arc. The resulting arc is tangent to the line from
  337. the current point of `path' to `(x1, y1)', and the line from `(x1, y1)'
  338. to `(x2, y2)'. If `m' is non-NULL, then the constructed Bézier curves
  339. representing the arc will be transformed by `m' before they are added to
  340. `path'. }
  341. procedure CGPathAddArcToPoint( path: CGMutablePathRef; m: CGAffineTransformPtr; x1: CGFloat; y1: CGFloat; x2: CGFloat; y2: CGFloat; radius: CGFloat ); external name '_CGPathAddArcToPoint';
  342. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  343. { Add `path2' to `path1'. If `m' is non-NULL, then the points in `path2'
  344. will be transformed by `m' before they are added to `path1'. }
  345. procedure CGPathAddPath( path1: CGMutablePathRef; m: CGAffineTransformPtr; path2: CGPathRef ); external name '_CGPathAddPath';
  346. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  347. {** Path information functions. **}
  348. { Return true if `path' contains no elements, false otherwise. }
  349. function CGPathIsEmpty( path: CGPathRef ): CBool; external name '_CGPathIsEmpty';
  350. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  351. { Return true if `path' represents a rectangle, false otherwise. }
  352. function CGPathIsRect( path: CGPathRef; var rect: CGRect ): CBool; external name '_CGPathIsRect';
  353. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  354. { Return the current point of the current subpath of `path'. If there is no
  355. current point, then return CGPointZero. }
  356. function CGPathGetCurrentPoint( path: CGPathRef ): CGPoint; external name '_CGPathGetCurrentPoint';
  357. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  358. { Return the bounding box of `path'. The bounding box is the smallest
  359. rectangle completely enclosing all points in the path, including control
  360. points for Bézier cubic and quadratic curves. If the path is empty, then
  361. return `CGRectNull'. }
  362. function CGPathGetBoundingBox( path: CGPathRef ): CGRect; external name '_CGPathGetBoundingBox';
  363. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  364. { Return the path bounding box of `path'. The path bounding box is the
  365. smallest rectangle completely enclosing all points in the path, *not*
  366. including control points for Bézier cubic and quadratic curves. If the
  367. path is empty, then return `CGRectNull'. }
  368. function CGPathGetPathBoundingBox( path: CGPathRef ): CGRect; external name '_CGPathGetPathBoundingBox';
  369. (* CG_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_4_0) *)
  370. { Return true if `point' is contained in `path'; false otherwise. A point
  371. is contained in a path if it is inside the painted region when the path
  372. is filled; if `eoFill' is true, then the even-odd fill rule is used to
  373. evaluate the painted region of the path, otherwise, the winding-number
  374. fill rule is used. If `m' is non-NULL, then the point is transformed by
  375. `m' before determining whether the path contains it. }
  376. function CGPathContainsPoint( path: CGPathRef; m: CGAffineTransformPtr; point: CGPoint; eoFill: CBool ): CBool; external name '_CGPathContainsPoint';
  377. (* CG_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) *)
  378. { The types of path elements returned by `CGPathApply'. }
  379. type
  380. CGPathElementType = SInt32;
  381. const
  382. kCGPathElementMoveToPoint = 0;
  383. kCGPathElementAddLineToPoint = 1;
  384. kCGPathElementAddQuadCurveToPoint = 2;
  385. kCGPathElementAddCurveToPoint = 3;
  386. kCGPathElementCloseSubpath = 4;
  387. { An element of a path returned by `CGPathApply'. }
  388. type
  389. CGPathElement = record
  390. typ: CGPathElementType;
  391. {$ifc TARGET_CPU_64}
  392. __alignment_dummy: SInt32;
  393. {$endc}
  394. points: CGPointPtr;
  395. end;
  396. { The prototype for the function called by `CGPathApplyFunction'. }
  397. type
  398. CGPathApplierFunction = procedure( info: UnivPtr; const (*var*) element: CGPathElement );
  399. { For element of `path', call `function', passing it the path element and
  400. `info'. }
  401. procedure CGPathApply( path: CGPathRef; info: UnivPtr; func: CGPathApplierFunction ); external name '_CGPathApply';
  402. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  403. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  404. end.
  405. {$endc} {not MACOSALLINCLUDE}