HTML5 canvas tutorial using internal CSS3 and JavaScript 1

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

when i appy setInterval(function)( ), or animation function the page goes blank...
this is eg of my code please help..all things work until i apply any function out of
CODE

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
window.onload = function(){

var canvas = document.createElement("canvas"),
c = canvas.getContext("2d");

canvas.width = 400;
canvas.height = 400;

c.fillStyle = "black";
c.fillRect(0, 0, canvas.width, canvas.height);

var posX = canvas.width / 2,
posY = canvas.height / 2;

setInterval(function)(){
posX += 1 ;
posY += 1 ;
c.fillStyle = "white";
c.fillRect(posX, posY, 10, 10);

}, 30) ;
};
</script>
<style>
body, html{
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>

</body>
</html>

sunrising
Автор

<!DOCTYPE html>
 <html lang="en">
   <head>
  <title>Canvas element</title>
  <style type="text/css">
   #Newcanvas {background-color:yellow;
     border:2px solid black;
   }
   </head>
  
   <body>
  <canvas id="Newcanvas" width="400px" height="400px">
  
  </canvas>
   </body>
  
 </html> 

still blank in crome??

moirangthemvishalsingh
welcome to shbcf.ru