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