27/10/2007, 18h13
|
#3
|
|
|
Re: HTA : Graphisme et Animation en pure CSS + Python
Salvatore a écrit :
> Bonjour la communauté,
>
> Après avoir testé VML, j'ai cherché quelque
> de moins gourmand en ressource pour réaliser
> des graphes sur une page HTML
> Je suis tombé sur cet article : http://www.davidbetz.net/graphics/
> J'ai décidé de voir ce que cela donner en Python :-)
>
> Cordialement
>
> Salvatore
>
>
> Notez au passage la fonction "win32gui.PumpWaitingMessages()"
> qui permet une animation fluide (:-) M.C)
> Voici un début en Python:
>
>
> <code>
>
> <html>
> <head>
> <TITLE>HTML Application Example</TITLE>
> <HTA:APPLICATION ID="HTAEx" APPLICATIONNAME="HTAEx" ICON="e.ico"
> WINDOWSTATE="normal">
> <style type="text/css">
> .Ink {
> position: relative;
> background-color: transparent;
> border-top: 1px solid transparent;
> width: 1px;
> height: 1px;
> }
> .InkV {
> position: absolute;
> background-color: transparent;
> border-top: 1px solid transparent;
> width: 1px;
> height: 1px;
> }
> #dynamicAttacher {
> background-color: #677767;
> width: 800px;
> height:800px;
> border: 0px solid black;
> padding:0px;
> margin:0px;
> }
>
> </style>
>
> <script language=python>
> import win32gui
> dynamicAttacherObj = document.getElementById('dynamicAttacher');
> def plotPixel(x,y):
> pixel = document.createElement('div')
> pixel.style.color = "#FF0000";
> pixel.className = 'Ink';
> pixel.style.left = `x` + 'px';
> pixel.style.top = `y` + 'px';
> document.all.dynamicAttacher.appendChild(pixel)
>
> def DrawVerticalLine(x, y, l, c):
> y = y+15
> longPixel = document.createElement('div');
> longPixel.className = 'InkV';
> longPixel.style.border = '0';
> longPixel.style.backgroundColor = c;
> longPixel.style.height = str(l) + 'px';
> longPixel.style.left = str(x) + 'px';
> longPixel.style.top = str(y) + 'px';
> document.all.dynamicAttacher.appendChild(longPixel );
>
>
> def DrawHorizontalLine(x, y, l, c):
> longPixel = document.createElement('div');
> longPixel.className = 'Ink';
> longPixel.style.borderTopColor = c;
> longPixel.style.width = str(l) + 'px';
> longPixel.style.left = str(x) + 'px';
> longPixel.style.top = str(y) + 'px';
> document.all.dynamicAttacher.appendChild(longPixel );
>
>
> def test():
> dynamicAttacherObj = document.getElementById('dynamicAttacher');
> back = dynamicAttacherObj.innerHTML
> for i in range(800):
> DrawHorizontalLine(0,i,800,"#00ff00")
> DrawVerticalLine(i,0,800,"#ffff00")
> win32gui.PumpWaitingMessages()
> dynamicAttacherObj.innerHTML = back
>
> def init():
> DrawHorizontalLine(0,400,800,"#fff")
> DrawVerticalLine(400,0,800,"#ff0000")
> test()
>
>
> </script>
> </head>
>
> <body onLoad="init()">
> <div id="dynamicAttacher"></div>
> </body>
>
> </html>
>
> </code>
Je n'ai pas testé mais il y a pyswf par contre à part les exemple sur le
site des swftools il n'y a rien.
|
|
|
|