Classes
The following classes are available globally.
-
Bitmap describes a two-dimensional raster pixel array. Bitmap is built on ImageInfo, containing integer width and height, ColorType and AlphaType describing the pixel format, and ColorSpace describing the range of colors. Bitmap points to PixelRef, which describes the physical array of pixels. ImageInfo bounds may be located anywhere fully inside PixelRef bounds.
Bitmap can be drawn using Canvas. Bitmap can be a drawing destination for Canvas draw member functions. Bitmap flexibility as a pixel container limits some optimizations available to the target platform.
If pixel array is primarily read-only, use Image for better performance. If pixel array is primarily written to, use Surface for better performance.
Bitmap is not thread safe. Each thread must have its own copy of Bitmap fields, although threads may share the underlying pixel array.
See moreDeclaration
Swift
public final class Bitmap
-
Canvas
provides an interface for drawing, and how the drawing is clipped and transformed.Canvas
contains a stack ofMatrix
and clip values.Canvas
andPaint
together provide the state to draw intoSurface
orBaseDevice
. EachCanvas
draw call transforms the geometry of the object by the concatenation of allMatrix
values in the stack. The transformed geometry is clipped by the intersection of all of clip values in the stack. TheCanvas
draw calls usePaint
to supply drawing state such as color,Typeface
, text size, stroke width,Shader
and so on.To draw to a pixel-based destination, create raster surface or GPU surface. Request
Canvas
fromSurface
to obtain the interface to draw.Canvas
generated by raster surface draws to memory visible to the CPU.Canvas
generated by GPU surface uses Vulkan or OpenGL to draw to the GPU.To draw to a document, obtain
Canvas
from SVG canvas, document PDF, orPictureRecorder
.Document
basedCanvas
and otherCanvas
subclasses referenceBaseDevice
describing the destination.Typically you create the Canvas from a bitmap, but an empty canvas can be created with the some fo the static
make
methods, and serve special purposes:makeEmpty(width:height)
- creates an empty canvas that ignores all drawing commandsmakeOverdraw(canvas:)
- A canvas that captures all drawing commands, and rather than draw the actual content, it increments the alpha channel of each pixel every time it would have been touched by a draw call.makeNway(width:height:)
- will create a passthrough n-way canvas. Once created you can add canvas withaddCanvas
, and remove them withremoveCanvas
Declaration
Swift
public final class Canvas
-
Undocumented
Declaration
Swift
public final class ColorFilter
-
Undocumented
See moreDeclaration
Swift
public final class ColorSpace
-
See moreSKData
holds an immutable data buffer. Not only is the data immutable, but the actual ptr that is returned (bydata
)) is guaranteed to always be the same for the life of this instance.Declaration
Swift
public final class SKData
-
Skia’s FontManager The default font manager can be accessed via the
See moredefault
static property ofFontManager
.Declaration
Swift
public final class FontManager
-
Represents a particular style (bold, italic, condensed) of a typeface.
See moreDeclaration
Swift
public final class FontStyle
-
Represets the set of styles for a particular font family.
See moreDeclaration
Swift
public final class FontStyleSet
-
Image
describes a two dimensional array of pixels to draw. The pixels may be decoded in a raster bitmap, encoded in aPicture
or compressed data stream, or located in GPU memory as a GPU texture.Image
cannot be modified after it is created.Image
may allocate additional storage as needed; for instance, an encodedImage
may decode when drawn.Image
width and height are greater than zero. Creating anImage
with zero width or height returnsImage
equal tonil
.
See moreImage
may be created fromBitmap
,Pixmap
,Surface
,Picture
, encoded streams, GPU texture, YUV_ColorSpace data, or hardware buffer. Encoded streams supported include BMP, GIF, HEIF, ICO, JPEG, PNG, WBMP, WebP. Supported encoding details vary with platform.Declaration
Swift
public final class Image
-
Undocumented
Declaration
Swift
public final class ImageFilter
-
Undocumented
Declaration
Swift
public final class MaskFilter
-
See morePaint
controls options applied when drawing.Paint
collects all options outside of theCanvas
clip andCanvas
matrix. Various options apply to strokes and fills, and images.Paint
collects effects and filters that describe single-pass and multiple-pass algorithms that alter the drawing geometry, color, and transparency. For instance,Paint
does not directly implement dashing or blur, but contains the objects that do so.Declaration
Swift
public final class Paint
-
Path
contain geometry.Path
may be empty, or contain one or more verbs that outline a figure.Path
always starts with a move verb to a Cartesian coordinate, and may be followed by additional verbs that add lines or curves. Adding a close verb makes the geometry into a continuous loop, a closed contour.Path
may contain any number of contours, each beginning with a move verb.Path
contours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers.Path
contours may be open or closed.When used to draw a filled area,
Path
describes whether the fill is inside or outside the geometry.Path
also describes the winding rule used to fill overlapping contours.The various commands that add to the path provide a fluid interface, meaning that calling the methods return the instance on which it was invoked, easily allowing the drawing operations to be concatenated.
See moreDeclaration
Swift
public final class Path
-
Undocumented
See moreDeclaration
Swift
public final class Picture
-
The picture recorder is used to record drawing operations made to a SKCanvas and stored in a SKPicture. call the
See morebeginRecording
method to start, issue your commands into the returnedCanvas
and then call theendRecording
method to get thePicture
that has the recording on it.Declaration
Swift
public final class PictureRecorder
-
Undocumented
See moreDeclaration
Swift
public final class Pixmap
-
See moreRegion
describes the set of pixels used to clipCanvas
.Region
is compact, efficiently storing a single integer rectangle, or a run length encoded array of rectangles.Region
may reduce the currentCanvas
clip, or may be drawn as one or more integer rectangles.Region
iterator returns the scan lines or rectangles contained by it, optionally intersecting a bounding rectangle.Declaration
Swift
public final class Region
-
Undocumented
See moreDeclaration
Swift
public final class RoundRect
-
Undocumented
Declaration
Swift
public class SKObject
-
bstraction for a source of bytes. Subclasses can be backed by memory, or a file, or something else.
Classic
streams
APIs are sort of async, in that on a request for N bytes, they may return fewer than N bytes on a given call, in which case the caller cantry again
to get more bytes, eventually (modulo an error) receiving their total N bytes.Skia streams behave differently. They are effectively synchronous, and will always return all N bytes of the request if possible. If they return fewer (the
See moreread
call returns the number of bytes read) then that means there is no more data (at EOF or hit an error). The caller should not call again in hopes of fulfilling more of the request.Declaration
Swift
public class SKStream
-
A reading stream that wraps a native file. To write use
See moreSKFileWStream
Declaration
Swift
public final class SKFileStream : SKStream
-
Undocumented
See moreDeclaration
Swift
public class SKWStream
-
Opens a write-only stream to the specified file. To read use
See moreSKFileStream
Declaration
Swift
public final class SKFileWStream : SKWStream
-
Shaders specify the source color(s) for what is being drawn. If a paint has no shader, then the paint’s color is used. If the paint has a shader, then the shader’s color(s) are use instead, but they are modulated by the paint’s alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency w/o having to modify the original shader… only the paint’s alpha needs to be modified.
Use any of the various static
See moremake
methods to create the shaderDeclaration
Swift
public final class Shader
-
Surface
is responsible for managing the pixels that a canvas draws into. The pixels can be allocated either in CPU memory (a raster surface) or on the GPU (a GrRenderTarget surface).Surface
takes care of allocating aCanvas
that will draw into the surface. Call surface->getCanvas() to use that canvas (but don’t delete it, it is owned by the surface).Surface
always has non-zero dimensions. If there is a request for a new surface, and either of the requested dimensions are zero, thennil
will be returned.Use one of the static
See moremake
methods to create instances ofSurface
Declaration
Swift
public final class Surface
-
Declaration
Swift
public final class TextBlobBuilder
-
The
Typeface
class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textskewX, textScaleX, FakeBoldText_Mask, to specify how text appears when drawn (and measured).Typeface objects are immutable, and so they can be shared between threads.
See moreDeclaration
Swift
public final class Typeface
-
Undocumented
See moreDeclaration
Swift
public class SkiaLayer : CALayer
-
SkiaView
is a UIView that you can add to your programs that can render some Skia content for you. To do this, create an instance of this class, and then set thedrawingCallback
property to point to a function that takes aSurface
and anImageInfo
as parameter, and this will be called when the view needs to render itself.You can set the
See moreignorePixelScaling
to ignore the built-in scaling that uses theUIView
‘scontentScaleFactor
Declaration
Swift
public class SkiaView : UIView