BDraw v1.8

Paint programs, vector editors, 3d modelers, animation editors, etc.
Message
Author
User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

BDraw v1.8

#1 Post by SFR »

I wrote simple graphic program in Gtkdialog and this is crazy, but...it works! :shock:
It uses <button> widget as a drawing area (that's why "BDraw").

Take a look at the screenshot; the toolbox area contains (from left to right):
- current shape
- stroke width
- transparency level
- stroke color
- fill color
(next row):
- Undo - delete last drawn object, doesn't work with Load & Save
- Load - load a picture, only .bdr format is accepted (well, it's SVG really, but has specific arrangement of lines)
- Save - save as .bdr (for further editing) or as .png (you can choose output resolution)
- Quit

Few words about drawing:
When you choose, eg. Line or Circle, then press the mouse button on starting point, drag cursor to the ending point and release button.
But there are two exceptions:
1. Text - press and release the button on starting point; this point will become the bottom-left beginning of the text.
Then choose a font (avoid fonts with digits in their names, they won't work [EDIT: they work since v1.1]), style and size and in the next window enter some text.
2. Arc - press the mouse button on starting point, drag cursor to the ending point and release button, then move cursor to another point and press space [EDIT: since v1.3 - press right mouse button].
(Then you can move cursor to another place and press space again, and so on.)

The drawing area is fixed to 512x512, but it doesn't matter IMHO, since it's vector graphic. As I wrote above you can adjust final resolution while exporting to PNG.

Hint: since you're drawing within a button, it blinks on hover and clicking. To avoid this, just draw filled rectangle that fills all space. This will also remove default transparency of the background.

Requirements:
- Gtkdialog >= 0.7.21 (version 1.0)
- Gtkdialog >= 0.8.0 (versions >= 1.1)
- Gtkdialog >= 0.8.1 (versions >= 1.3)
- base64 (versions >= 1.4)
- Xdialog
- rsvg-convert (for .png output)
- xwininfo
- getcurpos
- awk, sed, and so on.
(all of these should be already present in most/all of recent Puppies)

I've attached standalone, gzip'ed scripts - unpack, make executable and click to launch.

I didn't make a pet, but if someone could kindly make a nice icon for this app (I simply can't draw!) then I'll do it.

Tested on:
- Slacko-5.3.3, 5.4, 5.5
- Lupuplus-528.005
- Precise-5.4.1
- Akita-beta13
- FatDog64-601
- Carolina-0.0.3
- uPup-Precise-5.4.X.4
_____________

Edit:
Version 1.1 uploaded, see this post for changelog.
Version 1.2 uploaded, see this post for changelog.
Version 1.3 uploaded, see this post for changelog.
Version 1.4 uploaded, see this post for changelog.
Version 1.5 uploaded, see this post for changelog.
Version 1.5 replaced with v1.5.1, see this post for details.
Version 1.6 uploaded, see this post for changelog.
Version 1.6.1 uploaded, see this post for changelog.
Version 1.7 uploaded, see this post for changelog


Version 1.8:
- removed 'vercmp' dependency and used 'busybox dc' for compatibility with Fatdog

Have fun & Greetings!
Attachments
bdraw-1.8.sh.tar.gz
Unpack, make executable &amp; click to launch.
43bfa01b0baee491411a227aaf5ad0eb bdraw-1.8.sh
(7 KiB) Downloaded 330 times
bdraw-1.7.sh.gz
Unpack, make executable &amp; click to launch.
MD5: b9d67555b28214610854e35cfd6a8fe2 bdraw-1.7.sh
(6.77 KiB) Downloaded 565 times
bdraw-1.6.1.sh.gz
Unpack, make executable &amp; click to launch.
MD5: 1b568be289430f13b46cacf8eda91ed6 bdraw-1.6.1.sh
(7.3 KiB) Downloaded 654 times
bdraw-1.6.sh.gz
Unpack, make executable &amp; click to launch.
MD5: 2a73ea728b2e3e61c81a94802d22c117 bdraw-1.6.sh
WARNING - this version may not work due to &lt;spinbutton&gt; failure in some cases.
Reason: comma as decimal separator.
(7.29 KiB) Downloaded 870 times
bdraw-1.4.sh.gz
Unpack &amp; click to launch.
(6.51 KiB) Downloaded 851 times
bdraw-1.3.sh.gz
Unpack &amp; click to launch.
(5.86 KiB) Downloaded 877 times
bdraw-1.2.sh.gz
Unpack &amp; click to launch.
(4.95 KiB) Downloaded 842 times
bdraw-1.1.sh.gz
Unpack &amp; click to launch.
(5.04 KiB) Downloaded 859 times
bdraw.sh.gz
Unpack &amp; click to launch.
(this is old version 1.0)
(3.63 KiB) Downloaded 920 times
Screenshot.png
(55.77 KiB) Downloaded 1828 times
Last edited by SFR on Sat 21 Mar 2015, 15:08, edited 26 times in total.
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#2 Post by puppyluvr »

:D Hello,
Amazing.. Simply amazing..
Who would have thought... Well, you of course.. 8)
Ohh, the possibilities....
Been playing with gtk lately..
I believe we yet just touching on what it can do..
All the parts are there, its just figuring out creative ways to use them..
Like this... :idea:

I`ve already got ideas for this... :wink:
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!

Puppy since 2.15CE...

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#3 Post by vovchik »

Dear SFR,

Yes, amazing! Congrats.

With kind regards,
vovchik

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#4 Post by SFR »

Thanks guys! :D

I still can't believe it works...
The one who discovered how to draw on screen borders in C64 must have felt similarly. :wink:

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#5 Post by 01micko »

Brilliant!

zigbert (who happens to be an artist, major gtkdialog fan and svg fan) will fall in love with this!
Puppy Linux Blog - contact me for access

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#6 Post by sc0ttman »

Oh. My. Word.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#7 Post by vovchik »

Dear SFR,

I wonder whether I shouldn't try to port your code to BaCon. It is brilliant (yours), but we would get a real speed increase and, if UPX'd, it would be about 7-10k and be a very responsive little draw program. What do you think?

With kind regards,
vovchik

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#8 Post by zigbert »

Refreshing!

Sometimes, codelines get you in a good mood.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#9 Post by SFR »

vovchik wrote:Dear SFR,

I wonder whether I shouldn't try to port your code to BaCon. It is brilliant (yours), but we would get a real speed increase and, if UPX'd, it would be about 7-10k and be a very responsive little draw program. What do you think?

With kind regards,
vovchik
I think it's great idea, thank you! :) But if you could wait a while - I'm working on some little improvements (unfortunately they require Gtkdialog >= 0.8.0 now, but on the other hand every modern Puppy has it) and I did overlook 2-3 things, must fix them now.

I'll post it ASAP, maybe even today.

Thanks again you all &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#10 Post by SFR »

SFR wrote:The drawing area is fixed to 512x512, but it doesn't matter IMHO, since it's vector graphic. As I wrote above you can adjust final resolution while exporting to PNG.
Well, it matters really if we consider ratio...

Fortunately it's been solved (in a bit ugly, but somehow working way).
Franky, since the beginning I wanted to add the choice of size of drawing area, but the problem was that if the area was too narrow, the bottom widgets made the whole window stretched, including the "Main Button".
Even if I used <hbox></hbox>, the button was aligned to the right, which was completely opposite of what I wanted.
And even the great trick with <hbox><text> unveiled by Zigbert in his Gtkdialog thread didn't work, because although Main Button was aligned to the left, still was stretched too much.
The idea was to add another, invisible button next the Main One, which equalize the whole size and align Main Button to the left...but how to determine the overall size of a window before it's displayed..?
(Note - I had to consider that each user has different font size what causes different size of bottom buttons).

At first there's created an empty picture with 1x1 resolution and put into that invisible "Fix Button".
Then, when the window is being displayed, appropriate function is called and send to the background, waits 0.2s to make sure that the window is "really" displayed and visible for xwininfo, calculates the proper width of that picture and overwrites it.

The unsolved thing is to automatically refresh/resize "Fix Button" - now it's done when user hover the Main Button area for the first time.
Another thing I'm not happy with: even if drawing area is wide enough and Fix Button's width is set to 1px, there's still thin, vertical bar of empty space next to drawing area, on the right.

The maximum allowed picture resolution is calculated like this:
Max_X = Screen_Width - 64
Max_Y = Screen_Height - 256
Limiting the height is important because:
if
1). Picture height is greater than screen height
and
2). Picture is narrower than bottom widgets
then
when Fix Button is being resized, the whole window is cropped at bottom and adjusted to screen height.
I don't know why this happens and can't fix it, sorry. :oops: I hope the resolution limit won't be a big problem to anyone..?
On the other hand you can edit even 1x1 picture (if you have ultra-sensitive mouse and sharp eye). :lol:

Well, after all I believe it's fair trade, since BDraw is much more functional now.
And all in all it's just a playful toy. :wink:

"Load" button has been removed from the main window and now when app is launched there's a little initial window with "New", "Open" and "Quit" buttons.

Another fixes/additions:
- Oversight in Text tool: if there's more than one space in a row, they'll be displayed as one space; fixed now.
- Fonts with digits in their names - fixed!
- Added "Redo" button. I didn't mention it before, but Undo is multi-level, as well as Redo.
But to avoid some ambiguous mess, after drawing any shape, Redo buffer is cleared.
- Added cursor position view (updated every 1s) and current picture resolution.
@Vovchik - Is it possible to increase the update interval in BaCon, so it'd be close to realtime..?
- few minor code improvements


PS. Only two widgets seem to require Gtkdialog-0.8.0, so if someone would like to backport it to 0.7.21, it's just a matter of replacing <statusbar> with <text> and <timer> with <progressbar> (see Zigbert's thread for details).

First post updated.

Ok, that would be all for now. 8)

Greetings!
Attachments
screenshot.png
(31.8 KiB) Downloaded 1543 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#11 Post by vovchik »

Dear SFR,

I do not know how to tell you that you have uncovered something like quantum mechanics within the GTK button widget. Lovely :) And I worked for decades at the IAEA and did their first TCP/IP. You captured something essential. Nice :)

With kind regards,
vovchik

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#12 Post by seaside »

SFR, I just saw this and had to say-

This is the first drawing program that made me actually feel like drawing something (not that anyone else would share that interest after seeing how I draw....) :)

Very clean, attractive, and cleverly done.

Hats off to you,

Regards,
s

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#13 Post by zigbert »

SFR
The tips-thread is a bit old - it was written in those days before Thunor stepped up. Gtkdialog was not that powerful, and we needed more workarounds.

Some thoughts:
- I usual align widgets to the left by including a text widget. <text space-expand="true" space-fill="true"><label>""</label></text>
- You can make the drawing size larger than screen-size by setting the <button> widget inside a <vbox scrollable="true">
- I think it would be possible to use a <pixmap> widget instead of the <button> for the drawing. gtkdialog supports <eventbox> which can add <actions> to nonactive widgets like the <pixmap>.
- The <timer> can be updated more frequently than each sec. <timer visible="false" milliseconds="true" interval="100">



Sigmund

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#14 Post by SFR »

Hey Zigbert.
- I usual align widgets to the left by including a text widget. <text space-expand="true" space-fill="true"><label>""</label></text>
Yes, this is the trick I tried - the problem is that the Left Button becomes stretched anyway and covers ~half of the window (horizontally).
Couldn't find out any way to get its real size.
- You can make the drawing size larger than screen-size by setting the <button> widget inside a <vbox scrollable="true">
Good thinking, but I'll lose the ability to calculate mouse position properly...hmm, maybe in one of future Gtkdialog version will be something like "read-vbox/hbox-scrollbar-shift". :wink:
- I think it would be possible to use a <pixmap> widget instead of the <button> for the drawing. gtkdialog supports <eventbox> which can add <actions> to nonactive widgets like the <pixmap>.
I didn't play with Gtkdialog >= 0.8.1 yet, but I'll try it one of these days, thanks!
- The <timer> can be updated more frequently than each sec. <timer visible="false" milliseconds="true" interval="100">
Just tried and it works and looks nice...but unfortunately, it slows down response time and if user presses button and starts to drag the cursor too sudden, the initial X & Y coordiantes are incorrectly calculated. :(
Well, it happens even now with interval="1" (sec.), but to a lesser extent.

Thanks you for your tips, appreciated!

And thanks again to all of you for kind words :) &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#15 Post by Geoffrey »

Good stuff, tried it in Carolina with gtkdialog version 0.8.3 r473M, it all works.
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#16 Post by SFR »

Thanks for the info Geoffrey!
__________

I don't know how could I missed the obvious and trudge into complex and unnecessary methods.
If the button is narrower (or not) than the window, it's enough to use <hbox homogeneous="true"> (this will nicely align it to center, horizontally), and calculate X position using:
X = ( Mouse_X_Pos - Window_X_Pos ) - ( ( Window_Width - Picture_Width ) / 2 )
Much more simple and elegant...

So, the height problem is gone and theoretically picture size is no longer limited, but I set the limit to 2048x2048; more causes terrible slow down and/or Gtk crashes.
Also, coordinates were displayed in a range from 0 to Picture_Width/Height what was wrong, it's been corrected: from 0 to (Picture_Width/Height - 1).
And, just for fun, I added simplified support for dashed lines.

Ok, now I'm quite satisfied with this...

Version 1.2 attached to the first post.
___________

@Zigbert:
Just tried <eventbox> and it's really promissing. The one and only problem is handling keystrokes (for "Arc"), because there's no way to catch focus on <evenbox><pixmap> area; it's always glued to (and intercepted by) one of bottom buttons.

If someone would like to play with it, I've attached it to this post, as version 1.2+.

Greetings!
Attachments
bdraw-1.2+.sh.gz
Unpack &amp; click to launch.
Requires Gtkdialog &gt;= 0.8.1
&quot;Arc&quot; doesn't work
(4.98 KiB) Downloaded 777 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#17 Post by SFR »

RE: <eventbox><pixmap> and "Arc"

Nothing is unsolvable. :)
I examined Zigbert's Pmusic - I had no idea that there's $BUTTON variable in Gtkdialog that makes possible to read which button is pressed.
So "Arc" is now handled by right mouse button instead of spacebar.

As a really nice side effect, it's possible to draw "rays" and similar stuff now - simply, when you left click on some point, then you can right click many times elsewhere, but the initial X/Y position stays unchanged.

Another thing I _thought_ it's impossible to implement: "Freehand" mode.
It's not perfect - a bit "edgy", but pretty amusing.


Important change:
AFAIK in frugally installed Puppies /tmp folder is kept in RAM, but not in case of full installs (I might be wrong).
Since there's a lot of constantly used (by BDraw) temp files stored in /tmp, I changed the location to /dev/shm (suggested to me by Technosaurus elsewhere), what (I guess) should improve performance in fully installed Puppies.
If I'm wrong about this, please let me know, so I'll roll it back.

BTW, I combined both methods into one script - one can choose at initial window to use <button> or <pixmap>.

First post updated.

PS. Sorry for such frequent updates, but every time I thought "Ok, that's it, done!", then suddenly in the middle of the night something new popped up in my mind.
This time I'm pretty sure - I'll give it a rest...at least for some time. :wink:

Greetings!
Attachments
screenshot.png
(61.64 KiB) Downloaded 873 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#18 Post by Geoffrey »

SFR wrote:PS. Sorry for such frequent updates, but every time I thought "Ok, that's it, done!", then suddenly in the middle of the night something new popped up in my mind.
This time I'm pretty sure - I'll give it a rest...at least for some time.
Don't apologize, update as much as you like, I like to see things evolve like this, I'm liking it a lot. :)
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#19 Post by SFR »

Thanks Geoffrey :)
Indeed - I forgot about one important feature: bitmap import/export.

"Import Clipart" usage: select with mouse a part of drawing area, then choose an image.
The image will be inserted within previously selected area.
Supported (but not fully tested) formats are: bdr, png, svg, xpm, bmp, gif, jpg, tif, ico, ppm, pnm, pcx, tga.

BTW, the image will be 'base64' encoded and embedded into the picture, not linked.

Another nice side effect - the direction of selecting matters, eg. from upper left to bottom right - image will be inserted normally, but eg. selecting from bottom right to upper left - image will be flipped both horizontally and vertically.

"Export clipart" is used in the same manner as "Import", but the output format is always .png and the trick with "direction of selecting" doesn't work.

First post updated.

Greetings!
Attachments
screenshot.png
(115.95 KiB) Downloaded 853 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

Puppyt
Posts: 907
Joined: Fri 09 May 2008, 23:37
Location: Moorooka, Queensland
Contact:

#20 Post by Puppyt »

WOW! Fantastic work, SFR - I guess now we don't have to keep lamenting that Barry's EVE can't be ported into Puppy http://bkhome.org/eve/ :)
Search engines for Puppy
[url]http://puppylinux.us/psearch.html[/url]; [url=https://cse.google.com/cse?cx=015995643981050743583%3Aabvzbibgzxo&q=#gsc.tab=0]Google Custom Search[/url]; [url]http://wellminded.net63.net/[/url] others TBA...

Post Reply