Canvas
open class Canvas
Represents a class for drawing diagram items.
-
Creates a new Canvas from the specified context.
Declaration
Swift
public init(context: CGContext)Parameters
contextThe CGContext used by The canvas.
Return Value
The newly created Canvas instance.
-
Undocumented
Declaration
Swift
public init(unit: MeasureUnit) -
Draws a line between the two points specified with their X and Y coordinates.
Declaration
Swift
open func drawLine(_ x1: Double, y1: Double, x2: Double, y2: Double)Parameters
x1A double value that represents the X-coordinate of the point where the line starts.
y1A double value that represents the Y-coordinate of the point where the line starts.
x2A double value that represents the X-coordinate of the point where the line ends.
y2A double value that represents the Y-coordinate of the point where the line ends.
-
Draws an ellipse with the specified center, width and height.
Declaration
Swift
open func drawEllipse(_ x: Double, y: Double, width: Double, height: Double)Parameters
xA double value that indicates the X-coordinate of the ellipse center.
yA double value that indicates the Y-coordinate of the ellipse center.
widthA double value that indicates the width of the ellipse.
heightA double value that indicates the height of the ellipse.
-
Draws an arc in the specified rectangle from the given start and sweep angles.
Declaration
Swift
open func drawArc(_ rect: Rect, start: Double, sweep: Double)Parameters
rectThe Rectangle where the arc will be drawn.
startA double value that specifies the start angle of the arc.
sweepA double value that specifies the sweep angle of the arc.
-
Draws a Rectangle. with the specified coordinates.
Declaration
Swift
open func drawRect(_ rect: Rect)Parameters
rectA Rectangle that specifies the drawing coordinates.
-
Draws a rectangle at the specified location and with the specified width and height.
Declaration
Swift
open func drawRect(_ x: Double, y: Double, width: Double, height: Double)Parameters
xThe X-coordinate of the rectangle’s top left corner.
yThe Y-coordinate of the rectangle’s top left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.
-
Strokes e.g. draws the outlining of the specified Rectangle.
Declaration
Swift
open func strokeRect(_ rect: Rect)Parameters
rectA Rectangle that specifies the drawing coordinates.
-
Strokes e.g. draws only the outlining of the rectangle at the specified location and with the specified width and height.
Declaration
Swift
open func strokeRect(_ x: Double, y: Double, width: Double, height: Double)Parameters
xThe X-coordinate of the rectangle’s top left corner.
yThe Y-coordinate of the rectangle’s top left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.
-
Fills e.g. draws the interior and not the border of the specified Rectangle.
Declaration
Swift
open func fillRect(_ rect: Rect)Parameters
rectA Rectangle that specifies the drawing coordinates.
-
Draws a text with the specified arguments.
Declaration
Swift
open func drawText ( _ text: String, rect: Rect, ha: HorizontalAlignment = HorizontalAlignment.left, va: VerticalAlignment = VerticalAlignment.top, bold: Bool = false, italic: Bool = false, underline: Bool = false)Parameters
textA string with the text to draw.
rectThe layout rectangle of the text.
haThe horizontal alignment of the text.
vaThe vertical alignment of the text.
boldA bool value, which indicates if the text should be drawn bold.
italicA bool value, which indicates if the text should be drawn bold.
underlineA bool value, which indicates if the text should be drawn underlined.
-
Measures the height of the specified frame.
Declaration
Swift
open func measureFrameHeight(_ frame: CTFrame) -> CGFloatParameters
frameA CTFrameRef object that provides the frame to measure.
Return Value
A CGFloat value that represents the height of the frame.
-
Measures the width of the specified frame.
Declaration
Swift
open func measureFrameWidth(_ frame: CTFrame) -> CGFloatParameters
frameA CTFrameRef object that provides the frame to measure.
Return Value
A CGFloat value that represents the width of the frame.
-
Draws the specified text at the specified location.
Declaration
Swift
open func drawText(_ text: String, point: Point)Parameters
textThe text to draw.
pointThe top left corner of the rectangle that contains the specified text.
-
Starts a path from the current CGContext to infinity.
Declaration
Swift
open func pathStart() -
Closes the current CGContext path.
Declaration
Swift
open func pathCloseFigure() -
Moves the points in the current pathMatrix with the specified point.
Declaration
Swift
open func pathMoveTo(_ point: Point)Parameters
pointThe Point whose coordinates are used for correction of the coordinates of the pathMatrix.
-
Draws a Bezier curve from the end of the parh through the points provided as parameters.
-
Draws the specified GraphicsPath.
Declaration
Swift
open func drawPath(_ path: GraphicsPath) -
Draws the path of the current CGContext.
Declaration
Swift
open func pathDraw() -
Draws the outlining of the path of the current CGContext.
Declaration
Swift
open func pathStroke() -
Draws the specified image in the specified rectangle and with the specified alignment.
Declaration
Swift
open func drawImage(_ image: UIImage!, rect: Rect, align: ImageAlign) -
Translates the current CGContext with the specified X and Y values.
Declaration
Swift
open func translateTransform(_ x: Double, y: Double)Parameters
xA double value that specifies the X-coordinate of the translation.
yA double value that specifies the Y-coordinate of the translation.
-
Scales the current CGContext with the specified amount.
Declaration
Swift
open func scaleTransform(_ s: Double)Parameters
sA double value that specifies the scale’s value.
-
Undocumented
Declaration
Swift
open func scaleAtCenter(sx: Double, sy: Double, rect: Rect) -
Rotates the current CGContext with the specified angle.
Declaration
Swift
open func rotateTransform(_ angle: Double)Parameters
angleA double value that specifies the angle of the rotation.
-
Saves the state of the current context.
Declaration
Swift
open func saveState() -
Restores the state of the current context.
Declaration
Swift
open func restoreState() -
Undocumented
Declaration
Swift
open func clipToPath(_ path: GraphicsPath) -
Sets the font for text drawn at this Canvas.
Declaration
Swift
open func setFont( _ fontName: String, fontSize: Double, fontUnit: MeasureUnit)Parameters
fontNameA string that specifies the name of the font.
fontSizeA double value that specifies the size of the font.
fontUnitA MeasureUnit that specifies how font is measured.
-
Defines a variable that keeps information about the MeasureUnit used by The canvas.
Declaration
Swift
open var measureUnit: MeasureUnit { get set } -
Sets the thickness of the stroke.
Declaration
Swift
public func setStrokeThickness(_ thickness: Double)Parameters
thicknessA double value that specifies the thickness of the stroke of objects drawn in this canvas.
-
Sets the dash style for lines drawn in this canvas.
Declaration
Swift
open func setLineDashStyle(_ lengths: [Float])Parameters
lengthsArray with float values that specify the dash pattern for lines drawn in this canvas.
-
The CGContext used by this canvas.
Declaration
Swift
open var context: CGContext -
The name of the font used when text is drawn in this canvas.
Declaration
Swift
open var fontName: String -
The size of the text drawn in this canvas.
Declaration
Swift
open var fontSize: Double
Canvas Class Reference