I don't see a lot here on this topic. Perhaps it's a bit "forgotten" or maybe not that useful to most people. This example is a bit silly but it might be enough to get you started using GDI Paths for a certain kind of graphics effects.
Image may be NSFW.
Clik here to view.![Name: sshot.png
Views: 64
Size: 1.5 KB]()
Run it to see the effect animation.
Code:
Option Explicit
Private Const OUTPUT_TEXT As String = "Some Text"
Private Declare Function AbortPath Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function BeginPath Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hDC As Long) As Long
Private Enum CombineRgnStyles
RGN_AND = 1 'The new clipping region includes the intersection (overlapping areas)
'of the current clipping region and the current path.
RGN_OR = 2 'The new clipping region includes the union (combined areas) of the
'current clipping region and the current path.
RGN_XOR = 3 'The new clipping region includes the union of the current clipping
'region and the current path but without the overlapping areas.
RGN_DIFF = 4 'The new clipping region includes the areas of the current clipping
'region with those of the current path excluded.
RGN_COPY = 5 'The new clipping region is the current path.
End Enum
Private Declare Function SelectClipPath Lib "gdi32" ( _
ByVal hDC As Long, _
ByVal Mode As CombineRgnStyles) As Long
Private Sub Paint()
Static TickTock As Integer
Dim N As Single
If TickTock = 0 Then ForeColor = vbYellow Else ForeColor = vbRed
For N = 0 To ScaleHeight Step 12
Line (0, N)-(ScaleWidth, N)
Next
If TickTock = 1 Then ForeColor = vbYellow Else ForeColor = vbRed
For N = 4 To ScaleHeight Step 12
Line (0, N)-(ScaleWidth, N)
Next
If TickTock = 2 Then ForeColor = vbYellow Else ForeColor = vbRed
For N = 8 To ScaleHeight Step 12
Line (0, N)-(ScaleWidth, N)
Next
TickTock = (TickTock + 1) Mod 3
End Sub
Private Sub Form_Load()
AutoRedraw = True
BeginPath hDC
Circle (40, 30), 20
Circle (150, 35), 10
Circle (250, 20), 5
CurrentX = (ScaleWidth - TextWidth(OUTPUT_TEXT)) / 2
CurrentY = (ScaleHeight - 1.25 * TextHeight(OUTPUT_TEXT)) / 2
Print OUTPUT_TEXT;
Circle (260, 140), 15
Circle (75, 160), 10
Circle (200, 180), 5
EndPath hDC
SelectClipPath hDC, RGN_COPY
DrawWidth = 4
Paint
Timer1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
AbortPath hDC
End Sub
Private Sub Timer1_Timer()
Paint
End Sub
Clik here to view.
Run it to see the effect animation.