This is just a simple DEMO to display a pseudo-3D effect using a bash script. It generates a recessed box and a button and writes some thext inside bot.
There are two pieces of code, one for Linux, and one for OSX 10.7.5...
The Linux version also works on OSX 10.7.5 but is harder to see so a near identical version using the default OSX terminal colours was craeted instead.
You will have to split the two code pieces up yourself to run...
Enjoy finding simple solutions to often very difficult problems...
Bazza...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | Linux version:-
Code:
#!/bin/bash --posix
# This DEMO generates a simple pseudo-3D recessed or raised box in text
# mode format...
#
# Tested on PCLinuxOS 2009 and Debian 6.0.x on their default terminals...
# Checked on a Macbook Pro, 13 inch, OSX 10.7.5 on its default terminal...
vert=1
horiz=1
text1="This is the first line."
text2="This is the second line."
# Bright white on light grey...
printf "\x1B[1;37;47m"
clear
plot()
{
printf "\x1B["$vert";"$horiz"f"
}
box()
{
plot
printf "\x1B[0;30;47m+-----------------------------------\x1B[1;37;47m+"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[0;30;47m| \x1B[1;37;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[0;30;47m| \x1B[1;37;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[0;30;47m+\x1B[1;37;47m-----------------------------------+"
}
button()
{
plot
printf "\x1B[1;37;47m+-----------------------------------\x1B[0;30;47m+"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[1;37;47m| \x1B[0;30;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[1;37;47m| \x1B[0;30;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[1;37;47m+\x1B[0;30;47m-----------------------------------+"
}
# Simple program start...
# Set the box and button positions first...
vert=4
horiz=22
box
vert=9
horiz=22
button
# Now plot the two text lines...
vert=5
horiz=24
plot
printf "\x1B[0;32;47m$text1"
vert=6
horiz=24
plot
printf "\x1B[0;31;47m$text2\n\n\n"
vert=10
horiz=24
plot
printf "\x1B[0;34;47m$text1"
vert=11
horiz=24
plot
printf "\x1B[0;30;47m$text2\n\n\n"
Macbook Pro version:-
Code:
#!/bin/bash --posix
# This DEMO generates a simple pseudo-3D recessed or raised box in text
# mode format...
#
# For a Macbook Pro, 13 inch, OSX 10.7.5...
vert=1
horiz=1
text1="This is the first line."
text2="This is the second line."
# Bright white on light grey...
printf "\x1B[1;97;47m"
clear
plot()
{
printf "\x1B["$vert";"$horiz"f"
}
box()
{
plot
printf "\x1B[0;30;47m+-----------------------------------\x1B[1;97;47m+"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[0;30;47m| \x1B[1;97;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[0;30;47m| \x1B[1;97;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[0;30;47m+\x1B[1;97;47m-----------------------------------+"
}
button()
{
plot
printf "\x1B[1;97;47m+-----------------------------------\x1B[0;30;47m+"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[1;97;47m| \x1B[0;30;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[1;97;47m| \x1B[0;30;47m|"
vert=$[ ( $vert + 1 ) ]
plot
printf "\x1B[1;97;47m+\x1B[0;30;47m-----------------------------------+"
}
# Simple program start...
# Set the box and button positions first...
vert=4
horiz=22
box
vert=9
horiz=22
button
# Now plot the two text lines...
vert=5
horiz=24
plot
printf "\x1B[0;32;47m$text1"
vert=6
horiz=24
plot
printf "\x1B[0;31;47m$text2\n\n\n"
vert=10
horiz=24
plot
printf "\x1B[0;34;47m$text1"
vert=11
horiz=24
plot
printf "\x1B[0;30;47m$text2\n\n\n"
|
There are three very basic fuctions to do this task and it is not difficult to modify these functions to give buttons and recesses of differing sizes. Maybe even a psuedo-pressable button...
You will have to edit the download to remove the lines:- """ Linux version:-
Code: """
And...
""" Macbook Pro version:-
Code: """
And also split the two files for their respective OSes...
Enjoy...