CCairoContext

Contains all the functions and properties to draw elements into a cairo surface.

## Example

```
'First we need a Surface, which is a "physical thing" (a real Render-Target)

  Dim Srf As cCairoSurface

  'a Cairo-Image-Surface is something like an allocated InMemory-Bitmap (a hDIB)

  Set Srf = Cairo.CreateSurface(200, 100, ImageSurface)

  'Ok, now the drawing - to be able to do so, we need a Context first ...

  'and the CC below is something like an hDC in GDI, but ...

  Dim CC As cCairoContext

  'unlike in GDI, where we would "Select" a Bitmap into a hDC first...

  'with Cairo we can create such a CC "anytime" from any Surface

  'in a non-expensive Operation (this does not need larger CPU-cycles)

  Set CC = Srf.CreateContext

  'the following two lines ensure a complete Surface-Fill

  CC.SetSourceColor vbWhite

  CC.Paint

  'before our first rectangle, just a comment about Pixels and Scaling:

  'Cairos Image-Surfaces are "normal Bitmaps" - and in this example we've

  'created a 200x100 Pixel-Surface (with 32Bit ColorDepth) - the initial

  'x/y Scaling-Factors of a new created CairoContext (our CC) are 1 ...

  'and Scale 1 means, that the given Coords work "Pixelbased" (as in GDI)

  CC.Rectangle 10, 10, 180, 80

  'Oh, and the above line has not drawn anything to the Pixel-Surface yet,

  'it is only a Path-Definition ..., so if we want to Fill this Path, we

  'must tell it explicitely - first (yet before the Fill-Command), a Color:

  CC.SetSourceColor vbYellow

  CC.Fill '<-only now the Pixel within our Path are filled and the Surface-Content is changed

  'Ok, finally some Textoutput, otherwise it wouldn't be a Hello-World-Demo ;-)

  CC.SelectFont "Times New Roman", 25, vbRed

  CC.TextOut 25, 30, "Hello Cairo"

  'and this is our final "beam-up-into-the-Windows-World" ... if we want

  'the Cairo-PixelBuffers (the Surface-Contents) on our Windows-Screen,

  'we have to use the GDI finally - Srf.DrawToDC is internally (stretch-)blitting

  'our "Cairo-Pixels" and expects an hDC-Parameter for that

  Srf.DrawToDC hDC, 20, 20

```

## Methods

* Sub AppendPath(Path As cCairoPath)
* Sub ARC(xc As Double, yc As Double, Radius As Double, [angle1 As Double], [angle2 As Double = 6,28318530717959])
* Sub ArcNegative(xc As Double, yc As Double, Radius As Double, [angle1 As Double], [angle2 As Double = 6,28318530717959])
* Sub CalcTextRowsInfo(Text As String, AvailableWidth As Single, MultiLine As Boolean, OnlyOnLineBreaks As Boolean, RowsCharCount() As Long, RowsCharOffset() As Long, RowCount As Long, MaxRowExtents As Single)
* Sub ClearPath([CurrentPointOnly As Boolean])
* Sub Clip([PreservePath As Boolean])
* Sub ClipExplicit(X As Double, y As Double, Width As Double, Height As Double)
* Sub ClosePath()
* Sub ColorSplit(Color As Long, R As Double, G As Double, B As Double, [Shade As Double = 1], [lR As Long], [lG As Long], [LB As Long])
* Function CopyPath([AsFlatPath As Boolean], [FlatPrecision As Double = 0,1]) As cCairoPath
* Sub CurveTo(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, x3 As Double, y3 As Double)
* Sub DeviceToUserDistance(dx As Double, dy As Double)
* Sub DeviceToUserDistanceSingle(dx As Single, dy As Single)
* Sub DeviceToUserPoint(X As Double, y As Double)
* Sub DeviceToUserPointSingle(X As Single, y As Single)
* Sub DrawLine(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, [DrawInsideBounds As Boolean], [LineWidth As Double], [Color As Long = -1], [Alpha As Double = 1])
* Sub DrawRegularPolygon(cx As Double, cy As Double, R As Double, SideCount As Long, [BSplineInterpolation As SplineInterpolationEnm], [R\_Inner])
* Function DrawText(X As Double, y As Double, dx As Double, dy As Double, S As String, [SingleLine As Boolean], [Alignment As AlignmentConstants], [InnerSpace As Long], [VAlign As Long], [ExtendedFlags As DTExtFlagsEnm], [Alpha As Double = 1], [PathOnly As Boolean], [MaxDxNeeded As Double]) As Long
* Sub DrawTextCell(X As Double, y As Double, dx As Double, dy As Double, Text As String, [SingleLine As Boolean], [Alignment As AlignmentConstants], [InnerSpace As Double = 1], [FillColor As Long = 16777215], [GradientShade As Double], [LineColor As Long], [LineWidth As Double = 0,5])
* Sub Ellipse(X As Double, y As Double, Width As Double, Height As Double, [DrawInsideBounds As Boolean])
* Sub EllipticArcTo(rx As Double, ry As Double, xAxisRotDeg As Double, LargeArc As Boolean, Sweep As Boolean, X As Double, y As Double)
* Sub Fill([DontClosePath As Boolean], [Pattern As cCairoPattern])
* Function GetCharsFittingExtentPtr(pS As Long, CharCount As Long, Extent As Double) As Long
* Sub GetClipExtents(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double)
* Sub GetCurrentPoint(X As Double, y As Double)
* Sub GetCurrentPointSingle(X As Single, y As Single)
* Sub GetFillExtents(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double)
* Function GetFontHeight([TextHeight As Double]) As Double
* Function GetLineCap() As cairo\_line\_cap\_enm
* Function GetLineJoin() As cairo\_line\_join\_enm
* Function GetLineWidth() As Double
* Function GetMiterLimit() As Double
* Sub GetPathExtents(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double)
* Sub GetStrokeExtents(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double)
* Function GetTextExtentPtr(PText As Long, CharCount As Long) As Double
* Function GetTextExtents(Text As String, [FontHeight As Double = -1], [TextHeight As Double = -1]) As Double
* Function InFill(X As Double, y As Double) As Boolean
* Function InStroke(X As Double, y As Double) As Boolean
* Sub LineTo(X As Double, y As Double)
* Sub Mask(Pattern As cCairoPattern)
* Sub MaskSurface(Surface As cCairoSurface, [SrfX As Double], [SrfY As Double])
* Sub MatrixAddTransform(Matrix As cCairoMatrix)
* Function MatrixResetToIdentity() As cCairoMatrix
* Sub MoveTo(X As Double, y As Double)
* Sub Paint([Alpha As Double = 1], [Pattern As cCairoPattern])
* Sub Polygon(Points() As Double, [ClosePath As Boolean], [BSplineInterpolation As SplineInterpolationEnm], [BSplineClamp As Boolean], [MeetControlPoints As Boolean])
* Sub PolygonPtr(DoublePtr As Long, PairsCount As Long, [ClosePath As Boolean], [BSplineInterpolation As SplineInterpolationEnm], [BSplineClamp As Boolean], [MeetControlPoints As Boolean])
* Sub PolygonSingle(Points() As Single, [ClosePath As Boolean], [BSplineInterpolation As SplineInterpolationEnm], [BSplineClamp As Boolean], [MeetControlPoints As Boolean])
* Sub PolygonSinglePtr(SinglePtr As Long, PairsCount As Long, [ClosePath As Boolean], [BSplineInterpolation As SplineInterpolationEnm], [BSplineClamp As Boolean], [MeetControlPoints As Boolean])
* Function PopGroup([ResetClip As Boolean], [Extend As cairo\_extend\_enm = CAIRO\_EXTEND\_NONE]) As cCairoPattern
* Sub PushGroup([Content As cairo\_content\_enm = CAIRO\_CONTENT\_COLOR\_ALPHA], [ClipX As Double], [ClipY As Double], [ClipDX As Double], [ClipDY As Double])
* Sub Rectangle(X As Double, y As Double, Width As Double, Height As Double, [DrawInsideBounds As Boolean])
* Sub RelCurveTo(DX1 As Double, DY1 As Double, DX2 As Double, DY2 As Double, DX3 As Double, DY3 As Double)
* Sub RelEllipticArcTo(rx As Double, ry As Double, xAxisRotDeg As Double, LargeArc As Boolean, Sweep As Boolean, X As Double, y As Double)
* Sub RelLineTo(dx As Double, dy As Double)
* Sub RelMoveTo(dx As Double, dy As Double)
* Sub RenderSurfaceContent(SurfaceOrImageListKey, DstX As Double, DstY As Double, [DstDX As Double], [DstDY As Double], [Filter As cairo\_filter\_enm = CAIRO\_FILTER\_GOOD], [Alpha As Double = 1], [KeepAspectRatio As Boolean])
* Sub RenderSurfaceWithinCorners(SurfaceOrImageListKey, X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, x3 As Double, y3 As Double, X4 As Double, Y4 As Double, [Alpha As Double = 1], [StepWidth As Double = 2], [StepOverlap As Double = 2,5])
* Sub ResetClip()
* Sub Restore()
* Sub RotateDrawings(Angle As Double)
* Sub RotateDrawingsDeg(Angle As Double)
* Sub RoundedRect(X As Double, y As Double, Width As Double, Height As Double, Radius As Double, [DrawInsideBounds As Boolean], [CornerMask As CornerMaskEnm = cmAll], [CornersOnly As Boolean])
* Sub Save()
* Sub ScaleDrawings(sX As Double, sY As Double)
* Sub SelectFont(Name As String, SIZE As Double, [TextColor As Long], [Bold As Boolean], [Italic As Boolean], [Underline As Boolean], [StrikeThrough As Boolean])
* Sub SetDashes(Offset As Double, ParamArray DashSequence() As Variant)
* Sub SetLineCap(LineCap As cairo\_line\_cap\_enm)
* Sub SetLineJoin(LineJoin As cairo\_line\_join\_enm)
* Sub SetLineWidth(LineWidth As Double, [RoundToFullPixels As Boolean])
* Sub SetMiterLimit(MiterLimit As Double)
* Sub SetSourceColor(Color As Long, [Alpha As Double = 1], [Shade As Double = 1])
* Sub SetSourcePattern(Pattern As cCairoPattern)
* Sub SetSourceRGB(R As Double, G As Double, B As Double)
* Sub SetSourceRGBA(R As Double, G As Double, B As Double, [A As Double = 1])
* Sub SetSourceSurface(Surface As cCairoSurface, [xOffs As Double], [yOffs As Double])
* Sub Stroke([DontClosePath As Boolean], [Pattern As cCairoPattern])
* Sub TextOut(X As Double, y As Double, Text As String, [BaseLine As Boolean], [Alpha As Double = 1], [PathOnly As Boolean])
* Sub TextOutPtr(X As Double, y As Double, PText As Long, CharCount As Long, [BaseLine As Boolean], [Alpha As Double = 1], [PathOnly As Boolean], [ShapeOnly As Boolean])
* Function ToBSTR(B() As Byte, [CodePage As MSCodePages = CP\_UTF8]) As String
* Sub TranslateDrawings(tX As Double, tY As Double)
* Sub TranslateOLEColor(Color As Long)
* Sub UserToDeviceDistance(dx As Double, dy As Double)
* Sub UserToDeviceDistanceSingle(dx As Single, dy As Single)
* Sub UserToDevicePoint(X As Double, y As Double)
* Sub UserToDevicePointSingle(X As Single, y As Single)

## Properties

* Property AntiAlias As cairo\_antialias\_enm
* Property FillRule As cairo\_fill\_rule\_enm
* Property hCR As Long

    read-only

* Property Matrix As cCairoMatrix
* Property Operator As cairo\_operator\_enm
* Property Surface As cCairoSurface

    read-only

* Property Tolerance As Double