Differenze tra le versioni di "Ruotare un testo secondo i raggi di una circonferenza ideale"
Da Gambas-it.org - Wikipedia.
Riga 53: | Riga 53: | ||
.Translate(0, 90) | .Translate(0, 90) | ||
.Rotate(Rad(90)) | .Rotate(Rad(90)) | ||
− | .DrawText(" | + | .DrawText("Testo qualsiasi !", -20, 0, PictureBox1.W, PictureBox1.H, Align.Left) |
.End | .End | ||
End With | End With | ||
− | PictureBox1. | + | PictureBox1.Image = im |
− | |||
'''End''' | '''End''' | ||
Versione delle 19:27, 25 gen 2021
Il caso in oggetto è quello in cui si intende ruotare un testo qualsiasi secondo i raggi di una circonferenza. Pertanto il testo ruoterà avendo il suo margine sinistro corrispondente al centro della predetta circonferenza.
Bisognerà utilizzare la Classe Paint, ed in particolare le funzioni:
- .Translate( )
- .Rotate( )
- .DrawText( )
Sarà possibile ottenere, quanto previsto, mediante almeno tre oggetti.
Uso di una DrawingArea
[nota 1]
Public Sub Form_Open() With DrawingArea1 .X = 0 .Y = 0 .W = 150 .H = 150 End With End Public Sub DrawingArea1_Draw() With Paint .Translate(0, 90) .Rotate(Rad(90)) .DrawText("Testo", -20, 0, DrawingArea1.W, DrawingArea1.H, Align.Left) .End End With End
Uso di una PictureBox
Public Sub Form_Open() Dim im As Image With PictureBox1 .X = 0 .Y = 0 .W = 150 .H = 150 End With im = New Image(PictureBox1.W, PictureBox1.H, Color.Transparent) With Paint .Begin(im) .Translate(0, 90) .Rotate(Rad(90)) .DrawText("Testo qualsiasi !", -20, 0, PictureBox1.W, PictureBox1.H, Align.Left) .End End With PictureBox1.Image = im End
Uso di una TextLabel
Public Sub Form_Open() Dim im As Image With PictureBox1 .X = 0 .Y = 0 .W = 150 .H = 150 End With im = New Image(TextLabel1.W, TextLabel1.H, Color.Transparent) With Paint .Begin(im) .Translate(0, 90) .Rotate(Rad(90)) .DrawText("Hola, tincho !", -20, 0, TextLabel1.W, TextLabel1.H, Align.Left) .End End With im.Save("/tmp/immago.png", 100) TextLabel1.Text = "<IMG Src=/tmp/immago.png</img>" End
Note
[1] Rimandiamo anche a quest'altra pagina della WIKI: http://www.gambas-it.org/wiki/index.php?title=Ruotare_il_testo_in_una_DrawingArea