added tips to lamer.bash help
[mirrors/Programs.git] / php / skripty / fce.php
1 <?php
2 //This will draw the ASCII neverending sinus curve.
3 //Writen by (c) Harvie in 2oo6
4 //This is script for PHP CLI (Not WebPage).
5 //You can port it to web by replacing "/n" by "<br>/n"
6
7 //Settings:
8 $start = 0; //0 //First X
9 $step = 0.1; //0.1 //Increase X on every line by this number
10 $reset = 6.2; //When X >= reset, then it will be reseted to zero
11 $zoom = 1; //1 //This will repeat every line few times
12 $sleep = "15000"; //15000 - Wait between lines in microseconds
13 $line = (" "); // " " // ":" //chr ( 176 ) //This is the string, that will be repeated from display start to the curve (curve inlay).
14 $endline = ("+\n"); // "#\n" // ".\n" //chr ( 219 )."\n" //This is the string, that will be printed at end of every line (curve outline).
15
16 //Function:
17 //You can specify yours function here:
18 function func($x) {
19
20 $offset = 1.1; //1.1 //1 //0 -> Zero offset will draw only half of sin curve.
21 $width = 35; //20 //35 //40 //This will stretch every line.
22
23 $y = ( (sin($x) + $offset) * $width );
24 //echo("Debug: ".$x." ".$y." "); //Debug
25 return ($y);
26
27 }
28
29 //Code:
30 echo ("[SinusCurve]-[c][Harvie][2oo6]\n\n");
31 echo ("0| y\n");
32 echo ("-|--------------------------------------------->\n");
33 echo ("x|\n");
34 echo (" V\n\n");
35
36 sleep(2);
37
38 $pos = $start;
39 while(1) {
40
41 usleep($sleep); //Wait in microseconds
42
43 $znaku = func($pos);
44
45 $zoom2 = $zoom;
46 while ($zoom2 > 0) {
47
48 $znaku2 = round($znaku); //It looks better after round ;)
49 while ($znaku2 > 0) {
50 echo $line;
51 $znaku2 = ($znaku2 - 1);
52 }
53 //echo(" ".$pos); //Debug
54 echo ($endline);
55
56 $zoom2 = ($zoom2 - 1);
57 }
58
59 $pos = ($pos + $step);
60 if ($pos >= $reset) {
61 $pos = 0;
62 }
63
64 }
65 ?>
This page took 1.845158 seconds and 4 git commands to generate.