CGContext.pas 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. { CoreGraphics - CGContext.h
  2. * Copyright (c) 2000-2003 Apple Computer, Inc.
  3. * All rights reserved.
  4. }
  5. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 200
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$mode macpas}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$CALLING MWPASCAL}
  16. unit CGContext;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  19. {$setc GAP_INTERFACES_VERSION := $0200}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __i386__ and defined CPUI386}
  35. {$setc __i386__ := 1}
  36. {$elsec}
  37. {$setc __i386__ := 0}
  38. {$endc}
  39. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  40. {$error Conflicting definitions for __ppc__ and __i386__}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__}
  43. {$setc TARGET_CPU_PPC := TRUE}
  44. {$setc TARGET_CPU_X86 := FALSE}
  45. {$elifc defined __i386__ and __i386__}
  46. {$setc TARGET_CPU_PPC := FALSE}
  47. {$setc TARGET_CPU_X86 := TRUE}
  48. {$elsec}
  49. {$error Neither __ppc__ nor __i386__ is defined.}
  50. {$endc}
  51. {$setc TARGET_CPU_PPC_64 := FALSE}
  52. {$ifc defined FPC_BIG_ENDIAN}
  53. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  54. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  55. {$elifc defined FPC_LITTLE_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  58. {$elsec}
  59. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  60. {$endc}
  61. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  62. {$setc CALL_NOT_IN_CARBON := FALSE}
  63. {$setc OLDROUTINENAMES := FALSE}
  64. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  65. {$setc OPAQUE_UPP_TYPES := TRUE}
  66. {$setc OTCARBONAPPLICATION := TRUE}
  67. {$setc OTKERNEL := FALSE}
  68. {$setc PM_USE_SESSION_APIS := TRUE}
  69. {$setc TARGET_API_MAC_CARBON := TRUE}
  70. {$setc TARGET_API_MAC_OS8 := FALSE}
  71. {$setc TARGET_API_MAC_OSX := TRUE}
  72. {$setc TARGET_CARBON := TRUE}
  73. {$setc TARGET_CPU_68K := FALSE}
  74. {$setc TARGET_CPU_MIPS := FALSE}
  75. {$setc TARGET_CPU_SPARC := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_UNIX := FALSE}
  78. {$setc TARGET_OS_WIN32 := FALSE}
  79. {$setc TARGET_RT_MAC_68881 := FALSE}
  80. {$setc TARGET_RT_MAC_CFM := FALSE}
  81. {$setc TARGET_RT_MAC_MACHO := TRUE}
  82. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  83. {$setc TYPE_BOOL := FALSE}
  84. {$setc TYPE_EXTENDED := FALSE}
  85. {$setc TYPE_LONGLONG := TRUE}
  86. uses MacTypes,CFBase,CGGeometry,CGBase,CFDictionary,CGAffineTransforms,CGColorSpace,CGFont,CGImage,CGPDFDocument,CGPath,CGColor,CGShading,CGPDFPage;
  87. {$ALIGN POWER}
  88. type
  89. CGContextRef = ^SInt32; { an opaque 32-bit type }
  90. { Line join styles. }
  91. type
  92. CGLineJoin = SInt32;
  93. const
  94. kCGLineJoinMiter = 0;
  95. kCGLineJoinRound = 1;
  96. kCGLineJoinBevel = 2;
  97. { Line cap styles. }
  98. type
  99. CGLineCap = SInt32;
  100. const
  101. kCGLineCapButt = 0;
  102. kCGLineCapRound = 1;
  103. kCGLineCapSquare = 2;
  104. { Drawing modes for paths. }
  105. type
  106. CGPathDrawingMode = SInt32;
  107. const
  108. kCGPathFill = 0;
  109. kCGPathEOFill = 1;
  110. kCGPathStroke = 2;
  111. kCGPathFillStroke = 3;
  112. kCGPathEOFillStroke = 4;
  113. { Drawing modes for text. }
  114. type
  115. CGTextDrawingMode = SInt32;
  116. const
  117. kCGTextFill = 0;
  118. kCGTextStroke = 1;
  119. kCGTextFillStroke = 2;
  120. kCGTextInvisible = 3;
  121. kCGTextFillClip = 4;
  122. kCGTextStrokeClip = 5;
  123. kCGTextFillStrokeClip = 6;
  124. kCGTextClip = 7;
  125. { Text encodings. }
  126. type
  127. CGTextEncoding = SInt32;
  128. const
  129. kCGEncodingFontSpecific = 0;
  130. kCGEncodingMacRoman = 1;
  131. { Interpolation quality. }
  132. type
  133. CGInterpolationQuality = SInt32;
  134. const
  135. kCGInterpolationDefault = 0; { Let the context decide. }
  136. kCGInterpolationNone = 1; { Never interpolate. }
  137. kCGInterpolationLow = 2; { Faster, lower quality. }
  138. kCGInterpolationHigh = 3; { Slower, higher quality. }
  139. { Blend modes. }
  140. type
  141. CGBlendMode = SInt32;
  142. const
  143. kCGBlendModeNormal = 0;
  144. kCGBlendModeMultiply = 1;
  145. kCGBlendModeScreen = 2;
  146. kCGBlendModeOverlay = 3;
  147. kCGBlendModeDarken = 4;
  148. kCGBlendModeLighten = 5;
  149. kCGBlendModeColorDodge = 6;
  150. kCGBlendModeColorBurn = 7;
  151. kCGBlendModeSoftLight = 8;
  152. kCGBlendModeHardLight = 9;
  153. kCGBlendModeDifference = 10;
  154. kCGBlendModeExclusion = 11;
  155. kCGBlendModeHue = 12;
  156. kCGBlendModeSaturation = 13;
  157. kCGBlendModeColor = 14;
  158. kCGBlendModeLuminosity = 15; { Available in Mac OS X 10.4 & later. }
  159. { Return the CFTypeID for CGContextRefs. }
  160. function CGContextGetTypeID: CFTypeID; external name '_CGContextGetTypeID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  161. {* Graphics state functions. *}
  162. { Push a copy of the current graphics state onto the graphics state
  163. * stack. Note that the path is not considered part of the gstate, and is
  164. * not saved. }
  165. procedure CGContextSaveGState( c: CGContextRef ); external name '_CGContextSaveGState';
  166. { Restore the current graphics state from the one on the top of the
  167. * graphics state stack, popping the graphics state stack in the
  168. * process. }
  169. procedure CGContextRestoreGState( c: CGContextRef ); external name '_CGContextRestoreGState';
  170. {* Coordinate space transformations. *}
  171. { Scale the current graphics state's transformation matrix (the CTM) by
  172. * `(sx, sy)'. }
  173. procedure CGContextScaleCTM( c: CGContextRef; sx: Float32; sy: Float32 ); external name '_CGContextScaleCTM';
  174. { Translate the current graphics state's transformation matrix (the CTM)
  175. * by `(tx, ty)'. }
  176. procedure CGContextTranslateCTM( c: CGContextRef; tx: Float32; ty: Float32 ); external name '_CGContextTranslateCTM';
  177. { Rotate the current graphics state's transformation matrix (the CTM) by
  178. * `angle' radians. }
  179. procedure CGContextRotateCTM( c: CGContextRef; angle: Float32 ); external name '_CGContextRotateCTM';
  180. { Concatenate the current graphics state's transformation matrix (the CTM)
  181. * with the affine transform `transform'. }
  182. procedure CGContextConcatCTM( c: CGContextRef; transform: CGAffineTransform ); external name '_CGContextConcatCTM';
  183. { Return the current graphics state's transformation matrix. }
  184. function CGContextGetCTM( c: CGContextRef ): CGAffineTransform; external name '_CGContextGetCTM';
  185. {* Drawing attribute functions. *}
  186. { Set the line width in the current graphics state to `width'. }
  187. procedure CGContextSetLineWidth( c: CGContextRef; width: Float32 ); external name '_CGContextSetLineWidth';
  188. { Set the line cap in the current graphics state to `cap'. }
  189. procedure CGContextSetLineCap( c: CGContextRef; cap: CGLineCap ); external name '_CGContextSetLineCap';
  190. { Set the line join in the current graphics state to `join'. }
  191. procedure CGContextSetLineJoin( c: CGContextRef; join: CGLineJoin ); external name '_CGContextSetLineJoin';
  192. { Set the miter limit in the current graphics state to `limit'. }
  193. procedure CGContextSetMiterLimit( c: CGContextRef; limit: Float32 ); external name '_CGContextSetMiterLimit';
  194. { Set the line dash patttern in the current graphics state of `c'. }
  195. procedure CGContextSetLineDash( c: CGContextRef; phase: Float32; {const} lengths: {variable-size-array} Float32Ptr; count: size_t ); external name '_CGContextSetLineDash';
  196. { Set the path flatness parameter in the current graphics state of `c' to
  197. * `flatness'. }
  198. procedure CGContextSetFlatness( c: CGContextRef; flatness: Float32 ); external name '_CGContextSetFlatness';
  199. { Set the alpha value in the current graphics state of `c' to `alpha'. }
  200. procedure CGContextSetAlpha( c: CGContextRef; alpha: Float32 ); external name '_CGContextSetAlpha';
  201. { Set the blend mode of `context' to `mode'. }
  202. procedure CGContextSetBlendMode( context: CGContextRef; mode: CGBlendMode ); external name '_CGContextSetBlendMode'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  203. {* Path construction functions. *}
  204. { Note that a context has a single path in use at any time: a path is not
  205. * part of the graphics state. }
  206. { Begin a new path. The old path is discarded. }
  207. procedure CGContextBeginPath( c: CGContextRef ); external name '_CGContextBeginPath';
  208. { Start a new subpath at point `(x, y)' in the context's path. }
  209. procedure CGContextMoveToPoint( c: CGContextRef; x: Float32; y: Float32 ); external name '_CGContextMoveToPoint';
  210. { Append a straight line segment from the current point to `(x, y)'. }
  211. procedure CGContextAddLineToPoint( c: CGContextRef; x: Float32; y: Float32 ); external name '_CGContextAddLineToPoint';
  212. { Append a cubic Bezier curve from the current point to `(x,y)', with
  213. * control points `(cp1x, cp1y)' and `(cp2x, cp2y)'. }
  214. procedure CGContextAddCurveToPoint( c: CGContextRef; cp1x: Float32; cp1y: Float32; cp2x: Float32; cp2y: Float32; x: Float32; y: Float32 ); external name '_CGContextAddCurveToPoint';
  215. { Append a quadratic curve from the current point to `(x, y)', with
  216. * control point `(cpx, cpy)'. }
  217. procedure CGContextAddQuadCurveToPoint( c: CGContextRef; cpx: Float32; cpy: Float32; x: Float32; y: Float32 ); external name '_CGContextAddQuadCurveToPoint';
  218. { Close the current subpath of the context's path. }
  219. procedure CGContextClosePath( c: CGContextRef ); external name '_CGContextClosePath';
  220. {* Path construction convenience functions. *}
  221. { Add a single rect to the context's path. }
  222. procedure CGContextAddRect( c: CGContextRef; rect: CGRect ); external name '_CGContextAddRect';
  223. { Add a set of rects to the context's path. }
  224. procedure CGContextAddRects( c: CGContextRef; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGContextAddRects';
  225. { Add a set of lines to the context's path. }
  226. procedure CGContextAddLines( c: CGContextRef; {const} points: {variable-size-array} CGPointPtr; count: size_t ); external name '_CGContextAddLines';
  227. { Add an ellipse inside `rect' to the current path of `context'. See the
  228. * function `CGPathAddEllipseInRect' for more information on how the path
  229. * for the ellipse is constructed. }
  230. procedure CGContextAddEllipseInRect( context: CGContextRef; rect: CGRect ); external name '_CGContextAddEllipseInRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  231. { Add an arc of a circle to the context's path, possibly preceded by a
  232. * straight line segment. `(x, y)' is the center of the arc; `radius' is
  233. * its radius; `startAngle' is the angle to the first endpoint of the arc;
  234. * `endAngle' is the angle to the second endpoint of the arc; and
  235. * `clockwise' is 1 if the arc is to be drawn clockwise, 0 otherwise.
  236. * `startAngle' and `endAngle' are measured in radians. }
  237. procedure CGContextAddArc( c: CGContextRef; x: Float32; y: Float32; radius: Float32; startAngle: Float32; endAngle: Float32; clockwise: SInt32 ); external name '_CGContextAddArc';
  238. { Add an arc of a circle to the context's path, possibly preceded by a
  239. * straight line segment. `radius' is the radius of the arc. The arc is
  240. * tangent to the line from the current point to `(x1, y1)', and the line
  241. * from `(x1, y1)' to `(x2, y2)'. }
  242. procedure CGContextAddArcToPoint( c: CGContextRef; x1: Float32; y1: Float32; x2: Float32; y2: Float32; radius: Float32 ); external name '_CGContextAddArcToPoint';
  243. { Add `path' to the path of context. The points in `path' are transformed
  244. * by the CTM of context before they are added. }
  245. procedure CGContextAddPath( context: CGContextRef; path: CGPathRef ); external name '_CGContextAddPath'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  246. {* Path stroking. *}
  247. { Replace the path in context with the stroked version of the path, using
  248. * the parameters of `context' to calculate the stroked path. The
  249. * resulting path is created such that filling it with the appropriate
  250. * color will produce the same results as stroking the original path. You
  251. * can use this path in the same way you can use the path of any context;
  252. * for example, you can clip to the stroked version of a path by calling
  253. * this function followed by a call to "CGContextClipPath". }
  254. procedure CGContextReplacePathWithStrokedPath( c: CGContextRef ); external name '_CGContextReplacePathWithStrokedPath'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  255. {* Path information functions. *}
  256. { Return true if the context's path contains no elements, false otherwise. }
  257. function CGContextIsPathEmpty( c: CGContextRef ): CBool; external name '_CGContextIsPathEmpty';
  258. { Return the current point of the current subpath of the context's
  259. * path. }
  260. function CGContextGetPathCurrentPoint( c: CGContextRef ): CGPoint; external name '_CGContextGetPathCurrentPoint';
  261. { Return the bounding box of the context's path. The bounding box is the
  262. * smallest rectangle completely enclosing all points in the path,
  263. * including control points for Bezier and quadratic curves. }
  264. function CGContextGetPathBoundingBox( c: CGContextRef ): CGRect; external name '_CGContextGetPathBoundingBox';
  265. { Return true if `point' is contained in the current path of `context'. A
  266. * point is contained within a context's path if it is inside the painted
  267. * region when the path is stroked or filled with opaque colors using the
  268. * path drawing mode `mode'. `point' is specified is user space. }
  269. function CGContextPathContainsPoint( context: CGContextRef; point: CGPoint; mode: CGPathDrawingMode ): CBool; external name '_CGContextPathContainsPoint'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  270. {* Path drawing functions. *}
  271. { Draw the context's path using drawing mode `mode'. }
  272. procedure CGContextDrawPath( c: CGContextRef; mode: CGPathDrawingMode ); external name '_CGContextDrawPath';
  273. {* Path drawing convenience functions. *}
  274. { Fill the context's path using the winding-number fill rule. Any open
  275. * subpath of the path is implicitly closed. }
  276. procedure CGContextFillPath( c: CGContextRef ); external name '_CGContextFillPath';
  277. { Fill the context's path using the even-odd fill rule. Any open subpath
  278. * of the path is implicitly closed. }
  279. procedure CGContextEOFillPath( c: CGContextRef ); external name '_CGContextEOFillPath';
  280. { Stroke the context's path. }
  281. procedure CGContextStrokePath( c: CGContextRef ); external name '_CGContextStrokePath';
  282. { Fill `rect' with the current fill color. }
  283. procedure CGContextFillRect( c: CGContextRef; rect: CGRect ); external name '_CGContextFillRect';
  284. { Fill `rects', an array of `count' CGRects, with the current fill
  285. * color. }
  286. procedure CGContextFillRects( c: CGContextRef; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGContextFillRects';
  287. { Stroke `rect' with the current stroke color and the current linewidth. }
  288. procedure CGContextStrokeRect( c: CGContextRef; rect: CGRect ); external name '_CGContextStrokeRect';
  289. { Stroke `rect' with the current stroke color, using `width' as the the
  290. * line width. }
  291. procedure CGContextStrokeRectWithWidth( c: CGContextRef; rect: CGRect; width: Float32 ); external name '_CGContextStrokeRectWithWidth';
  292. { Clear `rect' (that is, set the region within the rect to
  293. * transparent). }
  294. procedure CGContextClearRect( c: CGContextRef; rect: CGRect ); external name '_CGContextClearRect';
  295. { Fill an ellipse (an oval) inside `rect'. }
  296. procedure CGContextFillEllipseInRect( context: CGContextRef; rect: CGRect ); external name '_CGContextFillEllipseInRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  297. { Stroke an ellipse (an oval) inside `rect'. }
  298. procedure CGContextStrokeEllipseInRect( context: CGContextRef; rect: CGRect ); external name '_CGContextStrokeEllipseInRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  299. { Stroke a sequence of line segments one after another in `context'. The
  300. * line segments are specified by `points', an array of `count' CGPoints.
  301. * This function is equivalent to
  302. * CGContextBeginPath(context);
  303. * for (k = 0; k < count; k += 2) begin
  304. * CGContextMoveToPoint(context, s[k].x, s[k].y);
  305. * CGContextAddLineToPoint(context, s[k+1].x, s[k+1].y);
  306. * end;
  307. * CGContextStrokePath(context);
  308. }
  309. procedure CGContextStrokeLineSegments( c: CGContextRef; {const} points: {variable-size-array} CGPointPtr; count: size_t ); external name '_CGContextStrokeLineSegments'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  310. {* Clipping functions. *}
  311. { Intersect the context's path with the current clip path and use the
  312. * resulting path as the clip path for subsequent rendering operations.
  313. * Use the winding-number fill rule for deciding what's inside the path. }
  314. procedure CGContextClip( c: CGContextRef ); external name '_CGContextClip';
  315. { Intersect the context's path with the current clip path and use the
  316. * resulting path as the clip path for subsequent rendering operations.
  317. * Use the even-odd fill rule for deciding what's inside the path. }
  318. procedure CGContextEOClip( c: CGContextRef ); external name '_CGContextEOClip';
  319. { Add `mask' transformed to `rect' to the clipping area of `context'. The
  320. * mask, which may be either an image mask or an image, is mapped into the
  321. * specified rectangle and intersected with the current clipping area of
  322. * the context.
  323. *
  324. * If `mask' is an image mask, then it clips in a manner identical to the
  325. * behavior if it were used with "CGContextDrawImage": it indicates an area
  326. * to be masked out (left unchanged) when drawing. The source samples of
  327. * the image mask determine which points of the clipping area are changed,
  328. * acting as an "inverse alpha": if the value of a source sample in the
  329. * image mask is S, then the corresponding point in the current clipping
  330. * area will be multiplied by an alpha of (1-S). (For example, if S is 1,
  331. * then the point in the clipping area becomes clear, while if S is 0, the
  332. * point in the clipping area is unchanged.
  333. *
  334. * If `mask' is an image, then it serves as alpha mask and is blended with
  335. * the current clipping area. The source samples of mask determine which
  336. * points of the clipping area are changed: if the value of the source
  337. * sample in mask is S, then the corresponding point in the current
  338. * clipping area will be multiplied by an alpha of S. (For example, if S
  339. * is 0, then the point in the clipping area becomes clear, while if S is
  340. * 1, the point in the clipping area is unchanged.
  341. *
  342. * If `mask' is an image, then it must be in the DeviceGray color space,
  343. * may not have alpha, and may not be masked by an image mask or masking
  344. * color. }
  345. procedure CGContextClipToMask( c: CGContextRef; rect: CGRect; mask: CGImageRef ); external name '_CGContextClipToMask';
  346. { Return the bounding box of the clip path of `c' in user space. The
  347. * bounding box is the smallest rectangle completely enclosing all points
  348. * in the clip. }
  349. function CGContextGetClipBoundingBox( c: CGContextRef ): CGRect; external name '_CGContextGetClipBoundingBox'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  350. {* Clipping convenience functions. *}
  351. { Intersect the current clipping path with `rect'. Note that this
  352. * function resets the context's path to the empty path. }
  353. procedure CGContextClipToRect( c: CGContextRef; rect: CGRect ); external name '_CGContextClipToRect';
  354. { Intersect the current clipping path with the clipping region formed by
  355. * creating a path consisting of all rects in `rects'. Note that this
  356. * function resets the context's path to the empty path. }
  357. procedure CGContextClipToRects( c: CGContextRef; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGContextClipToRects';
  358. {* Primitive color functions. *}
  359. { Set the current fill color in the context `c' to `color'. }
  360. procedure CGContextSetFillColorWithColor( c: CGContextRef; color: CGColorRef ); external name '_CGContextSetFillColorWithColor'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  361. { Set the current stroke color in the context `c' to `color'. }
  362. procedure CGContextSetStrokeColorWithColor( c: CGContextRef; color: CGColorRef ); external name '_CGContextSetStrokeColorWithColor'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  363. {* Colorspace functions. *}
  364. { Set the current fill colorspace in the context `c' to `colorspace'. As
  365. * a side-effect, set the fill color to a default value appropriate for the
  366. * colorspace. }
  367. procedure CGContextSetFillColorSpace( c: CGContextRef; colorspace: CGColorSpaceRef ); external name '_CGContextSetFillColorSpace';
  368. { Set the current stroke colorspace in the context `c' to `colorspace'.
  369. * As a side-effect, set the stroke color to a default value appropriate
  370. * for the colorspace. }
  371. procedure CGContextSetStrokeColorSpace( c: CGContextRef; colorspace: CGColorSpaceRef ); external name '_CGContextSetStrokeColorSpace';
  372. {* Color functions. *}
  373. { Set the components of the current fill color in the context `c' to the
  374. * values specifed by `components'. The number of elements in `components'
  375. * must be one greater than the number of components in the current fill
  376. * colorspace (N color components + 1 alpha component). The current fill
  377. * colorspace must not be a pattern colorspace. }
  378. procedure CGContextSetFillColor( c: CGContextRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetFillColor';
  379. { Set the components of the current stroke color in the context `c' to the
  380. * values specifed by `components'. The number of elements in `components'
  381. * must be one greater than the number of components in the current stroke
  382. * colorspace (N color components + 1 alpha component). The current stroke
  383. * colorspace must not be a pattern colorspace. }
  384. procedure CGContextSetStrokeColor( c: CGContextRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetStrokeColor';
  385. {* Pattern functions. *}
  386. { Set the components of the current fill color in the context `c' to the
  387. * values specifed by `components', and set the current fill pattern to
  388. * `pattern'. The number of elements in `components' must be one greater
  389. * than the number of components in the current fill colorspace (N color
  390. * components + 1 alpha component). The current fill colorspace must be a
  391. * pattern colorspace. }
  392. procedure CGContextSetFillPattern( c: CGContextRef; pattern: CGPatternRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetFillPattern';
  393. { Set the components of the current stroke color in the context `c' to the
  394. * values specifed by `components', and set the current stroke pattern to
  395. * `pattern'. The number of elements in `components' must be one greater
  396. * than the number of components in the current stroke colorspace (N color
  397. * components + 1 alpha component). The current stroke colorspace must be
  398. * a pattern colorspace. }
  399. procedure CGContextSetStrokePattern( c: CGContextRef; pattern: CGPatternRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetStrokePattern';
  400. { Set the pattern phase in the current graphics state of the context `c'
  401. * to `phase'. }
  402. procedure CGContextSetPatternPhase( c: CGContextRef; phase: CGSize ); external name '_CGContextSetPatternPhase';
  403. {* Color convenience functions. *}
  404. { Set the current fill colorspace in the context `c' to `DeviceGray' and
  405. * set the components of the current fill color to `(gray, alpha)'. }
  406. procedure CGContextSetGrayFillColor( c: CGContextRef; gray: Float32; alpha: Float32 ); external name '_CGContextSetGrayFillColor';
  407. { Set the current stroke colorspace in the context `c' to `DeviceGray' and
  408. * set the components of the current stroke color to `(gray, alpha)'. }
  409. procedure CGContextSetGrayStrokeColor( c: CGContextRef; gray: Float32; alpha: Float32 ); external name '_CGContextSetGrayStrokeColor';
  410. { Set the current fill colorspace in the context `c' to `DeviceRGB' and
  411. * set the components of the current fill color to `(red, green, blue,
  412. * alpha)'. }
  413. procedure CGContextSetRGBFillColor( c: CGContextRef; red: Float32; green: Float32; blue: Float32; alpha: Float32 ); external name '_CGContextSetRGBFillColor';
  414. { Set the current stroke colorspace in the context `c' to `DeviceRGB' and
  415. * set the components of the current stroke color to `(red, green, blue,
  416. * alpha)'. }
  417. procedure CGContextSetRGBStrokeColor( c: CGContextRef; red: Float32; green: Float32; blue: Float32; alpha: Float32 ); external name '_CGContextSetRGBStrokeColor';
  418. { Set the current fill colorspace in the context `c' to `DeviceCMYK' and
  419. * set the components of the current fill color to `(cyan, magenta, yellow,
  420. * black, alpha)'. }
  421. procedure CGContextSetCMYKFillColor( c: CGContextRef; cyan: Float32; magenta: Float32; yellow: Float32; black: Float32; alpha: Float32 ); external name '_CGContextSetCMYKFillColor';
  422. { Set the current stroke colorspace in the context `c' to `DeviceCMYK' and
  423. * set the components of the current stroke color to `(cyan, magenta,
  424. * yellow, black, alpha)'. }
  425. procedure CGContextSetCMYKStrokeColor( c: CGContextRef; cyan: Float32; magenta: Float32; yellow: Float32; black: Float32; alpha: Float32 ); external name '_CGContextSetCMYKStrokeColor';
  426. {* Rendering intent. *}
  427. { Set the rendering intent in the current graphics state of context `c' to
  428. * `intent'. }
  429. procedure CGContextSetRenderingIntent( c: CGContextRef; intent: CGColorRenderingIntent ); external name '_CGContextSetRenderingIntent';
  430. {* Image functions. *}
  431. { Draw `image' in the rectangular area specified by `rect' in the context
  432. * `c'. The image is scaled, if necessary, to fit into `rect'. }
  433. procedure CGContextDrawImage( c: CGContextRef; rect: CGRect; image: CGImageRef ); external name '_CGContextDrawImage';
  434. { Return the interpolation quality for image rendering of the context `c'.
  435. * The interpolation quality is a gstate-parameter which controls the level
  436. * of interpolation performed when an image is interpolated (for example,
  437. * when scaling the image). Note that it is merely a hint to the context:
  438. * not all contexts support all interpolation quality levels. }
  439. function CGContextGetInterpolationQuality( c: CGContextRef ): CGInterpolationQuality; external name '_CGContextGetInterpolationQuality';
  440. { Set the interpolation quality of the context `c' to `quality'. }
  441. procedure CGContextSetInterpolationQuality( c: CGContextRef; quality: CGInterpolationQuality ); external name '_CGContextSetInterpolationQuality';
  442. {* Shadow support. *}
  443. { Set the shadow parameters in `context'. `offset' specifies a
  444. * translation in base-space; `blur' is a non-negative number specifying
  445. * the amount of blur; `color' specifies the color of the shadow, which may
  446. * contain a non-opaque alpha value. If `color' is NULL, it's equivalent
  447. * to specifying a fully transparent color. The shadow is a gstate
  448. * parameter. After a shadow is specified, all objects drawn subsequently
  449. * will be shadowed. To turn off shadowing, set the shadow color to a
  450. * fully transparent color (or pass NULL as the color), or use the standard
  451. * gsave/grestore mechanism. }
  452. procedure CGContextSetShadowWithColor( context: CGContextRef; offset: CGSize; blur: Float32; color: CGColorRef ); external name '_CGContextSetShadowWithColor'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  453. { Equivalent to calling
  454. * CGContextSetShadowWithColor(context, offset, blur, color)
  455. * where color is black with 1/3 alpha (i.e., RGBA = (0, 0, 0, 1.0/3.0)) in
  456. * the DeviceRGB colorspace. }
  457. procedure CGContextSetShadow( context: CGContextRef; offset: CGSize; blur: Float32 ); external name '_CGContextSetShadow'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  458. {* Shading functions. *}
  459. { Fill the current clipping region of `c' with `shading'. }
  460. procedure CGContextDrawShading( c: CGContextRef; shading: CGShadingRef ); external name '_CGContextDrawShading'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  461. {* Text functions. *}
  462. { Set the current character spacing in the context `c' to `spacing'. The
  463. * character spacing is added to the displacement between the origin of one
  464. * character and the origin of the next. }
  465. procedure CGContextSetCharacterSpacing( c: CGContextRef; spacing: Float32 ); external name '_CGContextSetCharacterSpacing';
  466. { Set the user-space point at which text will be drawn in the context `c'
  467. * to `(x, y)'. }
  468. procedure CGContextSetTextPosition( c: CGContextRef; x: Float32; y: Float32 ); external name '_CGContextSetTextPosition';
  469. { Return the user-space point at which text will be drawn in the context
  470. * `c'. }
  471. function CGContextGetTextPosition( c: CGContextRef ): CGPoint; external name '_CGContextGetTextPosition';
  472. { Set the text matrix in the context `c' to `t'. }
  473. procedure CGContextSetTextMatrix( c: CGContextRef; t: CGAffineTransform ); external name '_CGContextSetTextMatrix';
  474. { Return the text matrix in the context `c'. }
  475. function CGContextGetTextMatrix( c: CGContextRef ): CGAffineTransform; external name '_CGContextGetTextMatrix';
  476. { Set the text drawing mode in the current graphics state of the context
  477. * `c' to `mode'. }
  478. procedure CGContextSetTextDrawingMode( c: CGContextRef; mode: CGTextDrawingMode ); external name '_CGContextSetTextDrawingMode';
  479. { Set the font in the current graphics state of the context `c' to
  480. * `font'. }
  481. procedure CGContextSetFont( c: CGContextRef; font: CGFontRef ); external name '_CGContextSetFont';
  482. { Set the font size in the current graphics state of the context `c' to
  483. * `size'. }
  484. procedure CGContextSetFontSize( c: CGContextRef; size: Float32 ); external name '_CGContextSetFontSize';
  485. { Attempts to find the font named `name' and, if successful, sets it as
  486. * the font in the current graphics state of `c' and sets the font size in
  487. * the current graphics state to `size'. `textEncoding' specifies how to
  488. * translate from bytes to glyphs when displaying text. }
  489. procedure CGContextSelectFont( c: CGContextRef; name: ConstCStringPtr; size: Float32; textEncoding: CGTextEncoding ); external name '_CGContextSelectFont';
  490. { Draw `string', a string of `length' bytes, at the point specified by the
  491. * text matrix in the context `c'. Each byte of the string is mapped
  492. * through the encoding vector of the current font to obtain the glyph to
  493. * display. }
  494. procedure CGContextShowText( c: CGContextRef; strng: ConstCStringPtr; length: size_t ); external name '_CGContextShowText';
  495. { Draw the glyphs pointed to by `g', an array of `count' glyphs, at the
  496. * point specified by the text matrix in the context `c'. }
  497. procedure CGContextShowGlyphs( c: CGContextRef; {const} g: {variable-size-array} CGGlyphPtr; count: size_t ); external name '_CGContextShowGlyphs';
  498. { Draw `glyphs', an array of `count' CGGlyphs, at the current point
  499. * specified by the text matrix. Each element of `advances' specifies the
  500. * offset from the previous glyph's origin to the origin of the associated
  501. * glyph; the advances are specified in user space. }
  502. procedure CGContextShowGlyphsWithAdvances( c: CGContextRef; {const} glyphs: {variable-size-array} CGGlyphPtr; {const} advances: {variable-size-array} CGSizePtr; count: size_t ); external name '_CGContextShowGlyphsWithAdvances'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  503. {* Text convenience functions. *}
  504. { Draw `string', a string of `length' bytes, at the point `(x, y)',
  505. * specified in user space, in the context `c'. Each byte of the string is
  506. * mapped through the encoding vector of the current font to obtain the
  507. * glyph to display. }
  508. procedure CGContextShowTextAtPoint( c: CGContextRef; x: Float32; y: Float32; strng: ConstCStringPtr; length: size_t ); external name '_CGContextShowTextAtPoint';
  509. { Display the glyphs pointed to by `glyphs', an array of `count' glyphs,
  510. * at at the point `(x, y)', specified in user space, in the context
  511. * `c'. }
  512. procedure CGContextShowGlyphsAtPoint( c: CGContextRef; x: Float32; y: Float32; {const} glyphs: {variable-size-array} CGGlyphPtr; count: size_t ); external name '_CGContextShowGlyphsAtPoint';
  513. {* PDF functions. *}
  514. { Draw `page' in the current user space of the context `c'. }
  515. procedure CGContextDrawPDFPage( c: CGContextRef; page: CGPDFPageRef ); external name '_CGContextDrawPDFPage'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  516. { DEPRECATED; use the CGPDFPage API instead.
  517. * Draw `page' in `document' in the rectangular area specified by `rect' in
  518. * the context `c'. The media box of the page is scaled, if necessary, to
  519. * fit into `rect'. }
  520. procedure CGContextDrawPDFDocument( c: CGContextRef; rect: CGRect; document: CGPDFDocumentRef; page: SInt32 ); external name '_CGContextDrawPDFDocument';
  521. {* Output page functions. *}
  522. { Begin a new page. }
  523. procedure CGContextBeginPage( c: CGContextRef; const (*var*) mediaBox: CGRect ); external name '_CGContextBeginPage';
  524. { End the current page. }
  525. procedure CGContextEndPage( c: CGContextRef ); external name '_CGContextEndPage';
  526. {* Context functions. *}
  527. { Equivalent to `CFRetain(c)'. }
  528. function CGContextRetain( c: CGContextRef ): CGContextRef; external name '_CGContextRetain';
  529. { Equivalent to `CFRelease(c)'. }
  530. procedure CGContextRelease( c: CGContextRef ); external name '_CGContextRelease';
  531. { Flush all drawing to the destination. }
  532. procedure CGContextFlush( c: CGContextRef ); external name '_CGContextFlush';
  533. { Synchronized drawing. }
  534. procedure CGContextSynchronize( c: CGContextRef ); external name '_CGContextSynchronize';
  535. {* Antialiasing functions. *}
  536. { Turn on antialiasing if `shouldAntialias' is true; turn it off
  537. * otherwise. This parameter is part of the graphics state. }
  538. procedure CGContextSetShouldAntialias( c: CGContextRef; shouldAntialias: CBool ); external name '_CGContextSetShouldAntialias';
  539. { Allow antialiasing in context `c' if `allowsAntialiasing' is true; don't
  540. * allow it otherwise. This parameter is not part of the graphics state. A
  541. * context will perform antialiasing if both `allowsAntialiasing' and the
  542. * graphics state parameter `shouldAntialias' are true. }
  543. procedure CGContextSetAllowsAntialiasing( context: CGContextRef; allowsAntialiasing: CBool ); external name '_CGContextSetAllowsAntialiasing'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  544. {* Font smoothing functions. *}
  545. { Turn on font smoothing if `shouldSmoothFonts' is true; turn it off
  546. * otherwise. This parameter is part of the graphics state. Note that this
  547. * doesn't guarantee that font smoothing will occur: not all destination
  548. * contexts support font smoothing. }
  549. procedure CGContextSetShouldSmoothFonts( c: CGContextRef; shouldSmoothFonts: CBool ); external name '_CGContextSetShouldSmoothFonts'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  550. {* Transparency layer support. *}
  551. { Begin a transparency layer. All subsequent drawing operations until a
  552. * corresponding CGContextEndTransparencyLayer are composited into a fully
  553. * transparent backdrop (which is treated as a separate destination buffer
  554. * from the context); after a call to CGContextEndTransparencyLayer, the
  555. * result is composited into the context using the global alpha and shadow
  556. * state of the context. This operation respects the clipping region of
  557. * the context. After a call to this function, all of the parameters in
  558. * the graphics state remain unchanged with the exception of the following:
  559. * The global alpha is set to 1.
  560. * The shadow is turned off.
  561. * Ending the transparency layer restores these parameters to the values
  562. * they had before CGContextBeginTransparencyLayer was called.
  563. * Transparency layers may be nested. }
  564. procedure CGContextBeginTransparencyLayer( context: CGContextRef; auxiliaryInfo: CFDictionaryRef ); external name '_CGContextBeginTransparencyLayer'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  565. { End a tranparency layer. }
  566. procedure CGContextEndTransparencyLayer( context: CGContextRef ); external name '_CGContextEndTransparencyLayer'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  567. {* User space to device space tranformations. *}
  568. { Return the affine transform mapping the user space (abstract
  569. * coordinates) of `context' to device space (pixels). }
  570. function CGContextGetUserSpaceToDeviceSpaceTransform( c: CGContextRef ): CGAffineTransform; external name '_CGContextGetUserSpaceToDeviceSpaceTransform'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  571. { Transform `point' from the user space of `context' to device space. }
  572. function CGContextConvertPointToDeviceSpace( c: CGContextRef; point: CGPoint ): CGPoint; external name '_CGContextConvertPointToDeviceSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  573. { Transform `point' from device space to the user space of `context'. }
  574. function CGContextConvertPointToUserSpace( c: CGContextRef; point: CGPoint ): CGPoint; external name '_CGContextConvertPointToUserSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  575. { Transform `size' from the user space of `context' to device space. }
  576. function CGContextConvertSizeToDeviceSpace( c: CGContextRef; size: CGSize ): CGSize; external name '_CGContextConvertSizeToDeviceSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  577. { Transform `size' from device space to the user space of `context'. }
  578. function CGContextConvertSizeToUserSpace( c: CGContextRef; size: CGSize ): CGSize; external name '_CGContextConvertSizeToUserSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  579. { Transform `rect' from the user space of `context' to device space. Since
  580. * affine transforms do not preserve rectangles in general, this function
  581. * returns the smallest rectangle which contains the transformed corner
  582. * points of `rect'. }
  583. function CGContextConvertRectToDeviceSpace( c: CGContextRef; rect: CGRect ): CGRect; external name '_CGContextConvertRectToDeviceSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  584. { Transform `rect' from device space to the user space of `context'. Since
  585. * affine transforms do not preserve rectangles in general, this function
  586. * returns the smallest rectangle which contains the transformed corner
  587. * points of `rect'. }
  588. function CGContextConvertRectToUserSpace( c: CGContextRef; rect: CGRect ): CGRect; external name '_CGContextConvertRectToUserSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  589. end.