Private i As Long, j As Long, R As Double, A As Double, Tplt As cCairoPath Private CC As cCairoContext, Patterns As cCollection, Pat As cCairoPattern Sub Form_Load() Const TS = 400, TOf = 15 Set CC = New_c.Cairo.CreateSurface(5 * TOf + 4 * TS, 3 * TOf + 2 * TS).CreateContext CC.Paint , New_c.Cairo.CreateSolidPatternLng(vbWhite) Set Patterns = New_c.Collection(True) AddTriWingPat "TriWing1" 'use the default-params AddTriWingPat "TriWing2", 1.5, 90, 1.2, 0.3 AddTriWingPat "TriWing3", 2, 0, 1.3, 1.06 AddTriWingPat "TriWing4", 4, 25, 2, 1.5 AddArrWingPat "ArrWing1" 'use the default-params AddArrWingPat "ArrWing2", 0.25, 45, 0.6, 2.2 AddArrWingPat "ArrWing3", 1.5, 45, 2, 2.5 AddArrWingPat "ArrWing4", 2.5, 0, 4.5, 4.5 For i = 0 To 7 CC.Rectangle (i Mod 4 + 1) * TOf + (i Mod 4) * TS, IIf(i < 4, TOf, 2 * TOf + TS), TS, TS CC.Fill , Patterns.ItemByIndex(i) Next i Set Picture = CC.Surface.Picture CC.Surface.WriteContentToPngFile Environ("temp") & "\AlhambraTiles.png" End Sub Sub AddTriWingPat(Key, Optional Zoom = 1, Optional Tilt = 0, Optional F1 = 0.5, Optional F2 = 0.5) Const W = 30, H = 26 CC.PushGroup , 0, 0, 2 * W * Zoom, 2 * H * Zoom CC.ScaleDrawings Zoom, Zoom CC.RotateDrawingsDeg -90 CC.TranslateDrawings -8, 0 CC.MoveTo 0, 0 For i = 0 To 2 CC.CurveTo -F1 * W, -F2 * W, F1 * W, (F2 - 1) * W, 0, -W CC.TranslateDrawings 0, -W CC.RotateDrawingsDeg 360 / 3 Next i Set Tplt = CC.CopyPath: CC.ClearPath 'store the Wings in a Path For j = 0 To 3: For i = 0 To 3 + j If i = 0 And j > 0 Then CC.TranslateDrawings -H, -4.5 * W CC.AppendPath Tplt 'apply the above Path-Template CC.TranslateDrawings 0, W Next i, j CC.FillRule = CAIRO_FILL_RULE_EVEN_ODD CC.Fill , Cairo.CreateSolidPatternLng(vbBlack) Set Pat = CC.PopGroup(True, CAIRO_EXTEND_REPEAT) Set Pat.Matrix = Pat.Matrix.RotateCoordsDeg(Tilt) Patterns.Add Pat, Key End Sub Sub AddArrWingPat(Key, Optional Zoom = 1, Optional Tilt = 0, Optional AFac = 1, Optional RFac = 1) CC.PushGroup , 0, 0, 48 * Zoom, 48 * Zoom CC.ScaleDrawings Zoom, Zoom CC.TranslateDrawings 24, 24 'shift into the center of the PushGroup A = 0.5 * Atn(1) * AFac 'AFac influences the start-angle R = 12 * RFac 'RFac influences the Radius, RFac=4 equals TileSize For i = 0 To 1 CC.MoveTo IIf(i Mod 2, 24, -24), IIf(i Mod 2, 24, -24) A = A + 6 * Atn(1): CC.LineTo R * Cos(A), R * Sin(A) CC.LineTo 0, 0 A = A + 6 * Atn(1): CC.LineTo R * Cos(A), R * Sin(A) CC.LineTo IIf(i Mod 2, 24, -24), IIf(i Mod 2, -24, 24) Next i CC.FillRule = CAIRO_FILL_RULE_EVEN_ODD CC.Fill , Cairo.CreateSolidPatternLng(vbBlack) Set Pat = CC.PopGroup(True, CAIRO_EXTEND_REFLECT) Set Pat.Matrix = Pat.Matrix.RotateCoordsDeg(Tilt) Patterns.Add Pat, Key End Sub