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 🙂
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:
Now code for point and click line drawing:
Now bind the line drawing code to mousedown event:
Just don’t forget to handle the mouseup event as well:
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.