Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jcanvas/16.7.3/jcanvas.js"></script>
  
  
</head>
<body>
<div class="" style="width:600px;margin: 0 auto;">
    <canvas width="600" height="600"></canvas>
</div>
</body>
</html>
 
var kerbinImg = 'http://wiki.kerbalspaceprogram.com/images/thumb/5/5d/TinyKerbin.png/270px-TinyKerbin.png';
    
   var width = 600;
    var height = 300;
    var kerbinCenterCoord = {x: width / 2, y: height /2};
    var kerbinRadius = height/3;
    var hoehe = 30;
    var pathWidth = 1;
    var rad,sinus,cosinus,
        steps = 120,
        winkel;
    var canvas = $('canvas');
    canvas.attr({width:width , height:height});
    canvas.drawImage({
        source: kerbinImg,
        x: kerbinCenterCoord.x, y: kerbinCenterCoord.y,
        width:  (kerbinRadius * 2),
        height: (kerbinRadius * 2)
    });
    var oldX,oldY;
    var DrawPixel = function (x,y , color){
        if(typeof color == 'undefined'){
            color = '#000';
        }
        if(!oldX && !oldY){
            oldX = x;
            oldY = y;
        }
        canvas.drawLine({
                strokeStyle: color,
                strokeWidth: pathWidth,
                x1: oldX, y1: oldY,
                x2: x, y2: y
        });
        oldX = x;
        oldY = y;
    };
    var alt = 0;
    // while(alt < hoehe){
    //
    //
    //
    // }
    // for (var h = 130;h>=hoehe;h--){
    //     console.log(Math.log(h));
    //
    //
    //     rad = (h / steps) * (2*Math.PI); /* Berechnen des Bogenmaßwinkels */
    //     sinus =   -1*Math.sin(rad);
    //     cosinus = -1*Math.cos(rad);
    //
    //
    //     var tmpX = kerbinCenterCoord.x + ((hoehe + kerbinRadius)*sinus);
    //     var tmpY = kerbinCenterCoord.y + ((hoehe + kerbinRadius)*cosinus);
    //
    //     DrawPixel(tmpX , tmpY);
    // }
    calcOrbitPoint(120);
    function calcOrbitPoint (curArc){
        rad = (curArc / steps) * (2*Math.PI); /* Berechnen des Bogenmaßwinkels */
        sinus =   -1*Math.sin(rad);
        cosinus = -1*Math.cos(rad);
        var tmpY = kerbinCenterCoord.y + ((hoehe + kerbinRadius)*cosinus);
        var tmpX = kerbinCenterCoord.x + ((hoehe + kerbinRadius)*sinus);
        DrawPixel(tmpX , tmpY);
        curArc--;
        if(curArc >= 0){
            setTimeout(function(){ calcOrbitPoint(curArc)},1);
        }
    }
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers