CGContextRef詳解

/* CoreGraphics - CGContext.h */數組

 

/** Graphics state functions. **/ 數據結構

//爲了讓開發者在進行座標變換時無須計算屢次座標變換後的累加結果,Quartz 2D還提供了以下兩個方法來保存、恢復繪圖狀態函數

 

/* 字體

 保存CGContextRef當前的繪圖狀態,方便之後恢復該狀態*/spa

void CGContextSaveGState(CGContextRef__nullable c) component

// 須要說明的是,CGContextSaveGState()函數保存的繪圖狀態,不只包括當前座標系統的狀態,也包括當前設置的填充風格、線條風格、陰影風格等各類繪圖狀態。但 CGContextSaveGState()函數不會保存當前繪製的圖形orm

 

/* 對象

 把CGContextRef的狀態恢復到最近一次保存時的狀態*/圖片

void CGContextRestoreGState(CGContextRef__nullable c)ip

    

/** Coordinate space transformations. **/

 

/* 縮放座標系統

該方法控制座標系統水平方向上縮放 sx,垂直方向上縮放 sy。在縮放後的座標系統上繪製圖形時,全部點的 X 座標都至關於乘以 sx 因子,全部點的 Y 座標都至關於乘以 sy因子。*/

void CGContextScaleCTM(CGContextRef__nullable c, CGFloat sx, CGFloat sy)

 

/* 平移座標系統

 該方法至關於把原來位於 (0, 0) 位置的座標原點平移到 (tx, ty)點。在平移後的座標系統上繪製圖形時,全部座標點的 X座標都至關於增長了 tx,全部點的 Y座標都至關於增長了 ty。*/

void CGContextTranslateCTM(CGContextRef__nullable c,

    CGFloat tx, CGFloat ty)

    

/* 旋轉座標系統

 該方法控制座標系統旋轉 angle 弧度。在縮放後的座標系統上繪製圖形時,全部座標點的 X、Y座標都至關於旋轉了 angle弧度以後的座標。*/

void CGContextRotateCTM(CGContextRef__nullable c, CGFloat angle)

 

/*

 使用 transform變換矩陣對 CGContextRef的座標系統執行變換,經過使用座標矩陣能夠對座標系統執行任意變換。*/

void CGContextConcatCTM(CGContextRef__nullable c,

    CGAffineTransform transform)

 

/* 獲取CGContextRef的座標系統的變換矩陣*/

CGAffineTransform CGContextGetCTM(CGContextRef__nullable c)

 

/** Drawing attribute functions. **/

 

/* 

 設置繪製直線、邊框時的線條寬度*/

void CGContextSetLineWidth(CGContextRef__nullable c, CGFloat width)

 

/* 

 設置線段端點的繪製形狀。該屬性支持以下三個值。*/

typedef CF_ENUM(int32_t, CGLineCap) {

    kCGLineCapButt, //該屬性值指定不繪製端點,線條結尾處直接結束。這是默認值。

    kCGLineCapRound,//該屬性值指定繪製圓形端點,線條結尾處繪製一個直徑爲線條寬度的半圓。

    kCGLineCapSquare//該屬性值指定繪製方形端點。線條結尾處繪製半個邊長爲線條寬度的正方形。須要說明的是,這種形狀的端點與「butt」形狀的端點十分類似,只是採用這種形式的端點的線條略長一點而已

};

void CGContextSetLineCap(CGContextRef__nullable c, CGLineCap cap)

 

typedef CF_ENUM(int32_t, CGLineJoin) {

    kCGLineJoinMiter, // 這是默認的屬性值。該方格的鏈接點形狀如圖1所示。

    kCGLineJoinRound, // 稍微圓角, 該方格的鏈接點形狀如圖2所示。

    kCGLineJoinBevel  // 斜角,該方格的鏈接點形狀如圖3所示。

};

圖1     圖2    圖3 

/* 

 設置線條鏈接點的風格,該屬性支持如上三個值:*/

void CGContextSetLineJoin(CGContextRef__nullable c, CGLineJoin join)

 

/* 

 當把鏈接點風格設爲meter風格時,該方法用於控制銳角箭頭的長度*/

void CGContextSetMiterLimit(CGContextRef__nullable c, CGFloat limit)

 

 

/* 

 Linedash pattern(虛線模式)容許咱們沿着描邊繪製虛線。咱們經過在CGContextSetLineDash結構體中指定虛線數組和虛線相位來控制虛線的大小及位置。

其中lengths屬性指定了虛線段的長度,該值是在繪製片段與未繪製片段之間交替。phase屬性指定虛線模式的起始點。圖3-11顯示了虛線模式:*/

void CGContextSetLineDash(CGContextRef__nullable c, CGFloat phase,const CGFloat *__nullable lengths, size_t count)

 

/* 設置彎曲的路徑中的圖形上下文的準確性。*/

void CGContextSetFlatness(CGContextRef__nullable c, CGFloat flatness)

 

/* 

 設置全局透明度*/

void CGContextSetAlpha(CGContextRef__nullable c, CGFloat alpha)

 

/* 

設置CGContextRef的疊加模式。Quartz 2D支持多種疊加模

*/void CGContextSetBlendMode(CGContextRef __nullable c, CGBlendMode mode)

 

/** Path construction functions. **/

 

/* Note that a context has a single path in use at any time: a path is not

   part of the graphics state. */

 

/* 開始建立路徑. */

void CGContextBeginPath(CGContextRef__nullable c)

 

/* 開始一個新的子路徑點 */

void CGContextMoveToPoint(CGContextRef__nullable c,

    CGFloat x, CGFloat y)

 

/* 添加一條直線段從當前指向的(x,y)。 */

void CGContextAddLineToPoint(CGContextRef__nullable c,

    CGFloat x, CGFloat y)

 

/**

 *  從當前添加一個三次Bezier曲線

 *  @param cp1x 控制點1 x座標

 *  @param cp1y 控制點1 y座標

 *  @param cp2x 控制點2 x座標

 *  @param cp2y 控制點2 y座標

 *  @param x    直線的終點 x座標

 *  @param y    直線的終點 y座標

 */

void CGContextAddCurveToPoint(CGContextRef__nullable c, CGFloat cp1x, CGFloat cp1y, CGFloat cp2x, CGFloat cp2y, CGFloat x, CGFloat y)    

 

/**

 *  從當前添加一個二次Bezier曲線

 *  @param cpx 控制點 x座標

 *  @param cpy 控制點 y座標

 *  @param x   直線的終點 x座標

 *  @param y   直線的終點 y座標

 */

void CGContextAddQuadCurveToPoint(CGContextRef__nullable c, CGFloat cpx, CGFloat cpy,CGFloat x,CGFloat y)

 

/* 關閉當前上下文的子路徑,且當前點和起點鏈接起來 */

void CGContextClosePath(CGContextRef__nullable c)

 

/** Path construction convenience functions. **/

 

/* 添加一個矩形路徑 */

void CGContextAddRect(CGContextRef__nullable c, CGRect rect)

 

/* 添加多個矩形路徑 */

void CGContextAddRects(CGContextRef__nullable c,

    const CGRect * __nullable rects, size_t count)

 

/* 添加多條直線路徑*/

void CGContextAddLines(CGContextRef__nullable c,

    const CGPoint * __nullable points, size_t count)

 

/* 根據一個矩形,繪製橢圓(圓形 */

void CGContextAddEllipseInRect(CGContextRef__nullable c, CGRect rect)

 

/**

 *  添加弧形對象

 *  @param x          中心點x座標

 *  @param y          中心點y座標

 *  @param radius     半徑

 *  @param startAngle 起始弧度

 *  @param endAngle   終止弧度

 *  @param clockwise  是否逆時針繪製,0則順時針繪製

 */

void CGContextAddArc(CGContextRef__nullable c, CGFloat x,CGFloat y,CGFloat radius,CGFloat startAngle,CGFloat endAngle,int clockwise)

 

 

/* 這個函數使用一個序列的三次貝塞爾曲線建立一個弧

 原理:首先畫兩條線,這兩條線分別是 current point to (x1,y1)和(x1,y1) to (x2,y2).這樣就是出現一個以(x1,y1)爲頂點的兩條射線,而後定義半徑長度,這個半徑是垂直於兩條射線的,這樣就能決定一個圓了,若是當前點和第一個切點的弧(起點)是不平等的,那麼會添加一條直線段從當前指向第一個切點。弧的終點成爲新的當前點的路徑。*/

 

void CGContextAddArcToPoint(CGContextRef__nullable c, CGFloat x1, CGFloat y1, CGFloat x2, CGFloat y2, CGFloat radius) 

 

/*添加路徑到圖形上下文 */

 

void CGContextAddPath(CGContextRef__nullable c, CGPathRef__nullable path)

 

/** Path stroking. **/

 

/*  

 使用繪製當前路徑時覆蓋的區域做爲當前CGContextRef中的新路徑。舉例來講,假如當前CGContextRef包含一個圓形路徑且線寬爲10,調用該方法後,當前CGContextRef將包含一個環寬爲10的環形路徑*/

void CGContextReplacePathWithStrokedPath(CGContextRef__nullable c)

 

/** Path information functions. **/

 

/* 表示目前的路徑是否包含任何的子路徑 */

bool CGContextIsPathEmpty(CGContextRef__nullable c)

 

/* 返回一個非空的路徑中的當前點。 */

CGPoint CGContextGetPathCurrentPoint(CGContextRef__nullable c)

 

/* 返回包含當前路徑的最小矩形。*/

CGRect CGContextGetPathBoundingBox(CGContextRef__nullable c)

 

/* Return a copy of the path of `context'. The returned path is specified in

   the current user space of `context'. */

 

CGPathRef __nullableCGContextCopyPath(CGContextRef__nullable c)

 

/* 檢查當前路徑中是否包含指定的點。 */

bool CGContextPathContainsPoint(CGContextRef__nullable c,

    CGPoint point, CGPathDrawingMode mode)

 

/** Path drawing functions. **/

 

typedef CF_ENUM (int32_t, CGPathDrawingMode) {

  kCGPathFill,//只有填充(非零纏繞數填充),不繪製邊框  如圖1

  kCGPathEOFill,//奇偶規則填充(多條路徑交叉時,奇數交叉填充,偶交叉不填充)如圖2

  kCGPathStroke,        // 只有邊框  如圖3

  kCGPathFillStroke,    // 既有邊框又有填充  如圖4

  kCGPathEOFillStroke   // 奇偶填充並繪製邊框  如圖5

};

圖1 圖2圖3圖4圖5 

/* 

 使用指定模式繪製當前CGContextRef中所包含的路徑。CGPathDrawingMode 屬性如上*/

 

void CGContextDrawPath(CGContextRef__nullable c, CGPathDrawingMode mode)

 

/** Path drawing convenience functions. **/

 

/* 

 填充該路徑包圍的區域*/

void CGContextFillPath(CGContextRef__nullable c)

 

/* 

 使用奇偶規則來填充該路徑包圍的區域。奇偶規則指:若是某個點被路徑包圍了奇數次,系統繪製該點;若是被路徑包圍了偶數次,系統不繪製*/

void CGContextEOFillPath(CGContextRef__nullable c)

 

/*  

 使用當前 CGContextRef設置的線寬繪製路徑*/

void CGContextStrokePath(CGContextRef__nullable c)

 

/* 

 填充rect表明的矩形*/

void CGContextFillRect(CGContextRef__nullable c, CGRect rect)

 

/*  

 填充多個矩形

*/

void CGContextFillRects(CGContextRef__nullable c,

    const CGRect * __nullable rects, size_t count)

 

/* 

 使用當前 CGContextRef設置的線寬繪製矩形框*/

void CGContextStrokeRect(CGContextRef__nullable c, CGRect rect)

 

/*  

 使用指定線寬繪製矩形框*/

void CGContextStrokeRectWithWidth(CGContextRef__nullable c,

    CGRect rect, CGFloat width)

 

/*

 擦除指定矩形區域上繪製的圖形*/

void CGContextClearRect(CGContextRef__nullable c, CGRect rect)

 

/* 

 填充rect矩形的內切橢圓區域*/

void CGContextFillEllipseInRect(CGContextRef__nullable c,

    CGRect rect)

 

/* 

 使用當前 CGContextRef設置的線寬繪製rect矩形的內切橢圓*/

void CGContextStrokeEllipseInRect(CGContextRef__nullable c, CGRect rect)

 

/* 

     CGContextBeginPath(context);

     for (k = 0; k < count; k += 2) {

       CGContextMoveToPoint(context, s[k].x, s[k].y);

       CGContextAddLineToPoint(context, s[k+1].x, s[k+1].y);

     }

     CGContextStrokePath(context); 

 使用當前 CGContextRef設置的線寬繪製多條線段。該方法須要傳入2N個CGPoint組成的數組,其中一、2個點組成第一條線段,三、4個點組成第2條線段,以此類推*/

void CGContextStrokeLineSegments(CGContextRef__nullable c,

    const CGPoint * __nullable points, size_t count)

 

/** Clipping functions. **/

 

/* 修改當前剪貼路徑,使用非零繞數規則。 */

void CGContextClip(CGContextRef__nullable c)

 

/* 修改當前剪貼路徑,使用奇偶規則。 */

void CGContextEOClip(CGContextRef__nullable c)

 

/*  剪切遮罩處理(針對圖片)*/

void CGContextClipToMask(CGContextRef__nullable c, CGRect rect, CGImageRef__nullable mask)

 

 

/* 獲取到了須要繪製的圖形上下文的位置與大小*/

 

CGRect CGContextGetClipBoundingBox(CGContextRef__nullable c)

 

 

/** Clipping convenience functions. **/

 

/* 剪切指定矩形區域外的部分. */

void CGContextClipToRect(CGContextRef__nullable c, CGRect rect)

 

 

/* 剪切指定多個矩形區域外的部分 */

void CGContextClipToRects(CGContextRef__nullable c,const CGRect *  rects, size_t count)

 

 

/** Primitive color functions. **/

 

/* 

 使用指定顏色來設置該CGContextRef的填充顏色*/

void CGContextSetFillColorWithColor(CGContextRef__nullable c,

    CGColorRef __nullable color)

 

/* 

 使用指定顏色來設置該CGContextRef的線條顏色*/

void CGContextSetStrokeColorWithColor(CGContextRef__nullable c,

    CGColorRef __nullable color)

 

/** Color space functions. **/

 

/* 顏色空間填充 */

void CGContextSetFillColorSpace(CGContextRef__nullable c, CGColorSpaceRef__nullable space)

 

/* 設置線框顏色空間 */

 

void CGContextSetStrokeColorSpace(CGContextRef__nullable c,

    CGColorSpaceRef __nullable space)

 

/** Color functions. **/

 

/* 設置填充顏色空間 CGFloat redColor[4] = {1.0,0,0,1.0};*/

void CGContextSetFillColor(CGContextRef__nullable c,const CGFloat *__nullable components(redColor))

 

/* 設置畫筆顏色 CGFloat redColor[4] = {1.0,0,0,1.0};*/

void CGContextSetStrokeColor(CGContextRef__nullable c,const CGFloat *__nullable components(redColor))

 

/** Pattern functions. **/

 

/* 

 設置該CGContextRef使用位圖填充*/

void CGContextSetFillPattern(CGContextRef__nullable c, CGPatternRef__nullable pattern,const CGFloat * __nullable components)

 

/* 

 設置該CGContextRef使用位圖繪製線條、邊框*/

void CGContextSetStrokePattern(CGContextRef__nullable c, CGPatternRef__nullable pattern,const CGFloat * __nullable components)

 

/*  

 設置該CGContextRef採用位圖填充的相位*/

void CGContextSetPatternPhase(CGContextRef__nullable c, CGSize phase)

 

/** Color convenience functions. **/

 

/* 

 使用灰色來設置該CGContextRef的填充顏色*/

void CGContextSetGrayFillColor(CGContextRef__nullable c,

    CGFloat gray, CGFloat alpha)

 

/*  

 使用灰色來設置該CGContextRef的線條顏色*/

void CGContextSetGrayStrokeColor(CGContextRef__nullable c,

    CGFloat gray, CGFloat alpha)

 

/*  

 使用RGB顏色模式來設置該CGContextRef的填充顏色*/

void CGContextSetRGBFillColor(CGContextRef__nullable c, CGFloat red,

    CGFloat green, CGFloat blue, CGFloat alpha)

 

/* 設置畫筆顏色 */

void CGContextSetRGBStrokeColor(CGContextRef__nullable c,

    CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)

 

/* 

 使用CMYK顏色模式來設置該CGContextRef的填充顏色*/

void CGContextSetCMYKFillColor(CGContextRef__nullable c,

    CGFloat cyan, CGFloat magenta, CGFloat yellow, CGFloat black, CGFloat alpha)

 

/* 

 使用CMYK顏色模式來設置該CGContextRef的線條顏色*/

void CGContextSetCMYKStrokeColor(CGContextRef__nullable c,

    CGFloat cyan, CGFloat magenta, CGFloat yellow, CGFloat black, CGFloat alpha)

 

/** Rendering intent. **/

 

/* 在當前圖形狀態設置渲染意向 */

void CGContextSetRenderingIntent(CGContextRef__nullable c,

    CGColorRenderingIntent intent)

 

/** Image functions. **/

 

/* 繪製圖像到圖形上下文中 */

void CGContextDrawImage(CGContextRef__nullable c, CGRect rect,

    CGImageRef __nullable image)

 

/* 重複繪製的圖像,擴展到提供的矩形,填補當前剪輯區域。 */

void CGContextDrawTiledImage(CGContextRef__nullable c, CGRect rect,

    CGImageRef __nullable image)

 

/* 

  獲取當前CGContextRef在放大圖片時的插值質量*/

CGInterpolationQuality CGContextGetInterpolationQuality(CGContextRef__nullable c)

 

/* 

  設置圖形上下文的插值質量水平。*/

void CGContextSetInterpolationQuality(CGContextRef__nullable c,

    CGInterpolationQuality quality)

 

/** Shadow support. **/

 

/*  

 設置陰影在X、Y方向上的偏移,以及模糊度和陰影的顏色

*/

void CGContextSetShadowWithColor(CGContextRef__nullable c,

    CGSize offset, CGFloat blur, CGColorRef __nullable color)

 

 

/*  

 設置陰影在X、Y方向上的偏移,以及模糊度(blur值越大,陰影越模糊)。該函數沒有設置陰影顏色,

默認使用1/3透明的黑色(即RGBA{0, 0, 0, 1.0/3.0})做爲陰影顏色

*/

 

void CGContextSetShadow(CGContextRef__nullable c, CGSize offset,

    CGFloat blur)

 

 

/** Gradient and shading functions. **/

 

/* 繪製一個漸變填充定義的出發點和落腳點沿線變化。*/

void CGContextDrawLinearGradient(CGContextRef__nullable c,

    CGGradientRef __nullable gradient, CGPoint startPoint, CGPoint endPoint,

    CGGradientDrawingOptions options)

 

 

/* 繪製一個沿着由所提供的開始和結束的圓限定的區域變化的漸變填充。 */

void CGContextDrawRadialGradient(CGContextRef__nullable c,

    CGGradientRef __nullable gradient, CGPoint startCenter, CGFloat startRadius,

    CGPoint endCenter, CGFloat endRadius, CGGradientDrawingOptions options)

 

 

/* 使用指定的陰影的背景,填充剪切路徑。 */

void CGContextDrawShading(CGContextRef __nullable c,

    __nullable CGShadingRef shading)

 

 

/** Text functions. **/

 

/* 設置當前字符間距. */

void CGContextSetCharacterSpacing(CGContextRef__nullable c,

    CGFloat spacing)

 

 

/* 設置要繪製文本的位置。 */

void CGContextSetTextPosition(CGContextRef__nullable c,

    CGFloat x, CGFloat y)

 

 

/* 返回在繪製文本的位置。 */

CGPoint CGContextGetTextPosition(CGContextRef __nullable c)

 

 

/* 設置當前文本矩陣。 */

void CGContextSetTextMatrix(CGContextRef__nullable c,

    CGAffineTransform t)

 

/* 返回當前文本矩陣。 */

CGAffineTransform CGContextGetTextMatrix(CGContextRef__nullable c)

 

/* 設置當前文本的繪圖模式。 */

void CGContextSetTextDrawingMode(CGContextRef__nullable c,

    CGTextDrawingMode mode)

 

/* 設置上下文的字體 */

void CGContextSetFont(CGContextRef__nullable c,

    CGFontRef __nullable font)

 

/* 設置上下文的字體大小。 */

void CGContextSetFontSize(CGContextRef__nullable c, CGFloat size)

 

 

/* 在所提供的位置繪製字形。 */

void CGContextShowGlyphsAtPositions(CGContextRef__nullable c,

    const CGGlyph * __nullable glyphs, const CGPoint * __nullable Lpositions,

    size_t count)

 

 

/** PDF functions. **/

 

/* 繪製一個PDF頁面到當前的用戶空間。 */

void CGContextDrawPDFPage(CGContextRef__nullable c,

    CGPDFPageRef __nullable page)

 

 

/** Output page functions. **/

 

/* 基於頁面的圖形上下文中開始了新的一頁。 */

void CGContextBeginPage(CGContextRef__nullable c,const CGRect *__nullable mediaBox)

 

 

/* 在基於頁面的圖形上下文結束當前的頁面。 */

void CGContextEndPage(CGContextRef__nullable c)

 

 

/** Context functions. **/

 

/* 圖形上下文的引用計數+1 */

CGContextRef __nullableCGContextRetain(CGContextRef__nullable c)

 

 

/* 圖形上下文的引用計數-1. */

void CGContextRelease(CGContextRef__nullable c)

 

 

/* 強制全部掛起的繪圖操做在一個窗口上下文中當即被渲染到目標設備 */

void CGContextFlush(CGContextRef__nullable c)

 

 

/* 將一個窗口的圖像上下文內容更新,即全部的繪圖操做都會在下次同步到窗口上. */

void CGContextSynchronize(CGContextRef__nullable c)

 

 

/** Antialiasing functions. **/

 

/*  

 設置該CGContextRef是否應該抗鋸齒(即光滑圖形曲線邊緣)*/

void CGContextSetShouldAntialias(CGContextRef__nullable c,

    bool shouldAntialias)

 

/* 

 設置該CGContextRef是否容許抗鋸齒*/

void CGContextSetAllowsAntialiasing(CGContextRef__nullable c,

    bool allowsAntialiasing)

 

/** Font display functions. **/

 

/*  

 設置該CGContextRef是否容許光滑字體*/

void CGContextSetShouldSmoothFonts(CGContextRef__nullable c,

    bool shouldSmoothFonts)

 

/* 

 設置該CGContextRef是否容許光滑字體*/

void CGContextSetAllowsFontSmoothing(CGContextRef__nullable c,

    bool allowsFontSmoothing)

 

// Enables or disables subpixel positioning in a graphics context.

void CGContextSetShouldSubpixelPositionFonts(

    CGContextRef __nullable c, bool shouldSubpixelPositionFonts)

 

 

// Sets whether or not to allow subpixel positioning for a graphics context

void CGContextSetAllowsFontSubpixelPositioning(

    CGContextRef __nullable c, bool allowsFontSubpixelPositioning)

 

 

// Enables or disables subpixel quantization in a graphics context.

void CGContextSetShouldSubpixelQuantizeFonts(

    CGContextRef __nullable c, bool shouldSubpixelQuantizeFonts)

 

 

// Sets whether or not to allow subpixel quantization for a graphics context

void CGContextSetAllowsFontSubpixelQuantization(

    CGContextRef __nullable c, bool allowsFontSubpixelQuantization)

 

 

/** Transparency layer support. **/

 

/* 開始一個透明層。

 直到相應的調用CGContextEndTransparencyLayer,在指定範圍內的全部後續繪製操做組合到一個徹底透明的背景(它被視爲一個單獨的目標緩衝區從上下文)。

 

在透明層中繪製須要三步:

 1.  調用函數 CGContextBeginTransparencyLayer

 2.  在透明層中繪製須要組合的對象

 3.  調用函數 CGContextEndTransparencyLayer*/

void CGContextBeginTransparencyLayer(CGContextRef__nullable c,

    CFDictionaryRef __nullable auxiliaryInfo)

 

 

/* 開始透明度層,它的邊界是指定的矩形,其內容是有界的。 */

void CGContextBeginTransparencyLayerWithRect(

    CGContextRef __nullable c, CGRect rect, CFDictionaryRef__nullable auxInfo)

 

 

/* 結束一個透明層。 */

void CGContextEndTransparencyLayer(CGContextRef__nullable c)

 

/** User space to device space tranformations. **/

 

/*  獲取Quartz轉換用戶空間和設備空間的仿射變換 */

CGAffineTransform CGContextGetUserSpaceToDeviceSpaceTransform(CGContextRef__nullable c)

 

/*———— 點 ————*/

/* 將一個CGPoint數據結構從一個空間變換到另外一個空間(DeviceSpace). */

CGPoint CGContextConvertPointToDeviceSpace(CGContextRef__nullable c,

    CGPoint point)

 

/* 將一個CGPoint數據結構從一個空間變換到另外一個空間(UserSpace). */

CGPoint CGContextConvertPointToUserSpace(CGContextRef__nullable c,

    CGPoint point)

 

/*———— 大小 ————*/

/* 將一個CGSize數據結構從一個空間變換到另外一個空間(DeviceSpace). */

CGSize CGContextConvertSizeToDeviceSpace(CGContextRef__nullable c, CGSize size)

 

 

/* 將一個CGSize數據結構從一個空間變換到另外一個空間(UserSpace). */

CGSize CGContextConvertSizeToUserSpace(CGContextRef__nullable c, CGSize size)

 

 

/*———— 矩形 ————*/

/* 將一個CGPoint數據結構從一個空間變換到另外一個空間(DeviceSpace)。 */

 

CGRect CGContextConvertRectToDeviceSpace(CGContextRef__nullable c,

    CGRect rect)

 

/* 將一個CGPoint數據結構從一個空間變換到另外一個空間(UserSpace)。 */

CGRect CGContextConvertRectToUserSpace(CGContextRef__nullable c,

    CGRect rect)

 

 

/** Deprecated functions. **/

DEPRECATED…

/* 設置在一個圖形上下文的字體和字體大小 */

void CGContextSelectFont(CGContextRef__nullable c,

    const char *__nullable name, CGFloat size, CGTextEncoding textEncoding)

 

/* 在當前文本位置,由目前的文本矩陣指定的點顯示一個字符數組。 */

void CGContextShowText(CGContextRef__nullable c,

    const char *__nullable string, size_t length)

 

/* 在指定的位置顯示一個字符串。 */

void CGContextShowTextAtPoint(CGContextRef__nullable c,

    CGFloat x, CGFloat y, const char * __nullable string, size_t length)

 

/* 在當前文本位置顯示一個數組的字形。 */

void CGContextShowGlyphs(CGContextRef__nullable c,

    const CGGlyph * __nullable g, size_t count)

 

/* 在指定的位置顯示一個數組的字形。 */

void CGContextShowGlyphsAtPoint(CGContextRef__nullable c, CGFloat x,

    CGFloat y, const CGGlyph * __nullable glyphs, size_t count)

 

/* 繪製具備不一樣的偏移量的一個數組字形。 */

void CGContextShowGlyphsWithAdvances(CGContextRef__nullable c,

    const CGGlyph * __nullable glyphs, const CGSize * __nullable advances,

    size_t count)

 

/* DEPRECATED; use the CGPDFPage API instead. */

void CGContextDrawPDFDocument(CGContextRef__nullable c, CGRect rect, CGPDFDocumentRef__nullable document,int page)

DEPRECATED…

相關文章
相關標籤/搜索