Disegnare in una DrawingArea una pseudo-galleria rettangolare tridimensionale in prospettiva con effetto grafico di movimento in avanti

Da Gambas-it.org - Wikipedia.

Disegniamo in una DrawingArea una pseudo-galleria rettangolare tridimensionale in prospettiva con effetto grafico di movimento di chi guarda in avanti, dando altresì l'impressione di percorrere tratti della galleria, ciascuno diversamente colorato rispetto al precedente:

Private DrawingArea1 As DrawingArea
Private c As Short = -1
Private clr As Integer = Color.Blue
Private vch As Integer = Color.Blue


Public Sub _new()
 
 With Me
   .Center
   .W = Screen.AvailableWidth
   .H = Screen.AvailableHeight
   .Arrangement = Arrange.Fill
 End With
 
 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
   .Background = Color.White
 End With
 
End

Public Sub Form_Open()

 Me.Show

 Do
   Inc c
   Wait 0.3
   If Object.IsValid(DrawingArea1) Then 
     DrawingArea1.Refresh
   Else 
     Break
   Endif
 Loop

End

Public Sub DrawingArea1_Draw()

 Dim b As Byte

' Definisce il rettangolo per disegnare la iniziale pseudo-galleria in 3D:
 For b = c + 1 To 20
   With Paint
     .Rectangle((DrawingArea1.W * 0.5) - ((DrawingArea1.W * (b / 20)) / 2), ((DrawingArea1.H * 0.5) - (DrawingArea1.H * (b / 20)) / 2), DrawingArea1.W * (b / 20), DrawingArea1.H * (b / 20))
     .LineWidth = 2.5
     .Brush = Paint.Color(vch)
     .Stroke()
   End With
 Next 

' Definisce il rettangolo per disegnare la nuova pseudo-galleria con un colore diverso:
 If c == 0 Then clr = Rand(&000099, &FFFF99)
 For b = 0 To c
   With Paint
     .Rectangle((DrawingArea1.W * 0.5) - ((DrawingArea1.W * (b / 20)) / 2), ((DrawingArea1.H * 0.5) - (DrawingArea1.H * (b / 20)) / 2), DrawingArea1.W * (b / 20), DrawingArea1.H * (b / 20))
     .LineWidth = 2.5
     .Brush = Paint.Color(clr)
     .Stroke()
   End With
 Next 

 If c = 20 Then
   Paint.End()
   c = 0
   vch = clr
   clr = Rand(&000099, &FFFF99)
 Endif 

End

o anche con i quadrati a distanza proporzionale per un effetto un po' più realistico:

Private DrawingArea1 As DrawingArea
Private c As Short = -1
Private clr As Integer
Private vch As Integer = Color.Blue


Public Sub _new()

 With Me
    .Center
   .W = Screen.AvailableWidth
   .H = Screen.AvailableHeight
   .Arrangement = Arrange.Fill
 End With

 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
   .Background = Color.White
 End With

End

Public Sub Form_Open()

 Me.Show

 Do
   Inc c
   Wait 0.1
   If Object.IsValid(DrawingArea1) Then 
     DrawingArea1.Refresh
   Else 
     Break
   Endif
 Loop

End

Public Sub DrawingArea1_Draw()

 Dim b As Short

 For b = c + 1 To 24
   With Paint
     .Rectangle((DrawingArea1.W * 0.5) - ((b * 0.125) ^ 3) * (b + b), (DrawingArea1.H * 0.5) - ((b * 0.1) ^ 3) * (b + b), ((DrawingArea1.W * 0.5) - ((DrawingArea1.W * 0.5) - ((b * 0.125) ^ 3) * (b + b))) * 2, ((DrawingArea1.H * 0.5) - ((DrawingArea1.H * 0.5) - ((b * 0.1) ^ 3) * (b + b))) * 2)
     .LineWidth = (0.1 * b) + (b / 6)
     .Brush = Paint.Color(vch)
     .Stroke()
   End With
 Next 

 If c == 0 Then clr = Rand(&000099, &FFFF99)
 For b = 0 To c
   With Paint
     .Rectangle((DrawingArea1.W * 0.5) - ((b * 0.125) ^ 3) * (b + b), (DrawingArea1.H * 0.5) - ((b * 0.1) ^ 3) * (b + b), ((DrawingArea1.W * 0.5) - ((DrawingArea1.W * 0.5) - ((b * 0.125) ^ 3) * (b + b))) * 2, ((DrawingArea1.H * 0.5) - ((DrawingArea1.H * 0.5) - ((b * 0.1) ^ 3) * (b + b))) * 2)
     .LineWidth = (0.1 * b) + (b / 6)
     .Brush = Paint.Color(clr)
     .Stroke()
   End With
 Next 

 If c = 24 Then
   Paint.End()
   c = 0
   vch = clr
   clr = Rand(&000099, &FFFF99)
 Endif 

End