Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of Alexander Roehnisch

Alexander Roehnisch

Alexander Roehnisch has asked 1 questions and find answers to 1 problems.

Stats

16
EtPoint
1
Vote count
1
questions
1
answers

About

function draw() {

        var ctx = document.getElementById('canvas').getContext('2d');
        var sidelength = 100;
        var angle = Math.PI*2/3;
        var translate_x = 250;
        var translate_y = 250;
        
        ctx.translate(translate_x,translate_y);
        
        for(i=1;i<4;i++)
        {
            ctx.beginPath();
            ctx.moveTo(0,0);
            ctx.lineTo(0,-sidelength);
            ctx.stroke();
            
            ctx.save(); 
            ctx.translate(0,-sidelength);
            for(j=1;j<4;j++)
            {
                ctx.beginPath();
                ctx.moveTo(0,0);            
                ctx.lineTo(0,-sidelength/2);
                ctx.stroke(); 
                
                ctx.save();   
                ctx.translate(0,-sidelength/2);
                for(k=1;k<4;k++)
                {
                    ctx.beginPath();
                    ctx.moveTo(0,0);            
                    ctx.lineTo(0,-sidelength/3);
                    ctx.stroke();
                    ctx.rotate(angle);                      
                }
                ctx.restore();  
                  
                ctx.rotate(angle);
                
            }
            ctx.restore();  
            
            ctx.rotate(angle);
        }
  }

Alexander Roehnisch questions