1

I have a desktop application project which involves a drawing component. Base language isn't choosed yet.

Actions required for the drawing are the following :

  • Point & click to draw sticks and curves.
  • Gallery of shapes to add.
  • Select components and edit their properties (thickness, length, metadata)

All I can think of is SVG+Javascript, since I used to work for the web until now. And I would like a broader point of view, more choice.

Please do not argue on which language is theorically best. Instead, tell a story : which one did you used, for what kind of project, and what seemed easy or difficult to you.

Thanks for sharing your experience :)

Elvex
  • 656
  • 5
  • 22
  • Are you asking in which language should this application be written or which language should be made available to the user interactively? Which desktop environment is your application meant for? – Nicola Musatti Oct 13 '11 at 09:54
  • The question is about which langage to choose for writing the app. I'm afraid to reinvent the wheel, though I don't want to "embed InkScape" in my app. I'd like to reuse what's reusable so the user can have a simple drawing Interface. Eg. if I had InkScape in spare parts, I would throw most of the parts, keep the ones that interest me, and develop those who are missing. – Elvex Oct 13 '11 at 10:11
  • I've been lurking around Qt / WPF for app design, but I wonder if I shouldn't embed another language or API to do the drawing part. – Elvex Oct 13 '11 at 10:38
  • We finally chose [Irrlicht](http://irrlicht.sourceforge.net/) which is a cross-platform engine built over OpenGL – Elvex Aug 23 '12 at 13:15

3 Answers3

1

Given the requirement there is only one language I'd use: Tcl. The Tk widget library has an excellent canvas widget which is vector based and is very easy to use. It is event based so feels very similar to javascript in terms of UI programming.

Here's code for point-and-click line drawing:

First, creating the canvas is simply:

canvas .c
pack .c

Now code for point and click line drawing:

set currentObject ""

set line {
  set ::currentObject [.c create line %x %y %x %y]

  bind . <Motion> {
    .c coords $currentObject [list %x %y %%x %%y]
  }
}

Now bind the line drawing code to mousedown event:

bind . <ButtonPress-1> $line

Just don't forget to handle the mouseup event as well:

bind . <ButtonRelease-1> {
  bind . <Motion> {}
}

That's just about a dozen lines of code. Which is another reason I usually turn to Tcl for this kind of thing: it lets you do a lot with very little code.

slebetman
  • 109,858
  • 19
  • 140
  • 171
  • Though I didn't understand much of what I've done, I downloaded something at http://equi4.com/tclkit/download.html, launched it, executed the above code, and now I can draw lines. Pretty amazing. – Elvex Oct 13 '11 at 10:34
0

There is of course the Logo programming language. It sounds like a joke, and in fact, I thought of it as a joke first, but you may find some use for it.

Community
  • 1
  • 1
Ola Eldøy
  • 5,720
  • 7
  • 49
  • 82
0

WPF is all about graphical stuff, including vectors.

Ola Eldøy
  • 5,720
  • 7
  • 49
  • 82