Thursday 15 September 2011

javascript - Auto-adjust canvas by itself in all possible sizes -


I have a canvas-FX code ("stars" emulate deep, front-centered, space-navigation ; I was not ) that I want to keep a website as background

I want it so much that when a user changes the size of the window (right or left side or resizing or whatever is pulling), the effect can adjust itself so that the sitar always Also come in the center of the shape or even changing the desktop resolution (I think the FX automatically resets the webcode as it reads).

In addition, I also want the code to adjust itself in the size of the body (i.e. adding up the content from top to bottom, etc.)

Finally, I How can I leave the lower bar, leaving the scroll bar just right?

I'm using the full code here:

     

< Strong>

In the following amendments I have made it to work. First remove the size in your canvas element.

  & lt; Canvas id = "canvas 2d" & gt; & Lt; / Canvas & gt; Change in   

After this I use for my CSS when I am doing full screen with canvas.

  html, body {width: 100%; Height: 100%; Margin: 0; Padding: 0; } # Canvas 2d {status: absolute; Top: 0; Left: 0; }   

And here JS needs to do all this

  // Set width and height to full windows size SCREEN_WIDTH = window . InnerWidth; // Change it to scroll the height to make the document size SCREEN_HEIGHT = document.documentElement.scrollHeight; // Be sure to set the canvas in the screen height and width. Canvas.width = SCREEN_WIDTH; Canvas Het = SCREEN_HEIGHT; // Every time we change the size and height width to window size, and reset the // center point window. Average = function () {SCREEN_HEIGHT = canvas.height = document.documentElement.scrollHeight; SCREEN_WIDTH = canvas.width = document.body.offsetWidth; HALF_WIDTH = SCREEN_WIDTH / 2; HALF_HEIGHT = SCREEN_HEIGHT / 2; };    

No comments:

Post a Comment