NegativeZero Posted February 2, 2005 Posted February 2, 2005 ok i want to draw a line the shapes into a circle, im going to use this for my health bar in a game im using. there is some info in the middle of the health bar, can anyone help me. Quote
Napivo1972 Posted February 2, 2005 Posted February 2, 2005 I didn�t have time to make it beautiful but here is a class that allows you to have a round indicator Public Class RoundIndicator Public x, y, h, w As Integer Public MinValue As Integer = 0 Public MaxValue As Integer = 100 Public Value As Integer = 45 Public p As Pen = New Pen(Color.Red, 4) Const startangle As Integer = 0 Public Sub New(ByVal vx, ByVal vy, ByVal vHeight, ByVal vWidth) x = vx y = vy h = vHeight w = vWidth End Sub Public Sub draw(ByVal g As Graphics) Dim Angle As Double = 360 * (Value / (MinValue - MaxValue)) g.DrawArc(p, x, y, w, h, Convert.ToInt32(startangle), Convert.ToInt32(startangle + Angle)) End Sub End Class to use it place this in a form Dim x As RoundIndicator Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load x = New RoundIndicator(20, 30, 100, 100) End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint x.draw(e.Graphics) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick x.Value = x.Value + 1 Me.Invalidate() End Sub Quote
NegativeZero Posted February 2, 2005 Author Posted February 2, 2005 hey thanks, works perfectly Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.