I am posting a series of article of where I am demonstrating the building of a basic drawing tool. If you are interesting in reading the previous post you can read here
- Part 1 : http://munnaondotnet.blogspot.com/2011/11/drawing-tool-story-drawing-simple-line.html
- Part 2 : http://munnaondotnet.blogspot.com/2011/12/drawing-tool-story-switching-between.html
Today I am going to show you guys how to draw a sine or cosine curve, Bellow I have shared a screenshot to let the user know what I am up to. In the bellow drew 9 sine curve on various values for xmin and ymin.
I have putdown the code in a single class named “CustomLine” the whole code is given bellow and no need farther explanation, as the class is pretty simple and any one can understand it quickly. If anyone need any explanation please drop a comment, I would more than happy to edit the post to add explanation section.
CustomLine code listing
Bellow the uses is given, note that I have used a canvas as graph control where any drawing surface can be used, but I feel comfortable as it uses basic functionalities of a drawing surface.
In this short article we have seen how we can use a sine wave or cosine wave curve in WPF. Hope this would help someone some day. I would continue to list lots of drawing and interesting stuff regarding WPF drawing both in 2D and 3D in future post. Until next time bye bye.