Inserire un testo in diagonale in un Controllo grafico

Da Gambas-it.org - Wikipedia.
Versione del 4 ago 2024 alle 08:27 di Vuott (Discussione | contributi) (Creata pagina con "Di seguito mostriamo un possibile codice per inserire un testo in diagonale in un Controllo grafico, ad esempio in una ''DrawingArea'': Private DrawingArea1 As DrawingArea...")

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Di seguito mostriamo un possibile codice per inserire un testo in diagonale in un Controllo grafico, ad esempio in una DrawingArea:

Private DrawingArea1 As DrawingArea


Public Sub Form_Open()

 With Me
   .W = 400
   .H = 400
   .Center
   .Arrangement = Arrange.Fill
 End With
 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
   .X = 0
   .Y = 0
   .Background = Color.Orange
 End With

End


Public Sub DrawingArea1_Draw()

 With Paint
   .LineTo(400, 400)
   .Stroke
' --- il testo ---
   .Translate(140, 100)
   .Rotate(Rad(315))
   .Font.Size = 20
   .Brush = .Color(Color.Yellow)
   .DrawText("G", 0, 0, .Font.TextWidth("G"), .Font.TextHeight("G"), Align.Center)
   .DrawText("a", 20, 0, .Font.TextWidth("a"), .Font.TextHeight("a"), Align.Center)
   .DrawText("m ", 40, 0, .Font.TextWidth("m"), .Font.TextHeight("m"), Align.Center)
   .DrawText("b", 65, 0, .Font.TextWidth("b"), .Font.TextHeight("b"), Align.Center)
   .DrawText("a", 83, 0, .Font.TextWidth("a"), .Font.TextHeight("a"), Align.Center)
   .DrawText("s", 100, 0, .Font.TextWidth("s"), .Font.TextHeight("s"), Align.Center)
   .End
 End With

End