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 29 Apr 2016, 02:02
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
text2xpm in shell
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [34 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4645

PostPosted: Thu 29 Dec 2011, 18:21    Post subject:  

01micko wrote:
Ok, so I put this to actual use

Note the feature request.
that was exactly the kind of thing I had in mind when I wrote this. Things like partview, battview, tempview... Then I found out how to do the same thing in svg much easier, but it is still good for xcb/X11+xpm only apps I guess.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8461
Location: qld

PostPosted: Tue 03 Jan 2012, 15:31    Post subject:  

Another one,

cpuicon

There's a difference, no thread topic, this is just a link to the source code and support files including a build script.

You could say I'm going a bit mad on tray icons! But I find them more useful than widgets or conky as I actually use them! They don't look fantastic but they are functional.

techno, care to share the svg knowledge?

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4645

PostPosted: Tue 03 Jan 2012, 23:38    Post subject:  

Try playing with this:
(save as <something>.svg and open with viewnior)
Code:
<svg>
  <rect width="100"
     height="50"
     x="0"
     y="0"
     style="font-size:12;fill:#0000ff;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
     id="rect1" />
  <rect
     width="50"
     height="50"
     x="0"
     y="0"
     style="font-size:12;fill:#ff00ff;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
     id="rect2" />
  <text
     x="0"
     y="50"
     style="font-size:12;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;"
     id="text1">
    <tspan
       id="tspan1">test</tspan>
  </text>
</svg>

you can add as many rectangles as you want, or you can save some svgS from inklite (uncompressed) for other shapes etc... (crap, now Iremember where I posted this before - it was in the project management / planner thread ... covered lines too)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3217

PostPosted: Wed 04 Jan 2012, 07:16    Post subject:  

01micko wrote:
Another one,

cpuicon


You could also eliminate a folder with 100 xpms, etc, with a small tray icon that just toggles cpu-usage on and off in a small window when you need it.
cpu.png
 Description   
 Filesize   47.85 KB
 Viewed   503 Time(s)

cpu.png

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


Joined: 18 May 2008
Posts: 4645

PostPosted: Wed 04 Jan 2012, 13:32    Post subject:  

this just requires echo and variables to generate svg
Code:
echo '<svg>
   <rect width="100" height="50" x="0" y="0" id="rect1" style="font-size:12;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
   <rect width="50" height="50" x="0" y="0" id="rect2" style="font-size:12;fill:#ff00ff;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
   <ellipse cx="24" cy="24" rx="24" ry="24" style="font-size:12;fill:#ff0000;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
   <ellipse cx="74" cy="24" rx="24" ry="24" style="font-size:12;fill:#00ff00;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
   <text x="12" y="25" id="text1" style="font-size:12;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;">test</text>
   <path d="M 50 25 L 100.0 25.0 " style="font-size:12;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;"/>
</svg>' >$FILE

simply edit the fixed parameters in place and then just replace the rest with single quoted variables. ex.

... width="50" .... becomes ... width="'${WIDTH}'" ...

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3217

PostPosted: Thu 05 Jan 2012, 03:52    Post subject:  

cpu-usage with Eterm

wrapper (toggle from tray):
Code:

#/bin/sh

var="$(pidof cpu)"

if [ "$var" ]; then
  kill -9  "$var"
else
Eterm --trans --no-cursor --buttonBar no --scrollBar no -x -f WHITE -g 10x2+890+682 -e cpu &
fi
cpu.png
 Description   
 Filesize   29.7 KB
 Viewed   467 Time(s)

cpu.png

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

Joined: 20 Jul 2010
Posts: 3707
Location: New Zealand

PostPosted: Thu 28 Jan 2016, 04:51    Post subject:  

Interesting. Will have to find a use for this.
I tried putting a "!" in my string but it was rejected:

Code:
# ./text2xpm "Very clever Techno !" >/tmp/tmp.xpm
bash: !": event not found
#


Had to leave out the !

ps: Is there any way to get a line wrap so that I can have two or more lines displayed in the xpm?

cheers!
Screenshot.png
 Description   
 Filesize   12 KB
 Viewed   200 Time(s)

Screenshot.png

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


Joined: 18 May 2008
Posts: 4645

PostPosted: Thu 28 Jan 2016, 05:17    Post subject:  

I'll have to check the quotes in all the subfunctions... I just reworked the glyphs for vertically oriented text ... still not implemented, but here are the strings for them ... our forum still hasn't figured out {overflow:scroll} so it won't be readable until cut/pasted.

As for extra lines, I'll probably convert it to functions, so that each arg is a separate line, then a wrapper can split the arguments by something like:
(oh yeah, this forum also adds spaces to each line, so delete the space that it adds to IFS)
Code:
IFS="
"
wrapper $Text



Copy/paste to editor to read
Code:
"                                                                                                                                                                                                                                                                                                                                                                                                       #                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 "
"                ######              #    ###     #   ##   ####           #     #   #####         ####    ##            ##   ###     #######       ########     #   ##      ##    ##      ######     #        #   #             ##  #####   ##########   #        #   #            #       ##            #   ##########   ##########    ########     ####         ########  #  ####   ##    ##   ###    #            #########    ####         #########    ##      ##   ###          ##       #       ######       #####        #   #    ##########       ### #     #              #      #      ######            #   ## ########           #            #       ######       ######       #####        #####       #########     ##           #   #            #       #######      ###          ######       ##   ##      ########     #     #   ##                         ####### #      #  #        ##  ###    ##     ##     #                ##  #  #           #                         #      #            #          #  #       #       #        #                                ##             ##                                                             #           #             #           #                        ##             "
"               #      #             #   #   ##   #   # # #    #   ##########   #  #     #   #   #    #   # ##         #  # #   #   #   #   #     #   #        # # #  #    #        #    #      #    #        #   #            #    #  #        #        #        #   #########     #     #              #    ##                ##     #        #   #    #       #       ###  #    # #     #    #   #   #                     #       ###               #     ##  ##        ##        # #      #      #  #  #      #     #      #     #       #   #       #  #  #   #   #            ###  # #    #                  #      #       #    #    #             #      #            #            #     #      #     #       #   #       #            #   # #      #     #           #          ##              #        # #            #   #    ##    #     #                       # #    # #   ##########    #   #   #     #   #  #   #             ###   ##    #         #     #####                #      #            #          #  #        #     #        # #                            #    ##          #  #                                      #    #   ####         #           #      #      #           ##############         ##               "
"              #        #   ##########   #     #  #   #  ##    #    #     #     #  #     #   #   #    #   #   ##       #   #    #   #    #   #   #    #       #   #    #   #        #   #        #   #   #    #   #   #        #    #   #       #        ##########   #        #     #   #               #      ##             #       #        #   #    #       #      # #   #    ##      #    #   #   ##########            #          ###         ###        ##            #####   #  ##    #      #  #  #      #     #      #     #      #     #      #  #  #   #   #           #   # # #    #         ## #######              #     #  #     ##########       #####       #            #     #      #     #      #     #      #            #  #  #      #     #            #           ##        ####          #              #  #    # #   #    #           ####### ##   # #    # #      #  #      ###########   #### #  #  #             #   # # #     ##     ##    ##     ##              #   #######         #          #  #         #   #        #   #             ###          ###     ###       #   ### ##      ##  ###  ####            ###  ###                ##### #####  ##### ##### #           ##           #       ##    #############"
"              #        #    #       #   #      # #   #   #    #     ##   #     #  #     #   #   #    #   #     ##     #   #    #   #    #   #   #    #       #   #    #   #        #   #        #   #   #    #   #   #        #        #       #        #        #            #      # #                #      ##            #        #        #   #    #       #     #  #   #    #       #   #    #   #                     #          ###            #       ##          ##        #    #   #      #  #  #      #     #      #     #      #     #      #  #  #    #########      #   # # #    #            #     #              #      ##      #        #      #            #            #     #      #     #      #     #      #            #  #  #   #########             #         ##              #         #              #  #    #  ## #   #                         #  ####  #   ##########    #   #   #   #  # ####   #             #   ##   #      #####     #         #             #      #            #          #  #          # #        #     #            #  #          #         ##     #               ##  #  #                  #    #   ####               #      #           ###############           #    ###                   "
"               #      #      #      #   #       ##   #        #       ## #     #  #     #    #   #   #   #       ##   #  # #   #   #    #   #    #   #       #   #    #   #        #   #        #   #   #    #   #   #        #        #       #        #        #            #       #                 #    ##            ##         #        #   #    #       #     #  #   #    #       #   #    #   #                     #       ###      #########      ##  ##     ###          #     ## #      #  #  #       #   #       #     #      #     #      #  #  #       #           #   ##  #     #                 #            ##        #               #      #######       #           #     #       #   #       #     #       #           # #   #      #                  #      ###          ######         # #             #  #    #    ##  #                           #      #       #  #       #  #    #   #  #   #     #             ### #   #               #           #            #      #            #          #  #           #        #       #                                     ##   #                                                                            #           #             #           #  ##                      "
"                ######                   ##      #   #      ##          ##     #####  ##      #######    #             ##   ###     ####  ##      ########   ##########    ########    ##########   ##########   ##########    ########    ##########                       ##    ##########   ##########   ##########   ##########    ########    ##########    ########    ##########    ###   ##    #            #########    ####                      ##      ##                #       ##       #  ##    ##########       #####        #####        #####        #            ###  ##  ##########                             ##########                                #######       #####       #########     #####       #######       #   #       #            ######                                 ##   ##      #####  #     #     #   ##                          ######                    ##   ##     ##     ##    #                 ###                                         #                              #  #                                                                    ##  ##                                                                                                                 ##                        "

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Thu 28 Jan 2016, 08:19    Post subject: very good post.  

I had no knowledge of this post, The script that converts the text string on points with so few lines of code is so clever. and conversion to xpm image not just to understand it at all is great.


Technosaurus can you let me copy you code, to I try to improve my make_dots script?

Very good post..... thanks.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
greengeek

Joined: 20 Jul 2010
Posts: 3707
Location: New Zealand

PostPosted: Thu 28 Jan 2016, 11:01    Post subject:  

technosaurus wrote:
I just reworked the glyphs for vertically oriented text ... still not implemented, but here are the strings for them
I tried grafting them in (hoping for a miracle despite the fact you said it's not implemented yet Smile ) and notice that the dots are missing (replaced by spaces instead?). Is that as expected?

Ash tells me:
Code:
# ./text2xpm "your text here" >/tmp/tmp.xpm
ash: bad number
#
txt2xpm_vert.jpg
 Description   
 Filesize   113.88 KB
 Viewed   157 Time(s)

txt2xpm_vert.jpg

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


Joined: 18 May 2008
Posts: 4645

PostPosted: Thu 28 Jan 2016, 11:40    Post subject:  

greengeek wrote:
technosaurus wrote:
I just reworked the glyphs for vertically oriented text ... still not implemented, but here are the strings for them
I tried grafting them in (hoping for a miracle despite the fact you said it's not implemented yet Smile ) and notice that the dots are missing (replaced by spaces instead?). Is that as expected?
It was supposed to be dots, I just converted it to 1s and 0s and screwed up when I switched it back... though the spaces are more readable.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
solo


Joined: 14 Nov 2013
Posts: 332

PostPosted: Fri 29 Jan 2016, 08:14    Post subject:  

So..

If you would have an extra set of 10 characters that would mimic graph states, like for instance a zero readout would only be dots, and a 1 value would be a row of 6 fills on row 11 (or K) only, and a 2 value would be a row of 6 fills on row 11 plus a row of 6 fills on row 10 (J), and so on and so on, would you then also have a tool for displaying graphs, be it very elementary?!
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4645

PostPosted: Fri 29 Jan 2016, 09:08    Post subject:  

At one point I combined this with my xpm percentbar generator... I can only seem to find the standalone percent bar function though (in bashbox), so I will just post it here for now.
I also reworked partview to use it here.
Code:
percentbar() { #usage: "$0" XX% name=filename fgcolor=XXX bgcolor=XXX height=XXX width=XXX [vertical]
FILENAME=barimage
FGCOLOR=\#000
BGCOLOR=None
PERCENT=50
WIDTH=100
HEIGHT=24
BARSTRING=""
q=0 #should have used for loops
y=0 #not while loops - oops
#get values from input
for x in $@; do
case $x in
   width*)WIDTH=`echo $x |cut -d = -f 2`;;
   height*)HEIGHT=`echo $x |cut -d = -f 2`;;
   fg*)FGCOLOR=`echo $x |cut -d = -f 2`
      [ "$FGCOLOR" != "None" ] && FGCOLOR=\#$FGCOLOR;;
   bg*)BGCOLOR=`echo $x |cut -d = -f 2`
      [ "$BGCOLOR" != "None" ] && BGCOLOR=\#$BGCOLOR;;
   name*)FILENAME=`echo $x |cut -d = -f 2`;;
   *%)PERCENT=`echo $x |cut -d % -f 1`;;
   vert*)VERTICAL="true";;
   *)   echo "usage "$0" XX% name=filename fgcolor=XXX bgcolor=XXX height=XXX width=XXX [vertical]
      colors can be 3 or 6 digit hexadecimal or None ... default is horizontal bars" && exit
      ;;
esac
done


#write header to file
echo '/* XPM */' >${FILENAME}.xpm
echo 'static char *'$FILENAME'_xpm[] = {' >>${FILENAME}.xpm
echo '"'$WIDTH $HEIGHT '2 1",' >>${FILENAME}.xpm
echo '"0 c '$BGCOLOR'",' >>${FILENAME}.xpm
echo '"1 c '$FGCOLOR'",' >>${FILENAME}.xpm

if [ "$VERTICAL" == "true" ];then #vertical bars
BARTOP=$(($HEIGHT*$PERCENT/100))
#generate each line of the image
   while [ "$q" -lt $HEIGHT ]; do
   q=$(($q + 1))
      if [ "$q" -lt $BARTOP ];then
         while [ "$z" -lt $WIDTH ]; do
            BARSTRING=${BARSTRING}0
            z=$(($z + 1))
         done
      else
         while [ "$z" -lt $WIDTH ]; do
            BARSTRING=${BARSTRING}1
            z=$(($z + 1))
         done
      fi
   echo '"'$BARSTRING'"' >>${FILENAME}.xpm
   BARSTRING=""
   z=0
   done
else #horizontal bars
#generate one line of the image
   BARMAX=$(($WIDTH*$PERCENT/100))
   while [ "$q" -lt $BARMAX ]; do
      q=$(($q + 1))
      BARSTRING=${BARSTRING}1
   done
   while [ "$q" -le $WIDTH ]; do
      BARSTRING=${BARSTRING}0
      q=$(($q + 1))
   done
#write a line for each pixel of height
   while [ "$y" -le $HEIGHT ]; do
   echo '"'$BARSTRING'"' >>${FILENAME}.xpm
      y=$(($y + 1))
   done
fi

echo '};' >>${FILENAME}.xpm
}

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4645

PostPosted: Sat 30 Jan 2016, 00:42    Post subject: Re: very good post.  

mister_electronico wrote:
Technosaurus can you let me copy you code, to I try to improve my make_dots script?

Very good post..... thanks.
All of my code is under the Technosaurus Public License which basically says you can do whatever you want with it, but don't expect me to contribute back to it if you put it under a viral license like those of the FSF (GPL, LGPL, AGPL,...)
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8461
Location: qld

PostPosted: Sat 30 Jan 2016, 01:17    Post subject:  

Just for fun I converted text2xpm to C. No other reason. It's basically useless, just an exercise.

Also attached is statically compiled version that should run on most x86 and x86_64 linux OS.

EDIT: updated source, removed crap from a previous attempt
text2xpm.c.gz
Description  source
gz

 Download 
Filename  text2xpm.c.gz 
Filesize  1.71 KB 
Downloaded  35 Time(s) 
texttoxpm.gz
Description  binary -renamed so it doesn't conflict
gz

 Download 
Filename  texttoxpm.gz 
Filesize  11.13 KB 
Downloaded  29 Time(s) 

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 3 [34 Posts]   Goto page: Previous 1, 2, 3 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.0917s ][ Queries: 12 (0.0048s) ][ GZIP on ]