Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Want to draw continuous line based on a function

Want to draw continuous line based on a function

Scheduled Pinned Locked Moved C#
questiondata-structurestutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • . Offline
    . Offline
    ...---...
    wrote on last edited by
    #1

    Hello, Let's say I have a function, exp^x for example. I would like to draw a graph of this function in the client area of my form. The only way I can think of doing this is to write a conditional loop that will iterate through values of x within some interval and then draw the value onto the screen scaled in some way to the clientRect.Height and clientRect.Width. Question: What do I have to do to get the 'graph' to appear as one continuous smooth plot? thanks

    R 1 Reply Last reply
    0
    • . ...---...

      Hello, Let's say I have a function, exp^x for example. I would like to draw a graph of this function in the client area of my form. The only way I can think of doing this is to write a conditional loop that will iterate through values of x within some interval and then draw the value onto the screen scaled in some way to the clientRect.Height and clientRect.Width. Question: What do I have to do to get the 'graph' to appear as one continuous smooth plot? thanks

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Create a Point for every x/y coordinate you have, put them all into an array and then call:

      Graphics g = e.Graphics; //assuming you are in OnPaint
      Point[] points = CalculatePoints();
      g.DrawLines(Pens.Black, points);

      You can also play around with the SmoothingMode property of the Graphics class. This will probably help you to make it look 'nicer'.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups