Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Vector Drawing Program - Full Source Code

Author
Message
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Apr 2010 23:30 Edited at: 16th Apr 2010 23:34
Hi everyone,

Actually the code this time is rather large so I decided to attach it as a zip file.

It's a project I started this afternoon (I knew where I wanted to go with it so coding went pretty fast). I have no intentions to update or code more for it, but I wanted to share it as a reference.

The application is a simple vector drawing program on the outside. On the inside it's a little more complicated. But I deliberately didn't use any more "advanced" features of DBP to make the code more understandable. I believe the code gives a good example of how to use User Defined Types, and how to manage them.
I also built this application in a way that makes it very easy to alter things. EG. The layout is not "set" with constants. By changing some values you make the canvas smaller or larger and the amount of code to be changed shouldn't be large.
Everything was coded from scratch.

Picture:



Features include:
* Line, ellipse, circle and bezier curves
* Moving of vector points, and fully changing them
* Connected points are "remembered" (you can connect multiply shapes in a point and they will stay connected)
* Snap to Grid (Grid Size is adjustable, but I didn't make a GUI button for it)
* A canvas

The canvas has its own dimensions, currently set on (left top right bottom): -5.0, 3.6, 5.0, -3.6, the grid size is set on 0.5.
by altering those dimensions you can easily implement a zoom and move canvas feature.

[edit]
I should give some instructions though:
Using the arrow: The arrow is used to move vector points (the blue dots). You can drag them around if you want.
Using Line/Ellipse/Circle: Click once to set the first point, and click somewhere else for the final point. This will add the shape to the drawing list.
Using Bezier Curves: Click and drag to set the first point and draw the anchor of the first point. Then click and drag a second time to set the final point and anchor.

Cheers!
Sven

Attachments

Login to view attachments
Guido Italy
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 17th Apr 2010 19:44
Super !

Function "Save" ??
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Apr 2010 20:08
Thanks!

I did some research for saving vector drawings, but it would've taken too much time.

Cheers!
Sven

French gui
19
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 29th Apr 2010 20:18
Awesome work you did there! One thing I would like to see, is a way to fill closed shapes. I've tried to do something like this but never suceed.

Login to post a reply

Server time is: 2024-04-26 07:09:40
Your offset time is: 2024-04-26 07:09:40