1234567891011121314151617181920212223242526272829303132333435363738 |
- //Variables
- var wSize, hSize;
- //Fonctions de redimensionnement
- function dimensionner(bloc) {
-
- if( typeof( window.innerHeight ) == 'number' )
- hSize = window.innerHeight;
- else if( document.documentElement && document.documentElement.clientHeight )
- hSize = document.documentElement.clientHeight;
- if( typeof( window.innerWidth ) == 'number' )
- wSize = window.innerWidth;
- else if( document.documentElement && document.documentElement.clientWidth )
- wSize = document.documentElement.clientHeight;
- //alert("Largeur : " + wSize + " Hauteur : " + hSize);
- document.getElementById(bloc).height = hSize;
- document.getElementById(bloc).width = wSize;
- }
- window.onload = function(){ dimensionner("canvas") };
- window.onresize = function(){ dimensionner("canvas") };
- //Propriétés
- var canvas = document.querySelector('#canvas');
- var context = canvas.getContext('2d');
- //Main
- context.lineWidth = "5";
- function mainLoop() {
- //Affichage
- context.strokeStyle = "blue";
- context.strokeRect(1, 1, wSize-30, hSize-30);
- }
- //Loop
- setInterval(mainLoop, 1000);
|