Differenze tra le versioni di "Curvare il testo in una DrawingArea"

Da Gambas-it.org - Wikipedia.
Riga 33: Riga 33:
 
     .Translate(240, 304)
 
     .Translate(240, 304)
 
     .Rotate(Rad(90))
 
     .Rotate(Rad(90))
     .DrawText("G", 0, 0, 5, 5, Align.Left)
+
    .Font.Bold = True
 +
     .DrawText("A", 0, 0, 5, 5, Align.Left)
 +
 
 +
    .Font.Bold = False
 +
    .Translate(44, 14)
 +
    .Rotate(Rad(315))
 +
    .DrawText("B", 0, 0, 5, 5, Align.Left)
 +
 
 +
    .Translate(44, 14)
 +
    .Rotate(Rad(315))
 +
    .DrawText("C", 0, 0, 5, 5, Align.Left)
 +
 
 +
    .Translate(44, 14)
 +
    .Rotate(Rad(315))
 +
    .DrawText("D", 0, 0, 5, 5, Align.Left)
 
    
 
    
 
     .Translate(44, 14)
 
     .Translate(44, 14)
 
     .Rotate(Rad(315))
 
     .Rotate(Rad(315))
     .DrawText("A", 0, 0, 5, 5, Align.Left)
+
     .DrawText("E", 0, 0, 5, 5, Align.Left)
   
+
 
 
     .Translate(44, 14)
 
     .Translate(44, 14)
 
     .Rotate(Rad(315))
 
     .Rotate(Rad(315))
     .DrawText("T", 0, 0, 5, 5, Align.Left)
+
     .DrawText("F", 0, 0, 5, 5, Align.Left)
   
+
 
 
     .Translate(44, 14)
 
     .Translate(44, 14)
 
     .Rotate(Rad(315))
 
     .Rotate(Rad(315))
     .DrawText("T", 0, 0, 5, 5, Align.Left)
+
     .DrawText("G", 0, 0, 5, 5, Align.Left)
   
+
 
 
     .Translate(44, 14)
 
     .Translate(44, 14)
 
     .Rotate(Rad(315))
 
     .Rotate(Rad(315))
     .DrawText("O", 0, 0, 5, 5, Align.Left)
+
     .DrawText("H", 0, 0, 5, 5, Align.Left)
 +
 
     .End
 
     .End
 
   End With
 
   End With

Versione delle 17:49, 3 giu 2021

Il caso è quello in cui si scrive un testo su una circonferenza ideale curvando ogni carattere in modo tale che il proprio asse verticale converga al centro di detta circonferenza. [Nota 1]
La rotazione è data dai valori presenti nei metodi "Paint.Traslate()" e "Paint.Rotate()" relativi alle misure dell'area di disegno e a quelle del testo.

Nell'esempio, che segue, si scriveranno alcuni caratteri lungo il semicerchio superiore della circonferenza:

Public Sub Form_Open()
 
 Dim DrawingArea1 As DrawingArea
 
 With Me
   .Center
   .W = 600
   .H = 500
   .Arrangement = Arrange.Fill
 End With
 
 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
   .X = 0
   .Y = 0
 End With
  
End

Public Sub DrawingArea1_Draw()

 With Paint
   .Arc(300, 300, 50, Rad(0), 360, False)
   .Stroke
   .DrawRect(250, 250, 50, 50, Color.Red, 1.0)
   .DrawRect(300, 250, 50, 50, Color.Red, 1.0)
   .DrawRect(250, 300, 50, 50, Color.Red, 1.0)
   .DrawRect(300, 300, 50, 50, Color.Red, 1.0)

   .Translate(240, 304)
   .Rotate(Rad(90))
   .Font.Bold = True
   .DrawText("A", 0, 0, 5, 5, Align.Left)
  
   .Font.Bold = False
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("B", 0, 0, 5, 5, Align.Left)
  
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("C", 0, 0, 5, 5, Align.Left)
  
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("D", 0, 0, 5, 5, Align.Left)
  
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("E", 0, 0, 5, 5, Align.Left)
  
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("F", 0, 0, 5, 5, Align.Left)
  
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("G", 0, 0, 5, 5, Align.Left)
  
   .Translate(44, 14)
   .Rotate(Rad(315))
   .DrawText("H", 0, 0, 5, 5, Align.Left)

   .End
 End With
 
End


Note

[1] Vedere anche questa pagina: Curvare la linea di testo in un oggetto Image