User Tools

Site Tools


k25:k25.1.1:start

25.1.1 Class Cairo

The class Cairo of the component Cairo (gb.cairo) is used for drawing on an image (data type Image) or a surface (Surface).

  • Before you draw something, you must call the Begin(Device) method. As an argument, specify the surface on which you want to draw (Image, CairoPdfSurface, CairoPsSurface or CairoSvgSurface).
  • You can then use methods of the Cairo class to draw text or lines or to fill surfaces with different colours and patterns.
  • When the drawing is finished, call the End() method.

Example:

Private Sub GeneratePDF()
  Dim sPfadBildDatei As String
  Dim imgImage As Image  
  Dim PDFSurface As CairoPdfSurface
 
  sPfadBildDatei = Application.Path &/ "fractal.png"
  imgImage = Image.Load(sPfadBildDatei)  
  PDFSurface = New CairoPdfSurface(sPfadPDFDatei, 210, 297) ' -->> DIN A4 surface
 
  Cairo.Begin(PDFSurface)    
    Cairo.Matrix.Translate(MMToPoints(20), MMToPoints(20))
    Cairo.Matrix.Scale(1, 1) '-- Zoom-Factor = 1        
    Cairo.Arc(MMToPoints(80), MMToPoints(75), MMToPoints(70)) '-- Circle
    Cairo.Clip() '-- Clip-Method
    If Exist(sPfadBildDatei) Then
       Cairo.Source = Cairo.ImagePattern(imgImage, 0, 0)
       Cairo.Paint()
    Endif   
  Cairo.End
 
  PDFSurface.Finish()
  Desktop.Open(sPfadPDFDatei)
 
End

B1

Figure 25.1.1.1: Circular clip area with underlaid image

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.
k25/k25.1.1/start.txt · Last modified: by 127.0.0.1