{"size": 1101, "ext": "js", "max_stars_repo_path": "pages/dali/folding_square.js", "max_stars_repo_name": "gianmarco-todesco/4D-slides", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pages/dali/folding_square.js", "max_issues_repo_name": "gianmarco-todesco/4D-slides", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pages/dali/folding_square.js", "max_forks_repo_name": "gianmarco-todesco/4D-slides", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.8536585366, "max_line_length": 65, "alphanum_fraction": 0.5758401453}
// Folding square 
// by gmt(todesco@toonz.com); feb2017 

function drawFoldingSquare(dtheta) {
    var a_canvas = document.getElementById("square");
    var context = a_canvas.getContext("2d");
    context.clearRect(0, 0, a_canvas.width, a_canvas.height);
    var x = 50.0, y = a_canvas.height - 30.0;
    var r = 50;
    context.beginPath();
    context.moveTo(10,y);
    context.lineTo(a_canvas.width-10,y);
    context.lineWidth = 0.5;
    context.stroke();
    
    context.beginPath();
    context.moveTo(x,y);
    var theta = 0;
    var dtheta = -Math.PI*dtheta/180.0;
    var pts = [x,y];
    for(var i=0;i<4;i++) {
        x += r*Math.cos(theta);
        y += r*Math.sin(theta);
        context.lineTo(x,y);
        pts.push(x,y);
        theta += dtheta;
    }
    context.lineWidth = 4;
    context.stroke();
    
    context.beginPath();
    for(var i=0;i<5;i++) {
        context.moveTo(pts[i*2]+4,pts[i*2+1]);
        context.arc(pts[i*2],pts[i*2+1], 4, 0, 2*Math.PI, false);
    }
    context.fillStyle = 'green';
    context.fill();
    context.lineWidth = 1;
    context.stroke();
}
 