Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 25 Apr 2014, 05:15
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon - Bash-based Basic-to-C converter/compiler
Post new topic   Reply to topic View previous topic :: View next topic
Page 26 of 36 [526 Posts]   Goto page: Previous 1, 2, 3, ..., 24, 25, 26, 27, 28, ..., 34, 35, 36 Next
Author Message
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 19 Oct 2011, 09:35    Post subject:  

this is just a small snippet so as to focus on the code example vovchick posted above
which sends out the arguments how the BaCon app was run with and
make the all of the env available to BaCon !
I will just pull out the env string bash version for this example
a big thanks to vovchick

Joe

Quote:

' call this arg-find1.bac
TRAP LOCAL
SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim

'--- thanks to vovchick for this gem
'--- send out to env the arguments used to run the program
'--- make the env availabe to BaCon
PRINT "==============env====================================="
SETENVIRON "BACONARGS", ARGUMENT$
myvar$ = EXEC$("set")
PRINT myvar$
PRINT "==============end====================================="


'--- use one of the env strings from bash in BaCon
Cmd$ = CONCAT$("echo ", "$BASH_VERSION")
Opt$ = EXEC$(Cmd$)
PRINT "this is the bash version " , Opt$





and I have a new "EXPORT" BACONARGS in the env Cool
BACONARGS='./arg-find1 /root/bacon-examples/experaments/colorbbc3bac'

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Wed 19 Oct 2011, 10:30    Post subject:
Subject description: making graphic overlays with gtk/gdk libs
 

Dear puppians,

Here is a little demo that shows how to do graphic overlays in BaCon, making direct use of gtk/gdk libs. With just a few additions - i.e. passed parameters, horizontal and vertical offests and a routine for canvas size - this can replace IM for overlay creation. Have a look. The source and two images are in the archive, as well as a lucid binary. The binary weighs in at 34k, which is better, I think, than 8+ MB for an unpacked IM (although IM is great for many, many things!).

With kind regards,
vovchik
overlay.tar.gz
Description 
gz

 Download 
Filename  overlay.tar.gz 
Filesize  32.5 KB 
Downloaded  202 Time(s) 
image1.png
 Description   
 Filesize   12.17 KB
 Viewed   836 Time(s)

image1.png

image2.png
 Description   
 Filesize   6.81 KB
 Viewed   826 Time(s)

image2.png

new_img.png
 Description   
 Filesize   23.39 KB
 Viewed   856 Time(s)

new_img.png

Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3219

PostPosted: Wed 19 Oct 2011, 11:42    Post subject:  

thanks! Any advantage over using mtPaint? (guess if you needed to script it...)
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Wed 19 Oct 2011, 12:53    Post subject:  

Dear jpeps,

I am certain that mtpaint can do that type of thing well - I just don't know how. It was really easier, for me at least, to program my own little routine for that particular job Smile And I learned something at the same time Smile

With kind regards,
vovchik
Back to top
View user's profile Send private message 
wjaguar

Joined: 21 Jun 2006
Posts: 216

PostPosted: Wed 19 Oct 2011, 14:52    Post subject:  

vovchik wrote:
I am certain that mtpaint can do that type of thing well - I just don't know how.

In point of fact, it cannot - at the moment. Wink So, thank you for demonstrating to me that yet another unholy perversion of PNG format does indeed exist in the wild Smile and providing a test example in the form of your "image2.png". I'll add support for such files in the next version.
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 19 Oct 2011, 23:11    Post subject:  

Hey vovchik

I know how long you have been trying to remove the imagemagick dependency in the backend
while using your overlay app pikonahttp://www.murga-linux.com/puppy/viewtopic.php?search_id=1673665206&t=49129
congratulations on getting a test run example going with just BaCon and HUG
and no other dependencies
and at such a small size

Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3219

PostPosted: Thu 20 Oct 2011, 01:57    Post subject:  

wjaguar wrote:
vovchik wrote:
I am certain that mtpaint can do that type of thing well - I just don't know how.

In point of fact, it cannot - at the moment. Wink So, thank you for demonstrating to me that yet another unholy perversion of PNG format does indeed exist in the wild Smile and providing a test example in the form of your "image2.png". I'll add support for such files in the next version.


I don't know much about mtPaint, but I just dragged the two images onto the canvas and saved. (vovchik's looks better, though Smile )
image3.png
 Description   Adding a little transparency
 Filesize   16.57 KB
 Viewed   826 Time(s)

image3.png

image4.png
 Description   
 Filesize   16.38 KB
 Viewed   757 Time(s)

image4.png

Back to top
View user's profile Send private message 
wjaguar

Joined: 21 Jun 2006
Posts: 216

PostPosted: Thu 20 Oct 2011, 02:50    Post subject:  

jpeps wrote:
I just dragged the two images onto the canvas and saved. (vovchik's looks better, though Smile )

Precisely. And it is because mtPaint cannot properly read in "image2.png", which uses a palette with partial transparency (the first such image I've ever seen).
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Thu 20 Oct 2011, 02:58    Post subject:  

Dear puppians,

@ Joe
Quote:
getting a test run example going with just BaCon and HUG


Thanks. There is no HUG - just straight calls to gtk/gdk, which makes the code more efficient and smaller. The down side of ths approach is that it looks almost like C, but that's OK if it gets the job done.Smile I think I am finally ready to modify Picona, since I already have routines worked out for scaling and overlay. It's now a matter of reviewing my old Picona code and making the changes. It will be a small, single binary in the end, which is what I am after, and will run on any Linux/Unix with GTK installed. I just have to sit down and do it.

@ jpeps
Quote:
I just dragged the two images onto the canvas


In my demo, in creating the final image, the 3D image is not on top but on the bottom, and the clear orb is on top - the overlay. The reason that the 3D is visible is because of the alpha transparency in the orb. That's why it looks better - apart from the scaling issue. Smile Moreover, the merged image canvas (background) in the new image is transparent. I am fairly certain that wjaguar will include this capability in a new version of mtpaint, so we just have to wait a bit.

With kind regards,
vovchik
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3219

PostPosted: Thu 20 Oct 2011, 03:30    Post subject:  

wjaguar wrote:
jpeps wrote:
I just dragged the two images onto the canvas and saved. (vovchik's looks better, though Smile )

Precisely. And it is because mtPaint cannot properly read in "image2.png", which uses a palette with partial transparency (the first such image I've ever seen).


Yeah, I cheated and filled in the hole with paint for image3 Smile
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3219

PostPosted: Thu 20 Oct 2011, 04:35    Post subject:  

vovchik wrote:

In my demo, in creating the final image, the 3D image is not on top but on the bottom, and the clear orb is on top - the overlay. The reason that the 3D is visible is because of the alpha transparency in the orb. That's why it looks better


Converted the image2.png to a jpg first so it was more workable.
image5.png
 Description   
 Filesize   10.42 KB
 Viewed   1097 Time(s)

image5.png

Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Thu 20 Oct 2011, 06:07    Post subject:  

Dear jpeps,

The reason jpg images are never used for icons is because they, by design, have no transparency. The "object" in the centre will always be accompanied by a background of some sort and there will be some dithering with respect to colours. There is, moreover, no alpha channel. Using jpgs for icons is, on the whole, a non-starter unless you add a transparent background and then remove the existing colour around an object and save back in a format that recognizes transparency such as png. Xpm images do have transparency, but they are limited in the number of colours they can display. Mac OSX icns and M$ ico support transparency and millions of colours, too, but for *nix, the standard is png or svg (for vector graphics).

With kind regards,
vovchik
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3219

PostPosted: Thu 20 Oct 2011, 11:43    Post subject:  

Very interesting, vovchik. mtPaint isn't recognizing the transparency format, so maybe that's why the jpg format looked better...although it comes with a backround, as you noted. A gif transformation (which also supports an alpha channel) looked the same as png.

You can create the transparency with the "opacity" slider in the layers window (as I did in my post) , although the background is part of the object.

It looks like your experiment will lead to some mtPaint development by wjaguar. (wow...he doesn't miss anything! Smile )
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Sat 22 Oct 2011, 00:52    Post subject:  

here is an update of bacon2bbc
It was bacon2bbc but since this is modified lets use bacon2bb

it now reduces the code 400 lines by using a DATA command

I want to comment that GatorDog was kind enough to show me
quite a few ways to improve the code from a PM he sent
I havent used all of his suggestions because
I need to keep it as simple as possible *so I understand what I'm doing* and at the same time
using the good ideas (the other ideas I will apply to my future snippets though so thanks rod )

there is a basic progress view now just dots but... hey
the linux kernel does that too Very Happy

I will keep at this I am writing a script to do this faster so more to come
but its complete for practical use for adding color to the forum posts
and simple enough for a code example to hack at
bacon2bb.tar.gz
Description 
gz

 Download 
Filename  bacon2bb.tar.gz 
Filesize  19.4 KB 
Downloaded  271 Time(s) 
bb.png
 Description   
 Filesize   8.56 KB
 Viewed   1037 Time(s)

bb.png


_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though

Last edited by big_bass on Sat 22 Oct 2011, 17:16; edited 1 time in total
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Sat 22 Oct 2011, 04:55    Post subject: bb code listing  

Dear Joe,

I appreciate what you are trying to do - make code listings more readable - but the "[quote]" solution seems to have its own problems. While the color coding is great, "[quote]" eliminates all leading white space, so far as I can tell, which means all structural indentation disappears. The "[code]" directive preserves the structure a bit by converting tabs into single spaces but, alas, has no color. BB code does not seem to allow for the best of both worlds, unfortunately, so it is either colors for keywords and no structure or structure and no colored keywords. I have tried all sorts of combinations to get something working in a BB sandbox http://www.bbcode.org/playground.php and have failed. Any ideas or workarounds?

With kind regards,
vovchik
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 26 of 36 [526 Posts]   Goto page: Previous 1, 2, 3, ..., 24, 25, 26, 27, 28, ..., 34, 35, 36 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0886s ][ Queries: 12 (0.0121s) ][ GZIP on ]