0
   

Need help with looping and canvas. Loop doesn't load.

 
 
NamesJ
 
Reply Wed 16 Jan, 2013 01:48 am
First off, here is the source:

<html>
<head>
<script type="text/javascript">
</script>
</head>
<body>

<canvas id="myCanvas" width="200" height="100" style="border:0px solid #d3d3d3;">Your browser does not support the HTML5 canvas tag.</canvas>

<script type="text/javascript">
function binRun(){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var a = 80;
var b = 0;
for(i = 0;i < 6;i++){
ctx.moveTo(a,b);
ctx.lineTo(x,b);
ctx.stroke();
if(x==a){
x = b * 2;
}else{
x = a;
}
if(y==b){
y = a * 2;
}else{
y = b;
}
}
}

</script>
</body>
</html>


So, the goal here is to use a mix of <canvas> and a loop that reassigns variable values in order to draw a binary square onto the page. The only thing is, I seem to not at all be able to get the loop to work the way I want it to. I always either get a blank screen, or a loading symbol near the mouse as if it never completes the cycles in javascript.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 817 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » Need help with looping and canvas. Loop doesn't load.
Copyright © 2019 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 10/22/2019 at 03:06:45