【Swift】CoreGraphics0->1
Core Graphics
Harness the power of Quartz technology to perform lightweight 2D rendering with high-fidelity output. Handle path-based drawing, antialiased rendering, gradients, images, color management, PDF documents, and more
Quartzテクノロジーの力を利用して、高忠実度の出力で軽量の2Dレンダリングを実行します。 パスベースの描画、アンチエイリアスレンダリング、グラデーション、画像、カラーマネジメント、PDFドキュメントなどを処理します
Core Graphicsフレームワークは、Quartzの高度な描画エンジンに基づいています。 比類のない出力忠実度を備えた低レベルで軽量の2Dレンダリングを提供します。 このフレームワークを使用して、パスベースの描画、変換、カラーマネジメント、オフスクリーンレンダリング、パターン、グラデーションとシェーディング、画像データ管理、画像作成、画像マスキング、およびPDFドキュメントの作成、表示、解析を処理します。
macOSでは、Core Graphicsには、ディスプレイハードウェア、低レベルのユーザー入力イベント、およびウィンドウシステムを操作するためのサービスも含まれています。
Geometric Data Types
struct CGFloat
CoreGraphicsおよび関連するフレームワークの浮動小数点スカラー値の基本型。
The basic type for floating-point scalar values in Core Graphics and related frameworks.
struct CGPoint
2次元座標系の点を含む構造。
A structure that contains a point in a two-dimensional coordinate system.
struct CGSize
幅と高さの値を含む構造。
A structure that contains width and height values.
struct CGRect
長方形の位置と寸法を含む構造。
A structure that contains the location and dimensions of a rectangle.
struct CGVector
2次元ベクトルを含む構造。
A structure that contains a two-dimensional vector.
struct CGAffineTransform
2Dグラフィックスの描画に使用するアフィン変換行列。
An affine transformation matrix for use in drawing 2D graphics.
2D Drawing
class CGContext
Quartz2D描画環境。
A Quartz 2D drawing environment.
CGContextタイプは、Quartz2Dの描画先を表します。 グラフィックスコンテキストには、描画パラメータと、宛先がアプリケーションのウィンドウ、ビットマップイメージ、PDFドキュメント、またはプリンタであるかどうかに関係なく、ページ上のペイントを宛先にレンダリングするために必要なすべてのデバイス固有の情報が含まれます。
class CGImage
ビットマップ画像または画像マスク。
A bitmap image or image mask.
class CGPath
不変のグラフィックパス:グラフィックコンテキストで描画される形状または線の数学的記述。
An immutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.
class CGMutablePath
可変グラフィックスパス:グラフィックスコンテキストで描画される形状または線の数学的記述。
A mutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.
class CGLayer
CoreGraphicsで描画されたコンテンツを再利用するためのオフスクリーンコンテキスト。
An offscreen context for reusing content drawn with Core Graphics.
CGContext
Constructing a Current Graphics Path
func beginPath()
Creates a new empty path in a graphics context.
func move(to: CGPoint)
Begins a new subpath at the specified point.
func addLine(to: CGPoint)
Appends a straight line segment from the current point to the specified point.
func addLines(between: [CGPoint])
Adds a sequence of connected straight-line segments to the current path.
func addRect(CGRect)
Adds a rectangular path to the current path.
func addRects([CGRect])
Adds a set of rectangular paths to the current path.
func addEllipse(in: CGRect)
Adds an ellipse that fits inside the specified rectangle.
func addArc(center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
Adds an arc of a circle to the current path, specified with a radius and angles.
func addArc(tangent1End: CGPoint, tangent2End: CGPoint, radius: CGFloat)
Adds an arc of a circle to the current path, specified with a radius and two tangent lines.
func addCurve(to: CGPoint, control1: CGPoint, control2: CGPoint)
Adds a cubic Bézier curve to the current path, with the specified end point and control points.
func addQuadCurve(to: CGPoint, control: CGPoint)
Adds a quadratic Bézier curve to the current path, with the specified end point and control point.
func addPath(CGPath)
Adds a previously created path object to the current path in a graphics context.
func closePath()
Closes and terminates the current path’s subpath.
var path: CGPath?
Returns a path object built from the current path information in a graphics context.
func replacePathWithStrokedPath()
Replaces the path in the graphics context with the stroked version of the path.
Drawing Images and PDF Content
func draw(CGImage, in: CGRect, byTiling: Bool)
指定した領域に画像を描画します。
Draws an image in the specified area.
func drawPDFPage(CGPDFPage)
PDFページのコンテンツを現在のグラフィックスコンテキストに描画します。
Draws the content of a PDF page into the current graphics context.
var interpolationQuality: CGInterpolationQuality
グラフィックスコンテキストの補間品質の現在のレベルを返します。
Returns the current level of interpolation quality for a graphics context.
補間品質は、画像の補間に使用する品質レベルのヒントを提供するグラフィックス状態パラメーターです(たとえば、画像をスケーリングする場合)。 すべてのコンテキストがすべての補間品質レベルをサポートしているわけではありません。
enum CGInterpolationQuality
画像をレンダリングするための補間品質のレベル。
Levels of interpolation quality for rendering an image.