Drawing line at an angle in ASP.nt

Discussion in 'ASP .Net' started by =?Utf-8?B?U3VyYWpQcmFiaHU=?=, Jun 8, 2006.

  1. 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.8)

    '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
     
    =?Utf-8?B?U3VyYWpQcmFiaHU=?=, Jun 8, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    642
    Kevin Spencer
    Jan 9, 2006
  2. Darren Grant

    Angle class - how is my code ?

    Darren Grant, Dec 15, 2003, in forum: C++
    Replies:
    5
    Views:
    520
    Darren Grant
    Dec 16, 2003
  3. defn noob
    Replies:
    1
    Views:
    398
    Mark Space
    Jun 28, 2008
  4. Keith Hughitt

    Angle brackets in command-line arguments?

    Keith Hughitt, Jul 16, 2008, in forum: Python
    Replies:
    4
    Views:
    623
    Keith Hughitt
    Jul 16, 2008
  5. Andrew Dunbar

    Extending the line input (angle) operator

    Andrew Dunbar, Oct 28, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    85
    Peter Wyzl
    Oct 28, 2004
Loading...

Share This Page