Da Gambas-it.org - Wikipedia.
|
|
(2 versioni intermedie di uno stesso utente non sono mostrate) |
Riga 1: |
Riga 1: |
− | Per disegnare su una ''DrawingArea'' con il mouse due o più linee in modo tale che, le linee precedentemente disegnate, restino visibili sulla ''DrawingArea'' ad ogni disegno di una nuova linea, potremo adottare un codice come il seguente: |[[#Note|1]]|
| + | #REDIRECT [[Disegnare_in_una_DrawingArea_più_linee_rette_con_il_mouse]] |
− | Private OldX As Single
| |
− | Private OldY As Single
| |
− | Private StartX As Single
| |
− | Private StartY As Single
| |
− | Private punti As New Integer[]
| |
− |
| |
− |
| |
− | '''Public''' Sub DrawingArea1_Draw()
| |
− |
| |
− | Dim i As Integer
| |
− |
| |
− | With Draw
| |
− | .Line(StartX, StartY, OldX, OldY)
| |
− | For i = 0 To punti.Count - 1 Step 4
| |
− | .Line(punti[i], punti[i + 1], punti[i + 2], punti[i + 3])
| |
− | Next
| |
− | .End
| |
− | End With
| |
− |
| |
− | '''End'''
| |
− |
| |
− |
| |
− | '''Public''' Sub DrawingArea1_MouseDown()
| |
− |
| |
− | StartX = Mouse.X
| |
− | StartY = Mouse.Y
| |
− | OldX = StartX
| |
− | OldY = StartY
| |
− |
| |
− | '''End'''
| |
− |
| |
− |
| |
− | '''Public''' Sub DrawingArea1_MouseMove()
| |
− |
| |
− | OldX = Mouse.X
| |
− | OldY = Mouse.Y
| |
− |
| |
− | DrawingArea1.Refresh()
| |
− |
| |
− | '''End'''
| |
− |
| |
− |
| |
− | '''Public''' Sub DrawingArea1_MouseUp()
| |
− |
| |
− | punti.Add(StartX)
| |
− | punti.Add(StartY)
| |
− | punti.Add(OldX)
| |
− | punti.Add(OldY)
| |
− |
| |
− | '''End'''
| |
− | | |
− | | |
− | | |
− | | |
− | =Note=
| |
− | [1] Il codice è stato realizzato dall'utente ''[http://www.gambas-it.org/smf/index.php?PHPSESSID=t7v51ptrf5rv5gbkuacmunsud4&action=profile;u=1249 Gianluigi]'' del forum ''gambas-it.org'' .
| |
Versione attuale delle 19:37, 28 nov 2020