Jump to content
  • 0

Фон


ugg555
 Share

Question

4 answers to this question

Recommended Posts

  • 0

Подскажите почему у меня не работает ! вот код перенесенный с сайта...

<!DOCTYPE html><html> <head>  <meta charset="utf-8">  <title>z-index</title>    <style>  body{  margin:0;}  </style>     </head> <body>  <script type="text/javascript">window.onload = init();function init(){canvas = document.getElementById('canvas');context = canvas.getContext('2d');canvas.width = window.innerWidth - 20;canvas.height = window.innerHeight - 20;canvas.addEventListener('mousemove',MouseMove,false);mouse = {x:0,y:0}particleHolder = [0];x = 900;y = 900;angle = 45;radius = 280;particleCount = 4000;color = ['rgba(0, 118, 163, 0.8)','rgba(141, 198, 63, 0.8)',];function MouseMove(event){	mouse.x = event.pageX - canvas.offsetLeft;	mouse.y = event.pageY - canvas.offsetLeft;}for(i = 0; i < particleCount ; i++){particleHolder.push(new generateParticles());}function generateParticles(){this.x = Math.random()*canvas.width;this.y = Math.random()*canvas.height;this.color = color[Math.floor(Math.random()*color.length)];this.rad = Math.floor(Math.random()*8);}function vibrate(){context.fillStyle = 'white';context.fillRect(0, 0, canvas.width, canvas.height);for(var j = 0; j < particleHolder.length; j++){var p = particleHolder[j];var distanceX = p.x - mouse.x;var distanceY = p.y - mouse.y;particleDistance =  Math.sqrt(distanceX*distanceX + distanceY*distanceY);particleMouse = Math.max( Math.min( 50 / ( particleDistance /p.rad ), 10 ), 0.1 );context.fillStyle=p.color;context.fillRect(p.x-((p.rad*particleMouse)/2),p.y-((p.rad*particleMouse)/2),p.rad*particleMouse,p.rad*particleMouse);}}setInterval(vibrate, 15);};      </script>      <canvas id = 'canvas'></canvas> </body></html>
Link to comment
Share on other sites

  • 0

Заработал вот так! теперь подумаю как  фон превратить

<html> <head>  <meta charset="utf-8">  <title>z-index</title>      <style type="text/css">    body{  margin:0;}    </style> </head>  <body>  <canvas id = 'canvas'></canvas> <script type="text/javascript">window.onload = init();function init(){canvas = document.getElementById('canvas');context = canvas.getContext('2d');canvas.width = window.innerWidth - 20;canvas.height = window.innerHeight - 20;canvas.addEventListener('mousemove',MouseMove,false);mouse = {x:0,y:0}particleHolder = [0];x = 900;y = 900;angle = 45;radius = 280;particleCount = 4000;color = ['rgba(0, 118, 163, 0.8)','rgba(141, 198, 63, 0.8)',];function MouseMove(event){	mouse.x = event.pageX - canvas.offsetLeft;	mouse.y = event.pageY - canvas.offsetLeft;}for(i = 0; i < particleCount ; i++){particleHolder.push(new generateParticles());}function generateParticles(){this.x = Math.random()*canvas.width;this.y = Math.random()*canvas.height;this.color = color[Math.floor(Math.random()*color.length)];this.rad = Math.floor(Math.random()*8);}function vibrate(){context.fillStyle = 'white';context.fillRect(0, 0, canvas.width, canvas.height);for(var j = 0; j < particleHolder.length; j++){var p = particleHolder[j];var distanceX = p.x - mouse.x;var distanceY = p.y - mouse.y;particleDistance =  Math.sqrt(distanceX*distanceX + distanceY*distanceY);particleMouse = Math.max( Math.min( 50 / ( particleDistance /p.rad ), 10 ), 0.1 );context.fillStyle=p.color;context.fillRect(p.x-((p.rad*particleMouse)/2),p.y-((p.rad*particleMouse)/2),p.rad*particleMouse,p.rad*particleMouse);}}setInterval(vibrate, 15);};      </script>     </body></html>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy