Disegnare in una DrawingArea un goniometro
Da Gambas-it.org - Wikipedia.
Per disegnare su una DrawingArea un semplice quadrante del goniometro, si potrà adottare il seguente codice: [nota 1]
Private DrawingArea1 As DrawingArea Private FINEANGOLO As Short = 360 Public Sub Form_Open() With Me .W = Screen.AvailableWidth .H = Screen.AvailableHeight .Arrangement = Arrange.Fill End With With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1" .Background = Color.Lighter(Color.Yellow) End With End Public Sub DrawingArea1_Draw() Dim rag, an As Short rag = DrawingArea1.H * 0.4 With Paint .Brush = Paint.Color(Color.Blue) For an = 0 To FINEANGOLO - 10 Step 10 .Text(CStr(an), (DrawingArea1.W / 2) + (rag + 20) * -Sin(Rad(-an)), (DrawingArea1.H / 2) - (rag + 20) * Cos(Rad(-an))) Next .Stroke .Brush = Paint.Color(Color.Red) .LineWidth = 3.0 .Arc(DrawingArea1.W / 2 + 10, DrawingArea1.H / 2 - 6, rag, Rad(0), Rad(360), False) .Stroke .End End With End
Note
[1] Vedere anche: Disegnare in una DrawingArea un cerchio