Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Drawing line at an angle in ASP.nt

Reply
Thread Tools

Drawing line at an angle in ASP.nt

 
 
=?Utf-8?B?U3VyYWpQcmFiaHU=?=
Guest
Posts: n/a
 
      06-08-2006
Hi All,

I am tying to build a ASP.net 2.0 based web page which displays a Analog
Guage ( 0 to 180 degrees) with an Arrow in the middle.

The application accepts the Percentage as input from a text box and then
generates an image which shows a Arrow pointer dipicting that percentage on
the Arc (or guage).

I am dynamically generating the arcs and the pointer using Draw Pie ( and
Fill pie) and DrawLine methods of the Graphics Class.

But the problem is though the logic is correct, but the drawline is not i
the correct angle. Can you please help my find out where i have gone wrong. I
hae pasted the code, you can run and check how it is working.


Code Below:
************************************************** *******


Dim iPercentage As New Integer
iPercentage = Integer.Parse(TextBox1.Text)

Dim arrowAngle As New Integer


'o% is 0 Degrees and 100% is 180 degrees
arrowAngle = Integer.Parse(iPercentage * 1.

'for drawing the arcs , using the drw pie method
'************************************************* ***************
Dim objBitmap As New Bitmap(200, 200)

Dim objGraphic As Graphics = Graphics.FromImage(objBitmap)
Dim blackPen As New Pen(Color.Black, 5)
Dim whiteBrush As New SolidBrush(Color.White)
objGraphic.FillRectangle(whiteBrush, 0, 0, 200, 200)

Dim rect As New RectangleF(0, 0, 200, 200)
objGraphic.DrawPie(Pens.Black, rect, 0, -180)
Dim rect1 As New Rectangle(0, 0, 200, 200)
objGraphic.FillPie(Brushes.Blue, rect1, 0, -180)
rect = New RectangleF(10, 10, 180, 180)
objGraphic.DrawPie(Pens.Black, rect, 0, -180)
rect1 = New Rectangle(10, 10, 180, 180)
objGraphic.FillPie(Brushes.White, rect1, 0, -180)

'to display the arrow with in the Pie Drawn which gives the Guage
Look and feel
' i am getting the Coordinated for the angle found so that the line drawn
is at an angle.
'************************************************
Dim mcos As Integer
Dim msin As Integer
mcos = Math.Cos(arrowAngle) * 100
msin = Math.Sin(arrowAngle) * 100

objGraphic.DrawLine(Pens.Blue, 100, 100, mcos, msin)
Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)

objGraphic.Dispose()
************************************************** *******

Please Help me out in this.

Regards
Sura
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Guide to the standard library? Library for drawing in GUIs?drawing inbrowsers? defn noob Java 1 06-28-2008 02:50 AM
funny drawing software:ScreenPen,drawing directly on screen! yyzzbb@sina.com Digital Photography 0 02-04-2006 12:31 AM
System.Drawing For Drawing Text Images jjbutera@hotmail.com ASP .Net 1 01-09-2006 09:55 PM
Not many "wide-angle" compacts but, heck, many are wide-angle anyway! JeffOYB@hotmail.com Digital Photography 10 01-09-2006 08:30 AM
Wide-angle primes in Canon's EF-S line? Kevin Digital Photography 3 08-21-2004 06:04 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57