1
{ CoreGraphics - CGContext.h
2
* Copyright (c) 2000-2003 Apple Computer, Inc.
5
{ Pascal Translation Updated: Peter N Lewis, <peter@stairways.com.au>, August 2005 }
7
Modified for use with Free Pascal
9
Please report any bugs to <gpc@microbizz.nl>
20
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
21
{$setc GAP_INTERFACES_VERSION := $0210}
23
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
24
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
27
{$ifc defined CPUPOWERPC and defined CPUI386}
28
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
30
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
31
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
34
{$ifc not defined __ppc__ and defined CPUPOWERPC}
39
{$ifc not defined __i386__ and defined CPUI386}
45
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
46
{$error Conflicting definitions for __ppc__ and __i386__}
49
{$ifc defined __ppc__ and __ppc__}
50
{$setc TARGET_CPU_PPC := TRUE}
51
{$setc TARGET_CPU_X86 := FALSE}
52
{$elifc defined __i386__ and __i386__}
53
{$setc TARGET_CPU_PPC := FALSE}
54
{$setc TARGET_CPU_X86 := TRUE}
56
{$error Neither __ppc__ nor __i386__ is defined.}
58
{$setc TARGET_CPU_PPC_64 := FALSE}
60
{$ifc defined FPC_BIG_ENDIAN}
61
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
62
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
63
{$elifc defined FPC_LITTLE_ENDIAN}
64
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
65
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
67
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
69
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
70
{$setc CALL_NOT_IN_CARBON := FALSE}
71
{$setc OLDROUTINENAMES := FALSE}
72
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
73
{$setc OPAQUE_UPP_TYPES := TRUE}
74
{$setc OTCARBONAPPLICATION := TRUE}
75
{$setc OTKERNEL := FALSE}
76
{$setc PM_USE_SESSION_APIS := TRUE}
77
{$setc TARGET_API_MAC_CARBON := TRUE}
78
{$setc TARGET_API_MAC_OS8 := FALSE}
79
{$setc TARGET_API_MAC_OSX := TRUE}
80
{$setc TARGET_CARBON := TRUE}
81
{$setc TARGET_CPU_68K := FALSE}
82
{$setc TARGET_CPU_MIPS := FALSE}
83
{$setc TARGET_CPU_SPARC := FALSE}
84
{$setc TARGET_OS_MAC := TRUE}
85
{$setc TARGET_OS_UNIX := FALSE}
86
{$setc TARGET_OS_WIN32 := FALSE}
87
{$setc TARGET_RT_MAC_68881 := FALSE}
88
{$setc TARGET_RT_MAC_CFM := FALSE}
89
{$setc TARGET_RT_MAC_MACHO := TRUE}
90
{$setc TYPED_FUNCTION_POINTERS := TRUE}
91
{$setc TYPE_BOOL := FALSE}
92
{$setc TYPE_EXTENDED := FALSE}
93
{$setc TYPE_LONGLONG := TRUE}
94
uses MacTypes,CFBase,CGGeometry,CGBase,CFDictionary,CGAffineTransforms,CGColorSpace,CGFont,CGImage,CGPDFDocument,CGPath,CGColor,CGShading,CGPDFPage;
99
CGContextRef = ^SInt32; { an opaque 32-bit type }
102
{ Line join styles. }
107
kCGLineJoinMiter = 0;
108
kCGLineJoinRound = 1;
109
kCGLineJoinBevel = 2;
118
kCGLineCapSquare = 2;
120
{ Drawing modes for paths. }
123
CGPathDrawingMode = SInt32;
128
kCGPathFillStroke = 3;
129
kCGPathEOFillStroke = 4;
131
{ Drawing modes for text. }
134
CGTextDrawingMode = SInt32;
138
kCGTextFillStroke = 2;
139
kCGTextInvisible = 3;
141
kCGTextStrokeClip = 5;
142
kCGTextFillStrokeClip = 6;
148
CGTextEncoding = SInt32;
150
kCGEncodingFontSpecific = 0;
151
kCGEncodingMacRoman = 1;
153
{ Interpolation quality. }
156
CGInterpolationQuality = SInt32;
158
kCGInterpolationDefault = 0; { Let the context decide. }
159
kCGInterpolationNone = 1; { Never interpolate. }
160
kCGInterpolationLow = 2; { Faster, lower quality. }
161
kCGInterpolationHigh = 3; { Slower, higher quality. }
166
CGBlendMode = SInt32;
168
kCGBlendModeNormal = 0;
169
kCGBlendModeMultiply = 1;
170
kCGBlendModeScreen = 2;
171
kCGBlendModeOverlay = 3;
172
kCGBlendModeDarken = 4;
173
kCGBlendModeLighten = 5;
174
kCGBlendModeColorDodge = 6;
175
kCGBlendModeColorBurn = 7;
176
kCGBlendModeSoftLight = 8;
177
kCGBlendModeHardLight = 9;
178
kCGBlendModeDifference = 10;
179
kCGBlendModeExclusion = 11;
180
kCGBlendModeHue = 12;
181
kCGBlendModeSaturation = 13;
182
kCGBlendModeColor = 14;
183
kCGBlendModeLuminosity = 15; { Available in Mac OS X 10.4 & later. }
186
{ Return the CFTypeID for CGContextRefs. }
188
function CGContextGetTypeID: CFTypeID; external name '_CGContextGetTypeID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
190
{* Graphics state functions. *}
192
{ Push a copy of the current graphics state onto the graphics state
193
* stack. Note that the path is not considered part of the gstate, and is
196
procedure CGContextSaveGState( c: CGContextRef ); external name '_CGContextSaveGState';
198
{ Restore the current graphics state from the one on the top of the
199
* graphics state stack, popping the graphics state stack in the
202
procedure CGContextRestoreGState( c: CGContextRef ); external name '_CGContextRestoreGState';
204
{* Coordinate space transformations. *}
206
{ Scale the current graphics state's transformation matrix (the CTM) by
209
procedure CGContextScaleCTM( c: CGContextRef; sx: Float32; sy: Float32 ); external name '_CGContextScaleCTM';
211
{ Translate the current graphics state's transformation matrix (the CTM)
214
procedure CGContextTranslateCTM( c: CGContextRef; tx: Float32; ty: Float32 ); external name '_CGContextTranslateCTM';
216
{ Rotate the current graphics state's transformation matrix (the CTM) by
219
procedure CGContextRotateCTM( c: CGContextRef; angle: Float32 ); external name '_CGContextRotateCTM';
221
{ Concatenate the current graphics state's transformation matrix (the CTM)
222
* with the affine transform `transform'. }
224
procedure CGContextConcatCTM( c: CGContextRef; transform: CGAffineTransform ); external name '_CGContextConcatCTM';
226
{ Return the current graphics state's transformation matrix. }
228
function CGContextGetCTM( c: CGContextRef ): CGAffineTransform; external name '_CGContextGetCTM';
230
{* Drawing attribute functions. *}
232
{ Set the line width in the current graphics state to `width'. }
234
procedure CGContextSetLineWidth( c: CGContextRef; width: Float32 ); external name '_CGContextSetLineWidth';
236
{ Set the line cap in the current graphics state to `cap'. }
238
procedure CGContextSetLineCap( c: CGContextRef; cap: CGLineCap ); external name '_CGContextSetLineCap';
240
{ Set the line join in the current graphics state to `join'. }
242
procedure CGContextSetLineJoin( c: CGContextRef; join: CGLineJoin ); external name '_CGContextSetLineJoin';
244
{ Set the miter limit in the current graphics state to `limit'. }
246
procedure CGContextSetMiterLimit( c: CGContextRef; limit: Float32 ); external name '_CGContextSetMiterLimit';
248
{ Set the line dash patttern in the current graphics state of `c'. }
250
procedure CGContextSetLineDash( c: CGContextRef; phase: Float32; {const} lengths: {variable-size-array} Float32Ptr; count: size_t ); external name '_CGContextSetLineDash';
252
{ Set the path flatness parameter in the current graphics state of `c' to
255
procedure CGContextSetFlatness( c: CGContextRef; flatness: Float32 ); external name '_CGContextSetFlatness';
257
{ Set the alpha value in the current graphics state of `c' to `alpha'. }
259
procedure CGContextSetAlpha( c: CGContextRef; alpha: Float32 ); external name '_CGContextSetAlpha';
261
{ Set the blend mode of `context' to `mode'. }
263
procedure CGContextSetBlendMode( context: CGContextRef; mode: CGBlendMode ); external name '_CGContextSetBlendMode'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
265
{* Path construction functions. *}
267
{ Note that a context has a single path in use at any time: a path is not
268
* part of the graphics state. }
270
{ Begin a new path. The old path is discarded. }
272
procedure CGContextBeginPath( c: CGContextRef ); external name '_CGContextBeginPath';
274
{ Start a new subpath at point `(x, y)' in the context's path. }
276
procedure CGContextMoveToPoint( c: CGContextRef; x: Float32; y: Float32 ); external name '_CGContextMoveToPoint';
278
{ Append a straight line segment from the current point to `(x, y)'. }
280
procedure CGContextAddLineToPoint( c: CGContextRef; x: Float32; y: Float32 ); external name '_CGContextAddLineToPoint';
282
{ Append a cubic Bezier curve from the current point to `(x,y)', with
283
* control points `(cp1x, cp1y)' and `(cp2x, cp2y)'. }
285
procedure CGContextAddCurveToPoint( c: CGContextRef; cp1x: Float32; cp1y: Float32; cp2x: Float32; cp2y: Float32; x: Float32; y: Float32 ); external name '_CGContextAddCurveToPoint';
287
{ Append a quadratic curve from the current point to `(x, y)', with
288
* control point `(cpx, cpy)'. }
290
procedure CGContextAddQuadCurveToPoint( c: CGContextRef; cpx: Float32; cpy: Float32; x: Float32; y: Float32 ); external name '_CGContextAddQuadCurveToPoint';
292
{ Close the current subpath of the context's path. }
294
procedure CGContextClosePath( c: CGContextRef ); external name '_CGContextClosePath';
296
{* Path construction convenience functions. *}
298
{ Add a single rect to the context's path. }
300
procedure CGContextAddRect( c: CGContextRef; rect: CGRect ); external name '_CGContextAddRect';
302
{ Add a set of rects to the context's path. }
304
procedure CGContextAddRects( c: CGContextRef; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGContextAddRects';
306
{ Add a set of lines to the context's path. }
308
procedure CGContextAddLines( c: CGContextRef; {const} points: {variable-size-array} CGPointPtr; count: size_t ); external name '_CGContextAddLines';
310
{ Add an ellipse inside `rect' to the current path of `context'. See the
311
* function `CGPathAddEllipseInRect' for more information on how the path
312
* for the ellipse is constructed. }
314
procedure CGContextAddEllipseInRect( context: CGContextRef; rect: CGRect ); external name '_CGContextAddEllipseInRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
316
{ Add an arc of a circle to the context's path, possibly preceded by a
317
* straight line segment. `(x, y)' is the center of the arc; `radius' is
318
* its radius; `startAngle' is the angle to the first endpoint of the arc;
319
* `endAngle' is the angle to the second endpoint of the arc; and
320
* `clockwise' is 1 if the arc is to be drawn clockwise, 0 otherwise.
321
* `startAngle' and `endAngle' are measured in radians. }
323
procedure CGContextAddArc( c: CGContextRef; x: Float32; y: Float32; radius: Float32; startAngle: Float32; endAngle: Float32; clockwise: SInt32 ); external name '_CGContextAddArc';
325
{ Add an arc of a circle to the context's path, possibly preceded by a
326
* straight line segment. `radius' is the radius of the arc. The arc is
327
* tangent to the line from the current point to `(x1, y1)', and the line
328
* from `(x1, y1)' to `(x2, y2)'. }
330
procedure CGContextAddArcToPoint( c: CGContextRef; x1: Float32; y1: Float32; x2: Float32; y2: Float32; radius: Float32 ); external name '_CGContextAddArcToPoint';
332
{ Add `path' to the path of context. The points in `path' are transformed
333
* by the CTM of context before they are added. }
335
procedure CGContextAddPath( context: CGContextRef; path: CGPathRef ); external name '_CGContextAddPath'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
339
{ Replace the path in context with the stroked version of the path, using
340
* the parameters of `context' to calculate the stroked path. The
341
* resulting path is created such that filling it with the appropriate
342
* color will produce the same results as stroking the original path. You
343
* can use this path in the same way you can use the path of any context;
344
* for example, you can clip to the stroked version of a path by calling
345
* this function followed by a call to "CGContextClipPath". }
347
procedure CGContextReplacePathWithStrokedPath( c: CGContextRef ); external name '_CGContextReplacePathWithStrokedPath'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
349
{* Path information functions. *}
351
{ Return true if the context's path contains no elements, false otherwise. }
353
function CGContextIsPathEmpty( c: CGContextRef ): CBool; external name '_CGContextIsPathEmpty';
355
{ Return the current point of the current subpath of the context's
358
function CGContextGetPathCurrentPoint( c: CGContextRef ): CGPoint; external name '_CGContextGetPathCurrentPoint';
360
{ Return the bounding box of the context's path. The bounding box is the
361
* smallest rectangle completely enclosing all points in the path,
362
* including control points for Bezier and quadratic curves. }
364
function CGContextGetPathBoundingBox( c: CGContextRef ): CGRect; external name '_CGContextGetPathBoundingBox';
366
{ Return true if `point' is contained in the current path of `context'. A
367
* point is contained within a context's path if it is inside the painted
368
* region when the path is stroked or filled with opaque colors using the
369
* path drawing mode `mode'. `point' is specified is user space. }
371
function CGContextPathContainsPoint( context: CGContextRef; point: CGPoint; mode: CGPathDrawingMode ): CBool; external name '_CGContextPathContainsPoint'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
373
{* Path drawing functions. *}
375
{ Draw the context's path using drawing mode `mode'. }
377
procedure CGContextDrawPath( c: CGContextRef; mode: CGPathDrawingMode ); external name '_CGContextDrawPath';
379
{* Path drawing convenience functions. *}
381
{ Fill the context's path using the winding-number fill rule. Any open
382
* subpath of the path is implicitly closed. }
384
procedure CGContextFillPath( c: CGContextRef ); external name '_CGContextFillPath';
386
{ Fill the context's path using the even-odd fill rule. Any open subpath
387
* of the path is implicitly closed. }
389
procedure CGContextEOFillPath( c: CGContextRef ); external name '_CGContextEOFillPath';
391
{ Stroke the context's path. }
393
procedure CGContextStrokePath( c: CGContextRef ); external name '_CGContextStrokePath';
395
{ Fill `rect' with the current fill color. }
397
procedure CGContextFillRect( c: CGContextRef; rect: CGRect ); external name '_CGContextFillRect';
399
{ Fill `rects', an array of `count' CGRects, with the current fill
402
procedure CGContextFillRects( c: CGContextRef; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGContextFillRects';
404
{ Stroke `rect' with the current stroke color and the current linewidth. }
406
procedure CGContextStrokeRect( c: CGContextRef; rect: CGRect ); external name '_CGContextStrokeRect';
408
{ Stroke `rect' with the current stroke color, using `width' as the the
411
procedure CGContextStrokeRectWithWidth( c: CGContextRef; rect: CGRect; width: Float32 ); external name '_CGContextStrokeRectWithWidth';
413
{ Clear `rect' (that is, set the region within the rect to
416
procedure CGContextClearRect( c: CGContextRef; rect: CGRect ); external name '_CGContextClearRect';
418
{ Fill an ellipse (an oval) inside `rect'. }
420
procedure CGContextFillEllipseInRect( context: CGContextRef; rect: CGRect ); external name '_CGContextFillEllipseInRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
422
{ Stroke an ellipse (an oval) inside `rect'. }
424
procedure CGContextStrokeEllipseInRect( context: CGContextRef; rect: CGRect ); external name '_CGContextStrokeEllipseInRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
426
{ Stroke a sequence of line segments one after another in `context'. The
427
* line segments are specified by `points', an array of `count' CGPoints.
428
* This function is equivalent to
429
* CGContextBeginPath(context);
430
* for (k = 0; k < count; k += 2) begin
431
* CGContextMoveToPoint(context, s[k].x, s[k].y);
432
* CGContextAddLineToPoint(context, s[k+1].x, s[k+1].y);
434
* CGContextStrokePath(context);
437
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 *)
439
{* Clipping functions. *}
441
{ Intersect the context's path with the current clip path and use the
442
* resulting path as the clip path for subsequent rendering operations.
443
* Use the winding-number fill rule for deciding what's inside the path. }
445
procedure CGContextClip( c: CGContextRef ); external name '_CGContextClip';
447
{ Intersect the context's path with the current clip path and use the
448
* resulting path as the clip path for subsequent rendering operations.
449
* Use the even-odd fill rule for deciding what's inside the path. }
451
procedure CGContextEOClip( c: CGContextRef ); external name '_CGContextEOClip';
453
{ Add `mask' transformed to `rect' to the clipping area of `context'. The
454
* mask, which may be either an image mask or an image, is mapped into the
455
* specified rectangle and intersected with the current clipping area of
458
* If `mask' is an image mask, then it clips in a manner identical to the
459
* behavior if it were used with "CGContextDrawImage": it indicates an area
460
* to be masked out (left unchanged) when drawing. The source samples of
461
* the image mask determine which points of the clipping area are changed,
462
* acting as an "inverse alpha": if the value of a source sample in the
463
* image mask is S, then the corresponding point in the current clipping
464
* area will be multiplied by an alpha of (1-S). (For example, if S is 1,
465
* then the point in the clipping area becomes clear, while if S is 0, the
466
* point in the clipping area is unchanged.
468
* If `mask' is an image, then it serves as alpha mask and is blended with
469
* the current clipping area. The source samples of mask determine which
470
* points of the clipping area are changed: if the value of the source
471
* sample in mask is S, then the corresponding point in the current
472
* clipping area will be multiplied by an alpha of S. (For example, if S
473
* is 0, then the point in the clipping area becomes clear, while if S is
474
* 1, the point in the clipping area is unchanged.
476
* If `mask' is an image, then it must be in the DeviceGray color space,
477
* may not have alpha, and may not be masked by an image mask or masking
480
procedure CGContextClipToMask( c: CGContextRef; rect: CGRect; mask: CGImageRef ); external name '_CGContextClipToMask';
482
{ Return the bounding box of the clip path of `c' in user space. The
483
* bounding box is the smallest rectangle completely enclosing all points
486
function CGContextGetClipBoundingBox( c: CGContextRef ): CGRect; external name '_CGContextGetClipBoundingBox'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
488
{* Clipping convenience functions. *}
490
{ Intersect the current clipping path with `rect'. Note that this
491
* function resets the context's path to the empty path. }
493
procedure CGContextClipToRect( c: CGContextRef; rect: CGRect ); external name '_CGContextClipToRect';
495
{ Intersect the current clipping path with the clipping region formed by
496
* creating a path consisting of all rects in `rects'. Note that this
497
* function resets the context's path to the empty path. }
499
procedure CGContextClipToRects( c: CGContextRef; {const} rects: {variable-size-array} CGRectPtr; count: size_t ); external name '_CGContextClipToRects';
501
{* Primitive color functions. *}
503
{ Set the current fill color in the context `c' to `color'. }
505
procedure CGContextSetFillColorWithColor( c: CGContextRef; color: CGColorRef ); external name '_CGContextSetFillColorWithColor'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
507
{ Set the current stroke color in the context `c' to `color'. }
509
procedure CGContextSetStrokeColorWithColor( c: CGContextRef; color: CGColorRef ); external name '_CGContextSetStrokeColorWithColor'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
511
{* Colorspace functions. *}
513
{ Set the current fill colorspace in the context `c' to `colorspace'. As
514
* a side-effect, set the fill color to a default value appropriate for the
517
procedure CGContextSetFillColorSpace( c: CGContextRef; colorspace: CGColorSpaceRef ); external name '_CGContextSetFillColorSpace';
519
{ Set the current stroke colorspace in the context `c' to `colorspace'.
520
* As a side-effect, set the stroke color to a default value appropriate
521
* for the colorspace. }
523
procedure CGContextSetStrokeColorSpace( c: CGContextRef; colorspace: CGColorSpaceRef ); external name '_CGContextSetStrokeColorSpace';
525
{* Color functions. *}
527
{ Set the components of the current fill color in the context `c' to the
528
* values specifed by `components'. The number of elements in `components'
529
* must be one greater than the number of components in the current fill
530
* colorspace (N color components + 1 alpha component). The current fill
531
* colorspace must not be a pattern colorspace. }
533
procedure CGContextSetFillColor( c: CGContextRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetFillColor';
535
{ Set the components of the current stroke color in the context `c' to the
536
* values specifed by `components'. The number of elements in `components'
537
* must be one greater than the number of components in the current stroke
538
* colorspace (N color components + 1 alpha component). The current stroke
539
* colorspace must not be a pattern colorspace. }
541
procedure CGContextSetStrokeColor( c: CGContextRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetStrokeColor';
543
{* Pattern functions. *}
545
{ Set the components of the current fill color in the context `c' to the
546
* values specifed by `components', and set the current fill pattern to
547
* `pattern'. The number of elements in `components' must be one greater
548
* than the number of components in the current fill colorspace (N color
549
* components + 1 alpha component). The current fill colorspace must be a
550
* pattern colorspace. }
552
procedure CGContextSetFillPattern( c: CGContextRef; pattern: CGPatternRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetFillPattern';
554
{ Set the components of the current stroke color in the context `c' to the
555
* values specifed by `components', and set the current stroke pattern to
556
* `pattern'. The number of elements in `components' must be one greater
557
* than the number of components in the current stroke colorspace (N color
558
* components + 1 alpha component). The current stroke colorspace must be
559
* a pattern colorspace. }
561
procedure CGContextSetStrokePattern( c: CGContextRef; pattern: CGPatternRef; {const} components: {variable-size-array} Float32Ptr ); external name '_CGContextSetStrokePattern';
563
{ Set the pattern phase in the current graphics state of the context `c'
566
procedure CGContextSetPatternPhase( c: CGContextRef; phase: CGSize ); external name '_CGContextSetPatternPhase';
568
{* Color convenience functions. *}
570
{ Set the current fill colorspace in the context `c' to `DeviceGray' and
571
* set the components of the current fill color to `(gray, alpha)'. }
573
procedure CGContextSetGrayFillColor( c: CGContextRef; gray: Float32; alpha: Float32 ); external name '_CGContextSetGrayFillColor';
575
{ Set the current stroke colorspace in the context `c' to `DeviceGray' and
576
* set the components of the current stroke color to `(gray, alpha)'. }
578
procedure CGContextSetGrayStrokeColor( c: CGContextRef; gray: Float32; alpha: Float32 ); external name '_CGContextSetGrayStrokeColor';
580
{ Set the current fill colorspace in the context `c' to `DeviceRGB' and
581
* set the components of the current fill color to `(red, green, blue,
584
procedure CGContextSetRGBFillColor( c: CGContextRef; red: Float32; green: Float32; blue: Float32; alpha: Float32 ); external name '_CGContextSetRGBFillColor';
586
{ Set the current stroke colorspace in the context `c' to `DeviceRGB' and
587
* set the components of the current stroke color to `(red, green, blue,
590
procedure CGContextSetRGBStrokeColor( c: CGContextRef; red: Float32; green: Float32; blue: Float32; alpha: Float32 ); external name '_CGContextSetRGBStrokeColor';
592
{ Set the current fill colorspace in the context `c' to `DeviceCMYK' and
593
* set the components of the current fill color to `(cyan, magenta, yellow,
596
procedure CGContextSetCMYKFillColor( c: CGContextRef; cyan: Float32; magenta: Float32; yellow: Float32; black: Float32; alpha: Float32 ); external name '_CGContextSetCMYKFillColor';
598
{ Set the current stroke colorspace in the context `c' to `DeviceCMYK' and
599
* set the components of the current stroke color to `(cyan, magenta,
600
* yellow, black, alpha)'. }
602
procedure CGContextSetCMYKStrokeColor( c: CGContextRef; cyan: Float32; magenta: Float32; yellow: Float32; black: Float32; alpha: Float32 ); external name '_CGContextSetCMYKStrokeColor';
604
{* Rendering intent. *}
606
{ Set the rendering intent in the current graphics state of context `c' to
609
procedure CGContextSetRenderingIntent( c: CGContextRef; intent: CGColorRenderingIntent ); external name '_CGContextSetRenderingIntent';
611
{* Image functions. *}
613
{ Draw `image' in the rectangular area specified by `rect' in the context
614
* `c'. The image is scaled, if necessary, to fit into `rect'. }
616
procedure CGContextDrawImage( c: CGContextRef; rect: CGRect; image: CGImageRef ); external name '_CGContextDrawImage';
618
{ Return the interpolation quality for image rendering of the context `c'.
619
* The interpolation quality is a gstate-parameter which controls the level
620
* of interpolation performed when an image is interpolated (for example,
621
* when scaling the image). Note that it is merely a hint to the context:
622
* not all contexts support all interpolation quality levels. }
624
function CGContextGetInterpolationQuality( c: CGContextRef ): CGInterpolationQuality; external name '_CGContextGetInterpolationQuality';
626
{ Set the interpolation quality of the context `c' to `quality'. }
628
procedure CGContextSetInterpolationQuality( c: CGContextRef; quality: CGInterpolationQuality ); external name '_CGContextSetInterpolationQuality';
630
{* Shadow support. *}
632
{ Set the shadow parameters in `context'. `offset' specifies a
633
* translation in base-space; `blur' is a non-negative number specifying
634
* the amount of blur; `color' specifies the color of the shadow, which may
635
* contain a non-opaque alpha value. If `color' is NULL, it's equivalent
636
* to specifying a fully transparent color. The shadow is a gstate
637
* parameter. After a shadow is specified, all objects drawn subsequently
638
* will be shadowed. To turn off shadowing, set the shadow color to a
639
* fully transparent color (or pass NULL as the color), or use the standard
640
* gsave/grestore mechanism. }
642
procedure CGContextSetShadowWithColor( context: CGContextRef; offset: CGSize; blur: Float32; color: CGColorRef ); external name '_CGContextSetShadowWithColor'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
644
{ Equivalent to calling
645
* CGContextSetShadowWithColor(context, offset, blur, color)
646
* where color is black with 1/3 alpha (i.e., RGBA = (0, 0, 0, 1.0/3.0)) in
647
* the DeviceRGB colorspace. }
649
procedure CGContextSetShadow( context: CGContextRef; offset: CGSize; blur: Float32 ); external name '_CGContextSetShadow'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
651
{* Shading functions. *}
653
{ Fill the current clipping region of `c' with `shading'. }
655
procedure CGContextDrawShading( c: CGContextRef; shading: CGShadingRef ); external name '_CGContextDrawShading'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
657
{* Text functions. *}
659
{ Set the current character spacing in the context `c' to `spacing'. The
660
* character spacing is added to the displacement between the origin of one
661
* character and the origin of the next. }
663
procedure CGContextSetCharacterSpacing( c: CGContextRef; spacing: Float32 ); external name '_CGContextSetCharacterSpacing';
665
{ Set the user-space point at which text will be drawn in the context `c'
668
procedure CGContextSetTextPosition( c: CGContextRef; x: Float32; y: Float32 ); external name '_CGContextSetTextPosition';
670
{ Return the user-space point at which text will be drawn in the context
673
function CGContextGetTextPosition( c: CGContextRef ): CGPoint; external name '_CGContextGetTextPosition';
675
{ Set the text matrix in the context `c' to `t'. }
677
procedure CGContextSetTextMatrix( c: CGContextRef; t: CGAffineTransform ); external name '_CGContextSetTextMatrix';
679
{ Return the text matrix in the context `c'. }
681
function CGContextGetTextMatrix( c: CGContextRef ): CGAffineTransform; external name '_CGContextGetTextMatrix';
683
{ Set the text drawing mode in the current graphics state of the context
686
procedure CGContextSetTextDrawingMode( c: CGContextRef; mode: CGTextDrawingMode ); external name '_CGContextSetTextDrawingMode';
688
{ Set the font in the current graphics state of the context `c' to
691
procedure CGContextSetFont( c: CGContextRef; font: CGFontRef ); external name '_CGContextSetFont';
693
{ Set the font size in the current graphics state of the context `c' to
696
procedure CGContextSetFontSize( c: CGContextRef; size: Float32 ); external name '_CGContextSetFontSize';
698
{ Attempts to find the font named `name' and, if successful, sets it as
699
* the font in the current graphics state of `c' and sets the font size in
700
* the current graphics state to `size'. `textEncoding' specifies how to
701
* translate from bytes to glyphs when displaying text. }
703
procedure CGContextSelectFont( c: CGContextRef; name: ConstCStringPtr; size: Float32; textEncoding: CGTextEncoding ); external name '_CGContextSelectFont';
705
{ Draw `string', a string of `length' bytes, at the point specified by the
706
* text matrix in the context `c'. Each byte of the string is mapped
707
* through the encoding vector of the current font to obtain the glyph to
710
procedure CGContextShowText( c: CGContextRef; strng: ConstCStringPtr; length: size_t ); external name '_CGContextShowText';
712
{ Draw the glyphs pointed to by `g', an array of `count' glyphs, at the
713
* point specified by the text matrix in the context `c'. }
715
procedure CGContextShowGlyphs( c: CGContextRef; {const} g: {variable-size-array} CGGlyphPtr; count: size_t ); external name '_CGContextShowGlyphs';
717
{ Draw `glyphs', an array of `count' CGGlyphs, at the current point
718
* specified by the text matrix. Each element of `advances' specifies the
719
* offset from the previous glyph's origin to the origin of the associated
720
* glyph; the advances are specified in user space. }
722
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 *)
724
{* Text convenience functions. *}
726
{ Draw `string', a string of `length' bytes, at the point `(x, y)',
727
* specified in user space, in the context `c'. Each byte of the string is
728
* mapped through the encoding vector of the current font to obtain the
729
* glyph to display. }
731
procedure CGContextShowTextAtPoint( c: CGContextRef; x: Float32; y: Float32; strng: ConstCStringPtr; length: size_t ); external name '_CGContextShowTextAtPoint';
733
{ Display the glyphs pointed to by `glyphs', an array of `count' glyphs,
734
* at at the point `(x, y)', specified in user space, in the context
737
procedure CGContextShowGlyphsAtPoint( c: CGContextRef; x: Float32; y: Float32; {const} glyphs: {variable-size-array} CGGlyphPtr; count: size_t ); external name '_CGContextShowGlyphsAtPoint';
741
{ Draw `page' in the current user space of the context `c'. }
743
procedure CGContextDrawPDFPage( c: CGContextRef; page: CGPDFPageRef ); external name '_CGContextDrawPDFPage'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
745
{ DEPRECATED; use the CGPDFPage API instead.
746
* Draw `page' in `document' in the rectangular area specified by `rect' in
747
* the context `c'. The media box of the page is scaled, if necessary, to
750
procedure CGContextDrawPDFDocument( c: CGContextRef; rect: CGRect; document: CGPDFDocumentRef; page: SInt32 ); external name '_CGContextDrawPDFDocument';
752
{* Output page functions. *}
754
{ Begin a new page. }
756
procedure CGContextBeginPage( c: CGContextRef; const (*var*) mediaBox: CGRect ); external name '_CGContextBeginPage';
758
{ End the current page. }
760
procedure CGContextEndPage( c: CGContextRef ); external name '_CGContextEndPage';
762
{* Context functions. *}
764
{ Equivalent to `CFRetain(c)'. }
766
function CGContextRetain( c: CGContextRef ): CGContextRef; external name '_CGContextRetain';
768
{ Equivalent to `CFRelease(c)'. }
770
procedure CGContextRelease( c: CGContextRef ); external name '_CGContextRelease';
772
{ Flush all drawing to the destination. }
774
procedure CGContextFlush( c: CGContextRef ); external name '_CGContextFlush';
776
{ Synchronized drawing. }
778
procedure CGContextSynchronize( c: CGContextRef ); external name '_CGContextSynchronize';
780
{* Antialiasing functions. *}
782
{ Turn on antialiasing if `shouldAntialias' is true; turn it off
783
* otherwise. This parameter is part of the graphics state. }
785
procedure CGContextSetShouldAntialias( c: CGContextRef; shouldAntialias: CBool ); external name '_CGContextSetShouldAntialias';
787
{ Allow antialiasing in context `c' if `allowsAntialiasing' is true; don't
788
* allow it otherwise. This parameter is not part of the graphics state. A
789
* context will perform antialiasing if both `allowsAntialiasing' and the
790
* graphics state parameter `shouldAntialias' are true. }
792
procedure CGContextSetAllowsAntialiasing( context: CGContextRef; allowsAntialiasing: CBool ); external name '_CGContextSetAllowsAntialiasing'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
794
{* Font smoothing functions. *}
796
{ Turn on font smoothing if `shouldSmoothFonts' is true; turn it off
797
* otherwise. This parameter is part of the graphics state. Note that this
798
* doesn't guarantee that font smoothing will occur: not all destination
799
* contexts support font smoothing. }
801
procedure CGContextSetShouldSmoothFonts( c: CGContextRef; shouldSmoothFonts: CBool ); external name '_CGContextSetShouldSmoothFonts'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
803
{* Transparency layer support. *}
805
{ Begin a transparency layer. All subsequent drawing operations until a
806
* corresponding CGContextEndTransparencyLayer are composited into a fully
807
* transparent backdrop (which is treated as a separate destination buffer
808
* from the context); after a call to CGContextEndTransparencyLayer, the
809
* result is composited into the context using the global alpha and shadow
810
* state of the context. This operation respects the clipping region of
811
* the context. After a call to this function, all of the parameters in
812
* the graphics state remain unchanged with the exception of the following:
813
* The global alpha is set to 1.
814
* The shadow is turned off.
815
* Ending the transparency layer restores these parameters to the values
816
* they had before CGContextBeginTransparencyLayer was called.
817
* Transparency layers may be nested. }
819
procedure CGContextBeginTransparencyLayer( context: CGContextRef; auxiliaryInfo: CFDictionaryRef ); external name '_CGContextBeginTransparencyLayer'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
821
{ End a tranparency layer. }
823
procedure CGContextEndTransparencyLayer( context: CGContextRef ); external name '_CGContextEndTransparencyLayer'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
825
{* User space to device space tranformations. *}
827
{ Return the affine transform mapping the user space (abstract
828
* coordinates) of `context' to device space (pixels). }
830
function CGContextGetUserSpaceToDeviceSpaceTransform( c: CGContextRef ): CGAffineTransform; external name '_CGContextGetUserSpaceToDeviceSpaceTransform'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
832
{ Transform `point' from the user space of `context' to device space. }
834
function CGContextConvertPointToDeviceSpace( c: CGContextRef; point: CGPoint ): CGPoint; external name '_CGContextConvertPointToDeviceSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
836
{ Transform `point' from device space to the user space of `context'. }
838
function CGContextConvertPointToUserSpace( c: CGContextRef; point: CGPoint ): CGPoint; external name '_CGContextConvertPointToUserSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
840
{ Transform `size' from the user space of `context' to device space. }
842
function CGContextConvertSizeToDeviceSpace( c: CGContextRef; size: CGSize ): CGSize; external name '_CGContextConvertSizeToDeviceSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
844
{ Transform `size' from device space to the user space of `context'. }
846
function CGContextConvertSizeToUserSpace( c: CGContextRef; size: CGSize ): CGSize; external name '_CGContextConvertSizeToUserSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
848
{ Transform `rect' from the user space of `context' to device space. Since
849
* affine transforms do not preserve rectangles in general, this function
850
* returns the smallest rectangle which contains the transformed corner
851
* points of `rect'. }
853
function CGContextConvertRectToDeviceSpace( c: CGContextRef; rect: CGRect ): CGRect; external name '_CGContextConvertRectToDeviceSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
855
{ Transform `rect' from device space to the user space of `context'. Since
856
* affine transforms do not preserve rectangles in general, this function
857
* returns the smallest rectangle which contains the transformed corner
858
* points of `rect'. }
860
function CGContextConvertRectToUserSpace( c: CGContextRef; rect: CGRect ): CGRect; external name '_CGContextConvertRectToUserSpace'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)