0

Not sure if this belongs to here or to a .NET forum.

Does anybody know of an implementation to reuse .NET coded drawings with TikZ? Or any ideas, how to do that? I just want to know, if it would be easy or doesn't worth the work.

To give an example: Drawings in C# are done like this:

static Pen black = new Pen(Color.FromArgb(50, 0, 0, 0), 1);

gives us the line. The color and a thickness 1.

SmoothingMode saveMode = SmoothingMode.AntiAlias;

some sample properties which can be ignored for the beginning.

int aVariable = 20;
    Point startPos = new Point(0, 142);
    Point curvePos = new Point(43, 134);
    Point endPos = new Point(72, 116);
    for (int y = 0; y <= aVariable; y++)
    {
        g.DrawCurve(black, new Point[] { startPos, curvePos, endPos });
        startPos.Y = startPos.Y + 4;
        curvePos.Y = curvePos.Y + 4;
        endPos.Y = endPos.Y + 4;
    }

or

Color color1 = Color.FromArgb(80, 132, 178, 223);
Color color2 = Color.FromArgb(132, 178, 223);
g.FillRectangle(new LinearGradientBrush(new Point(124, 19), new Point(124, 25), color1, color2), new Rectangle(124, 19, 29, 6));

demonstrate some drawings.

I think, there are a lot of parallels to TikZ as everything is defined by coordinates, lines, curves or rectangles. So any idea about how to reuse this code is welcome.

  • Any vector description of graphics will come down to describing line widths, move/draw operations, etc. As such, you could make a similar request for any other vector language. My feeling is this question is likely either a straight 'no' (I don't think there is a converter) or 'too broad' (writing one is a major operation). – Joseph Wright Aug 7 '13 at 8:34
  • If there is a .NET library that exports the final drawing in (some vector graphics format that can be converted to) SVG, you can use Inkscape to convert that to TikZ. – marczellm Aug 7 '13 at 8:54
  • @JosephWright You are absolutely right. I just wanted to listen around, if someone has done some work here. – LaRiFaRi Aug 7 '13 at 8:57
  • @marczellm I just got the same idea one second ago. Found this here: codeproject.com/Articles/3751/… Maybe that's allready a solution. Anybody has used that? – LaRiFaRi Aug 7 '13 at 8:57
0

Collecting the comments to write an answer:

No, there is no converter around. Or at least not a known one.

Easiest solution would be, to export the drawings to SVG with a library like this: http://www.codeproject.com/Articles/3751/An-SVG-framework-in-C-and-an-SVG-GDI-bridge

The SVG can be treated within Inkscape. Inkscape has an export function to TikZ which is still in work but already gives nice results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.