Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                

<!-- Full credit: http://jsfiddle.net/umaar/fWSUk/ -->
<h1 class="txtshadow">airplane</h1>
<div id="canvas-container" >
    <canvas id="sineCanvas"  width="1024" height="300"></canvas>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Open+Sans:300);
body {
    height: 100%;
    width: 100%;
    background: #1b1d21;
    background-image: url(http://www.transparenttextures.com/patterns/carbon-fibre.png);
font-family: 'Open Sans', sans-serif;
  
}


h1 {
font-family: 'Open Sans', sans-serif;
font-size: 92px;
padding:  5px;
text-align: center;
text-rendering: optimizeLegibility;
} 

.txtshadow{
  color: #000;
  text-shadow: 0 0 1px #3D3D3D;
}

#canvas-container{
  text-align: center;
}
              
            
!

JS

              
                (function () {

    var unit= 50,canvas, context, canvas2, context2,
        height, width, xAxis, yAxis,
        draw;

    /**
     * Init function.Initialize variables and begin the animation.
     */
    function init() {

        canvas = document.getElementById("sineCanvas");
        context = canvas.getContext("2d");

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

        xAxis = Math.floor(height / 2);
        yAxis = Math.floor(width / 4);

        context.save();
        draw();

    }

    /**
     * Draw animation function.
     * 
     * This function draws one frame of the animation, waits 25ms, and then calls
     * itself again.
     */
    draw = function () {
        // Clear the canvas
        context.clearRect(0, 0, width, height);
        
        // BLUE gradient
        grd = context.createLinearGradient(0.000, 0.000, 800.000, 0.000);
        grd.addColorStop(0, 'rgba(189, 106, 155, 1.000)');
        grd.addColorStop(1, 'rgba(189, 106, 155, 0.00)');
        context.strokeStyle = grd;
        context.lineWidth = 2;
        // BLUE sine
        context.beginPath();
        drawSine(draw.t, unit, 0, 1);
        context.stroke();
        //BLUE plane
        drawPlane(draw.t, unit, 0, 1);
        
        //GREEN gradient
        grd = context.createLinearGradient(0.000, 0.000, 800.000, 0.000);
        grd.addColorStop(0, 'rgba(151, 204, 18, 1.000)');
        grd.addColorStop(1, 'rgba(151, 204, 18, 0.000)');
        context.strokeStyle = grd;
        // GREEN sine
        context.beginPath();
        drawSine(draw.t, unit*2, 50, -1);
        context.stroke();
        // GREEN plane
        drawPlane(draw.t, unit*2, 50, -1 );
        
        //YELLOW Gradient
        grd = context.createLinearGradient(0.000, 0.000, 800.000, 0.000);
        grd.addColorStop(0,  'rgba(245, 223, 22, 1.000)');
        grd.addColorStop(1, 'rgba(245, 223, 22, 0.0)');
        context.strokeStyle = grd;
        //YELLOW sine
        context.beginPath();
        drawSine(draw.t, unit*2, 100, 1);
        context.stroke();
        //YELLOW plane
        drawPlane(draw.t, unit*2, 100, 1 );

        //RED Gradient
        grd = context.createLinearGradient(0.000, 0.000, 800.000, 0.000);
        grd.addColorStop(0,  'rgba(204, 63, 24, 1.000)');
        grd.addColorStop(1, 'rgba(204, 63, 24, 0.000)');
        context.strokeStyle = grd;
        //RED sine
        context.beginPath();
        drawSine(draw.t, unit*1/150, 150, -1);
        context.stroke();
        //RED plane
        drawPlane(draw.t, unit*1/150, 150, -1 );
        
        // Restore original styles
        context.restore();

        
        // Update the time and draw again
        draw.seconds = draw.seconds - .007;
        draw.t = draw.seconds * Math.PI;
        setTimeout(draw , 35);
    };

    draw.seconds = 0;
    draw.t = 0;


    /**
     * Function to draw sine
     * 
     * The sine curve is drawn in 10px segments starting at the origin. 
     */
    function drawSine(t, unitval, offset, direction) {

        // Loop to draw segments
        for (i = yAxis; i <= width; i += 10) {
            x = t + (-yAxis + i) / unitval;
            y = Math.sin(x) * direction;
            context.lineTo(i + offset , (unitval / 3) * y + xAxis);
        }
    }



    /**
     * Function to draw arrow
     */
    function drawPlane(t, unitVal, offset, direction) {

        // Cache position of arrow on the circle
        var y = xAxis + (unitVal / 3) * Math.sin(t) * direction;
        var img = new Image();
        img.src = "https://i.imgur.com/LsYmdkL.png";
        //img.src = "https://i.imgur.com/bYuAw4C.png";
        // Draw yAxis bead
        context.beginPath();
        context.drawImage(img, yAxis - 29  + offset , y - 16 );
        //context.arc(yAxis, y, 5, 0, 2*Math.PI, false);
        context.stroke();
    }

    init();

})();
              
            
!
999px

Console