I am drawing graphs into a WinForms Picturebox. Now I am searching for a possibility to 'duplicate' a line (an array of points), so that the two resulting lines are positioned a fixed distance away from the original one. Like in this picture, I have the red line and want to get the black ones:
Picture of lines http://img227.imageshack.us/img227/2341/linesb.png
I thought about just moving the line a few pixels up/right/up-right, but that leads to strange overlapping lines.
Is there any other approach that does what I want? Any ideas would be greatly appreciated. Thanks!
I have created a function that does exactly what you need a few months ago as a part of a graph layouting algorithm. I wrote that in python and PyQt. I just pasted the code here at codepad. That should be very easily translateable to c#.
Update:
Translated it one-to-one from my python snippet (Love to do that graphics stuff :) ). As my original code was designed for more than two output lines, I just took that into the c# version as well. For two black lines being 20 pixels away from the red one, just pass
width = 40
andnum = 2
. The returned jagged array represents an array of lines (outer array), with each line represented by an array of points (inner).To try it out I took this small sample (The same sample as in my PyQt code):
Which resulted in this graphic:
outlines around line http://img41.imageshack.us/img41/8606/lines2.th.png