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
context
The 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
x1
A double value that represents the X-coordinate of the point where the line starts.
y1
A double value that represents the Y-coordinate of the point where the line starts.
x2
A double value that represents the X-coordinate of the point where the line ends.
y2
A 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
x
A double value that indicates the X-coordinate of the ellipse center.
y
A double value that indicates the Y-coordinate of the ellipse center.
width
A double value that indicates the width of the ellipse.
height
A 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
rect
The Rectangle where the arc will be drawn.
start
A double value that specifies the start angle of the arc.
sweep
A 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
rect
A 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
x
The X-coordinate of the rectangle’s top left corner.
y
The Y-coordinate of the rectangle’s top left corner.
width
The width of the rectangle.
height
The height of the rectangle.
-
Strokes e.g. draws the outlining of the specified Rectangle.
Declaration
Swift
open func strokeRect(_ rect: Rect)
Parameters
rect
A 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
x
The X-coordinate of the rectangle’s top left corner.
y
The Y-coordinate of the rectangle’s top left corner.
width
The width of the rectangle.
height
The 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
rect
A 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
text
A string with the text to draw.
rect
The layout rectangle of the text.
ha
The horizontal alignment of the text.
va
The vertical alignment of the text.
bold
A bool value, which indicates if the text should be drawn bold.
italic
A bool value, which indicates if the text should be drawn bold.
underline
A 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) -> CGFloat
Parameters
frame
A 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) -> CGFloat
Parameters
frame
A 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
text
The text to draw.
point
The 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
point
The 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
x
A double value that specifies the X-coordinate of the translation.
y
A 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
s
A 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
angle
A 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
fontName
A string that specifies the name of the font.
fontSize
A double value that specifies the size of the font.
fontUnit
A 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
thickness
A 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
lengths
Array 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