Sponsored Content
The Lounge What is on Your Mind? Merry Xmas (special present inside) Post 303009984 by bakunin on Saturday 23rd of December 2017 10:21:10 PM
Old 12-23-2017
Merry Xmas (special present inside)

A Merry Xmas to all of you.

And, as a special present to vbe (he knows why) a little exercise:

Code:
#! /bin/ksh

pPrintSnow ()
{
typeset -i iLen=$1
while (( iLen )) ; do
     if ! (( RANDOM % 31 )) ; then
          printf "%1s" "."
     else
          printf "%1s" " "
     fi
     (( iLen -= 1 ))
done
return 0
}



pPrintTreeLine ()
{
typeset -i iWidth=$1
typeset -i iTermWidth=$COLUMNS
typeset -i iOffset=$(( (iTermWidth - iWidth)/2 ))

pPrintSnow $iOffset
while [ $iWidth -gt 0 ] ; do
     if !   (( RANDOM % 11 )) ; then
          printf "%s" "$(tput sgr0;tput bold)i$(tput sgr0;tput dim)"
     elif ! (( RANDOM %  7 )) ; then
          printf "%s" "O"
     elif ! (( RANDOM % 13 )) ; then
          printf "%s" "O"
     else
          printf "%s" "*"
     fi
     (( iWidth -= 1 ))
done
pPrintSnow $iOffset
printf "\n"

return 0
}



pPrintTrunk ()
{
typeset -i iTrunkWidth=$(( $1 - 2 ))
typeset -i iTrunkHeight=$2
typeset -i iTermWidth=$COLUMNS
typeset -i iOffset=$(( (iTermWidth - iTrunkWidth)/2 ))
typeset -i iCnt=0

if [ $iTrunkWidth -lt 1 ] ; then
     (( iTrunkWidth = 1 ))
     (( iOffset = (iTermWidth - iTrunkWidth ) / 2 ))
fi

while (( iTrunkHeight )) ; do
     if (( iTrunkHeight == 1 )) ; then
          printf "%${iOffset}s/" " "
     else
          printf "%${iOffset}s " " "
     fi
     (( iCnt = iTrunkWidth ))
     while (( iCnt )) ; do
          printf "%s" "|"
          (( iCnt -= 1 ))
     done
     if (( iTrunkHeight == 1 )) ; then
          printf '\\ \n'
     else
          printf '\n'
     fi
     (( iTrunkHeight -= 1 ))
done
return 0
}



# main ()
typeset -i iHeight=$1
typeset -i iCnt=0

eval $(resize)
tput dim
(( iCnt = 1 ))
while [ $iCnt -le $(( iHeight *2 )) ] ; do
     pPrintTreeLine $iCnt
     (( iCnt += 2 ))
done
pPrintTrunk $(( iHeight / 2 )) $(( iHeight / 5 ))
tput sgr0

exit 0

bakunin

Last edited by bakunin; 12-24-2017 at 01:31 AM..
This User Gave Thanks to bakunin For This Post:
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find the count of records from tables present inside a file.

hi gurus, I am having a file containing a list of tables.i want to find the count of records inside thes tables. for this i have to connect into database and i have to put the count for all the tables inside another file i used the following loop once all the tablenames are inside the file. ... (1 Reply)
Discussion started by: navojit dutta
1 Replies

2. What is on Your Mind?

Merry Christmas

Merry Christmas and all best wishes to all fox in this forum salute from Croatia (0 Replies)
Discussion started by: solaris_user
0 Replies

3. Shell Programming and Scripting

want to remove comma present inside double qoute

Hi friends... I have a dat file like below:- test_file.dat abc,ttt,"""123,89.98",yyu,opp vvv,"23,76.68",w564,"54,98.87",985 i need the remove the comma present inside the double qoute as output:- out_test_file.dat abc,ttt,"""12389.98",yyu,opp vvv,"2376.68",w564,"5498.87",985... (6 Replies)
Discussion started by: gani_85
6 Replies

4. Shell Programming and Scripting

Replace Special Character With Next Present Byte

Hi, First find the special character, from the special character take next two bytes convert the bytes to decimal and replace with next present byte of decimal value times. E.g. Input: 302619ú1A? Output: 302619(3 spaces for ú1A)?????????????????????????? Thanks, Dines (27 Replies)
Discussion started by: dineshnak
27 Replies

5. What is on Your Mind?

Merry XMAS, happy holidays etc. everybody...

Have a laugh... https://www.youtube.com/watch?v=HZWQcl1C-c8 Bazza... (4 Replies)
Discussion started by: wisecracker
4 Replies
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy