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. Bezier Points

Bezier Points

Scheduled Pinned Locked Moved C#
graphicsquestion
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.
  • J Offline
    J Offline
    Jim Warburton
    wrote on last edited by
    #1

    I am using DrawBezier to display a user defined bezier curve. I need the x,y values along the curve (not just points used to create the curve but each point along the curve). I have the mathematical formula but if the graphics is generating the points to paint is there a way to access the x,y locations of points it is painting? Thanks

    O 1 Reply Last reply
    0
    • J Jim Warburton

      I am using DrawBezier to display a user defined bezier curve. I need the x,y values along the curve (not just points used to create the curve but each point along the curve). I have the mathematical formula but if the graphics is generating the points to paint is there a way to access the x,y locations of points it is painting? Thanks

      O Offline
      O Offline
      Obaid ur Rehman
      wrote on last edited by
      #2

      Why don't you make your own method for that. May be the following code might help. If my memory serves me correctly, I've copied this code from a book by Charles Petzold on Windows forms programming. public void DrawBezier(Graphics grfx, Pen pen, Point p0, Point p1, Point p2, Point p3) { Point[] curve = new Point[100]; for (int i = 0; i < curve.Length; i++) { float u = (float) i / (curve.Length - 1); //Console.WriteLine(u); float y=((1-u)*(1-u)*(1-u)* p0.Y) + (3*u* (1-u)*(1-u)* p1.Y) + (3*u*u* (1-u)* p2.Y) + (u*u*u* p3.Y); float x=((1-u)*(1-u)*(1-u)* p0.X) + (3*u* (1-u)*(1-u)* p1.X) + (3*u*u* (1-u)* p2.X) + (u*u*u * p3.X); curve[i] = new Point((int) Math.Round(x), (int) Math.Round(y)); } grfx.DrawLines(pen, curve); }

      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