Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleDraw an eight-way symmetric picture
Keywordssymmetry, symmetric picture
CategoriesGraphics
 
Thanks to Sergio Perciballi (oigres@postmaster.co.uk).

As the user draws, reproduce the drawing reflected eight ways.

 
Private Sub Form_MouseDown(Button As Integer, shift As _
    Integer, x As Single, y As Single)
    If Button = vbLeftButton Then
        bmousedown = True
        'drawSymmetry x, y
    End If
    If Button = vbRightButton Then
        putsymmetry x, y, shift

    End If
End Sub

Private Sub Form_MouseMove(Button As Integer, shift As _
    Integer, x As Single, y As Single)
    Static lastx
    Static lasty
    Static lastp(15)
    Dim v As Long
    If bmousedown = True Then
       
        'topleft
        Form1.Line (lastp(0), lastp(1))-(cx - (x - cx), cy _
            - (y - cy)), clrArray(0)
        Form1.Line (lastp(10), lastp(11))-(cx - (y - cy), _
            cy - (x - cx)), clrArray(4) 'vbCyan
        'topright
        Form1.Line (lastp(8), lastp(9))-(y + 10, cy - (x - _
            cx)), clrArray(1) 'RGB(127, 127, 250)
        Form1.Line (lastp(14), lastp(15))-(cy + (x - cx) + _
            10, cx - (y - cy) - 10), clrArray(5) 'RGB(128,
            ' 128, 100)
        'bottom left
        Form1.Line (lastp(2), lastp(3))-(cx - (x - cx), y), _
            clrArray(2)
        Form1.Line (lastp(6), lastp(7))-(cx - (y - cy), x - _
            10), clrArray(6)
        'bottom right
        Form1.Line (lastx, lasty)-(x, y), clrArray(3)
        Form1.Line (lastp(12), lastp(13))-(y + 10, x - 10), _
            clrArray(7) '&HFF00FF

    End If
    'vbred
    lastp(0) = cx - (x - cx)
    lastp(1) = cy - (y - cy)
    lastp(2) = cx - (x - cx)
    lastp(3) = y
    lastp(4) = x
    lastp(5) = cy - (y - cy)
    'reflected points; swapped x and y coords
    lastp(6) = cx - (y - cy)
    lastp(7) = x - 10
    lastp(8) = y + 10
    lastp(9) = cy - (x - cx)
    lastp(10) = cx - (y - cy)
    lastp(11) = cy - (x - cx)
    lastp(12) = y + 10
    lastp(13) = x - 10
    lastp(14) = cy + (x - cx) + 10
    lastp(15) = cx - (y - cy) - 10
    'black
    lastx = x
    lasty = y

End Sub

Private Sub Form_MouseUp(Button As Integer, shift As _
    Integer, x As Single, y As Single)
    bmousedown = False
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated