comparison _xampp/contrib/mingstats_swf.php @ 0:b12c99b7c3f0

commit for previous development
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 19 Jan 2015 17:13:49 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b12c99b7c3f0
1 <?php
2
3 // Copyright (C) 2005 Kai Seidler, oswald@apachefriends.org
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //
19
20 $values["A"]=rand(20,230);
21 $values["B"]=rand(20,230);
22 $values["C"]=rand(20,230);
23 $values["D"]=rand(20,230);
24 $values["E"]=rand(20,230);
25 $values["F"]=rand(20,270);
26 $values["G"]=rand(20,270);
27 $values["H"]=rand(20,270);
28
29 $max=270;
30
31 $width=540;
32 $height=320;
33
34 $m = new SWFMovie();
35 $m->setDimension($width, $height);
36 $m->setBackground(251, 121, 34);
37 $m->setRate(30.0);
38
39 $font = new SWFFont("BabelSans-B.fdb");
40
41 $g = new SWFGradient();
42 $g->addEntry(0.0, 0, 0, 0);
43 $g->addEntry(1.0, 0xff, 0xff, 0xff);
44
45 function box($w,$h)
46 {
47 global $g;
48
49 $s = new SWFShape();
50 $f=$s->addFill($g, SWFFILL_LINEAR_GRADIENT);
51 $f->scaleTo(0.05);
52 $s->setRightFill($f);
53 //$s->setRightFill($s->addFill(255,255,255));
54 $s->movePenTo(0, 0);
55 $s->drawLineTo($w, 0);
56 $s->drawLineTo($w, -$h);
57 $s->drawLineTo(0, -$h);
58 $s->drawLineTo(0, 0);
59 return $s;
60 }
61
62 function text($string)
63 {
64 global $font;
65
66 $t = new SWFText();
67 $t->setFont($font);
68 $t->setColor(255, 255, 255);
69 $t->setHeight(20);
70 $t->addString($string);
71
72 return $t;
73 }
74
75 $t=$m->add(text("Balkendiagramm mit PHP und Ming"));
76 $t->moveTo(30,40);
77
78 $i=0;
79 reset($values);
80 while(list($key,$value) = each($values))
81 {
82 $text[$i]=$m->add(text($key));
83 $text[$i]->moveTo(50+$i*60,50);
84 $box[$i]=$m->add(box(50,1));
85 $box[$i]->moveTo(30+$i*60,$height-20);
86 $box[$i]->setName("box".$i);
87 $i++;
88 }
89
90 for($f=0;$f<=$max;$f+=5)
91 {
92 $i=0;
93 reset($values);
94 while(list($key,$value) = each($values))
95 {
96 $h=$value;
97 if($h>$f)
98 {
99 $box[$i]->scaleTo(1,$f);
100 $text[$i]->moveTo(50+$i*60,$height-$f-25);
101 }
102 $i++;
103 }
104 $m->nextFrame();
105 }
106
107 $m->add(new SWFAction("stop();"));
108 $m->nextFrame();
109
110 header('Content-type: application/x-shockwave-flash');
111 $m->output();
112 ?>