Added lot of junk laying around on harvie.cz
[mirrors/Programs.git] / php / skripty / sinus_curve.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 = (2*PI()); //When X >= reset, then it will be reseted to zero
11 $zoom = 1; //1 //This will repeat every line few times
12 $offset = 1.1; //1.1 //1 //0 -> Zero offset will draw only half of sin curve.
13 $width = 35; //20 //35 //40 //This will stretch every line.
14 $sleep = "15000"; //15000 - Wait between lines in microseconds
15 $line = (" "); // " " // ":" //chr ( 176 ) //This is the string, that will be repeated from display start to the curve (curve inlay).
16 $endline = ("+\n"); // "#\n" // ".\n" //chr ( 219 )."\n" //This is the string, that will be printed at end of every line (curve outline).
17
18 //Code:
19 echo ("[SinusCurve]-[c][Harvie][2oo6]\n\n");
20 echo ("0| y\n");
21 echo ("-|--------------------------------------------->\n");
22 echo ("x|\n");
23 echo (" V\n\n");
24
25 sleep(2);
26
27 $pos = $start;
28 while(1) {
29
30 usleep($sleep); //Wait in microseconds
31
32 $znaku = ((sin($pos) + $offset) * $width);
33
34 $zoom2 = $zoom;
35 while ($zoom2 > 0) {
36
37 $znaku2 = round($znaku); //It looks better after round ;)
38 while ($znaku2 > 0) {
39 echo $line;
40 $znaku2 = ($znaku2 - 1);
41 }
42 //echo(" ".$pos." "); //Debug
43 echo ($endline);
44
45 $zoom2 = ($zoom2 - 1);
46 }
47
48 //echo(" ".$pos." "); //Debug
49 $pos = ($pos + $step);
50 if ($pos >= $reset) {
51 $pos = 0;
52 }
53
54 }
55 ?>
This page took 0.377756 seconds and 4 git commands to generate.