Pseudo-3D effect in text mode...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Pseudo-3D effect in text mode...
# 1  
Old 08-06-2013
Pseudo-3D effect in text mode...

This is a DEMO only...

Someone recently asked about creating a box to make something look nicer on screen.
I suggested that with careful colouring a 3D effect could be created...

Linux version; this also works on a Macbook Pro but is not as easy to see as the other code below:-

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"

And yeah you guessed it, overlay and time the two, use Corona688's version of INKEY$ and create a press-able button as a starter text mode GUI using the cursor keys and ENTER key as a pseudo mouse.

All good fun eh!...
Pseudo-3D effect in text mode...-3djpg
This User Gave Thanks to wisecracker For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Text mode AF spectrum analyser.

Well guys, this MUST be a first. This is DEMO code only and has NO error detection or correction, nor out of bounds checking. I have succumbed to Python and scipy to do the FFT heavy lifting as I have absolutely no idea where to start do such a thing using AWK. This is a taster for me to... (7 Replies)
Discussion started by: wisecracker
7 Replies

2. OS X (Apple)

Text mode dual _LED_ VU meter.

Hi guys... Finally decided to release this, I have a python version too but that is unimportant to me. It is a text mode "Dual_VU.sh" meter. It actually calls dash as the interpreter but change the shebang to suit yourselves. It uses the bell character for overload per channel and... (1 Reply)
Discussion started by: wisecracker
1 Replies

3. Hardware

How to go to GUI from text mode?

Dear All, i am trying to install the redhat linux using graphical mode...but it stucks while probing video card...i have installed linux using text mode it works fine and whole the installation goes fine. after installation if i give startx command it again stucks....looks like a vga card... (9 Replies)
Discussion started by: zaheer.gr8
9 Replies

4. SuSE

Convet Linux OS from text mode to graphic mode

Hi All, I used to have my suse linux(VM) server in graphic mode but not anymore since morning. I cant rolback since i loose somuch work. Any idea how to it back to normal. Thanks (6 Replies)
Discussion started by: s_linux
6 Replies

5. Solaris

How to switch from GUI to text mode?

Hi all I have installed solaris 5.10 and it is loading in GUI mode by default. I want to load in text mode by default. How to do this? How to switch from GUI to text mode and vise versa.? Please help.. (2 Replies)
Discussion started by: johnl
2 Replies

6. Solaris

pseudo: [ID 129642 kern.info] pseudo-device: vol0

Hi I have a system that gave me some messages on bootup that I was not used to seeing: pseudo: pseudo-device: vol0 genunix: vol0 is /pseudo/vol@0 these came with these: Feb 13 17:42:17 system1 eri: SUNW,eri0 : 100 Mbps full duplex link up Feb 13 17:42:21 system1sendmail: My unqualified... (0 Replies)
Discussion started by: mndavies
0 Replies

7. UNIX for Dummies Questions & Answers

emacs in text mode how to?

hello all I saw somewhere there is some kind of version of emacs in full text mode ? how can I get/download it? if I have ordenry emacs installed can I start it in text mode? thanks (2 Replies)
Discussion started by: umen
2 Replies

8. AIX

Startup AIX in GUI or text mode

Can I know is there anyone know how to statup AIX in GUI and text mode? Thank You..... (2 Replies)
Discussion started by: dwarf007
2 Replies

9. UNIX for Advanced & Expert Users

simulate text mode in X-Windows

Hi. I need to run old full-screen text-mode application under X-Windows. (By the way it is touch-screen calibrator firmware). The screen resolution is to be 1280x1024 exactly. The program expect text-mode geometry 80x25. Running xterm (no window manager) I have adjusted the font pararameters to... (3 Replies)
Discussion started by: shestero
3 Replies

10. IP Networking

how to get online in text mode with redhat 7.1 ?

Hi people... Is there any way to configure the conection i text mode ? I need to know how to make the modem work and how to configure a dial up conection in text mode by redhat 7.1 and if possible how to configure the email... I use the workstation installation...any help will be welcome...... (2 Replies)
Discussion started by: furioso
2 Replies
Login or Register to Ask a Question