A Freebie Text Mode Plot, (Drawing), Function...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers A Freebie Text Mode Plot, (Drawing), Function...
# 1  
Old 03-30-2013
A Freebie Text Mode Plot, (Drawing), Function...

This is probably common knowledge to the big guns but this is for newbies...

This is a demo using simple plot function using bash.

In a default Terminal...

It clears the window, sets the cursor to the top left hand corner, draws a triangle inside the window, writes a string inside the triangle and resets the command prompt at the top left hand corner and finally stops...

Code:

#!/bin/bash

# $VER: plot.sh_Version_0.00.10_Public_Domain_2013_B.Walker.
# A means of shifting the cursor and text printing at the same time inside one function.

# Positional _plot_ function...
plot() { printf "\x1B["$vert";"$horiz"f$char" ; }

# A simple clear screen function just for added fun...
# I know, I KNOW, I can use clear but that defeats the reason for this plot function!
clrscn()
{
for vert in $( seq 1 64 )
do
	printf "\n"
done
# Set the cursor to the top left hand corner.
horiz=1
vert=1
char=""
# Now use plot with its required _arguments_ after the function call.
plot $vert $horiz $char
}

clrscn
# Just a delay, nothing more...
sleep 1

# Draw a tringle upwards slope.
horiz=20
char="*"
for vert in $( seq 22 -1 2 )
do
	# Remember; _arguments_ added after the function call...
	plot $vert $horiz $char
	horiz=$[ ( $horiz + 1 ) ]
done

# Shift back 1 horizontal position for triangle apex...
horiz=$[ ( $horiz - 1 ) ]

# Now draw the the triangle's downards slope.
for vert in $( seq 2 1 22 )
do
	plot $vert $horiz $char
	horiz=$[ ( $horiz + 1 ) ]
done

# Draw the triangle's bottom line...
horiz=21
vert=22
char="***************************************\n"
plot $vert $horiz $char

# Finally write a string inside the triangle.
horiz=24
vert=21
char="Plotting and drawing the easy way.\n\n\n"
plot $vert $horiz $char

# Place the command prompt at the top...
horiz=1
vert=1
char=""
plot $vert $horiz $char

# Plot function end...

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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:- ... (0 Replies)
Discussion started by: wisecracker
0 Replies

2. Programming

which function copies data from user to kernel mode

when transitionaning from user to kernel mode which function copies data from user mode buffer to kernel mode? (5 Replies)
Discussion started by: rupeshkp728
5 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. Shell Programming and Scripting

MODE function in awk

Hello, Can someone pls help me with some statistical calculation in awk In excel there is a statistical function called "Mode". How Mode works: MODE returns the most frequently occurring, or repetitive, value in array or range. Eg if we have 5 numbers in 5 different columns... (12 Replies)
Discussion started by: Needhelp2
12 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. 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