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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <html>
    <head>
        <title>Crawling Lasher.</title>
        <link href='https://fonts.googleapis.com/css?family=Quantico:400' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/style.css">
    </head>
    <body>
        <div id="container"></div>
        <script src="https://soulwire.github.io/sketch.js/js/sketch.min.js"></script>
        <script src="js/tentacles.js"></script>
    </body>
</html>

              
            
!

CSS

              
                html, body {

    background: #f2f2f2;
    background: -moz-radial-gradient(center, ellipse cover,  #000000 0%, #000000 26%, #111111 59%, #111111 77%, #888888 100%);
    background: -webkit-gradient(radial, center center, 0, center center, 100%, color-stop(0%,#000000), color-stop(26%,#000000), color-stop(59%,#111111), color-stop(77%,#111111), color-stop(100%,#888888));
    background: -webkit-radial-gradient(center, ellipse cover,  #000000 0%,#000000 26%,#111111 59%,#111111 77%,#888888 100%);
    background: -o-radial-gradient(center, ellipse cover,  #000000 0%,#000000 26%,#111111 59%,#111111 77%,#888888 100%);
    background: -ms-radial-gradient(center, ellipse cover,  #000000 0%,#000000 26%,#111111 59%,#111111 77%,#888888 100%);
    background: radial-gradient(ellipse at center,  #000000 0%,#000000 26%,#111111 59%,#111111 77%,#888888 100%);
    overflow: hidden;
    padding: 0;
    margin: 0;
    height: 100%;
}
              
            
!

JS

              
                
/**
 * Copyright (C) 2012 by Justin Windle
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.

    Edited version of https://github.com/soulwire/Muscular-Hydrostats

 */

var settings = {
    interactive: false,
    headRadius: 1,
    thickness: 5,
    tentacles: 50,
    friction: 0,
    gravity: 0,
    colour: { r: 1, g: 1, b: 1 },
    length: 50,
    pulse: true,
    wind: 0
};

var utils = {

    curveThroughPoints: function( points, ctx ) {

        var i, n, a, b, x, y;
        
        for ( i = 1, n = points.length - 2; i < n; i++ ) {

            a = points[i];
            b = points[i + 1];
            
            x = ( a.x + b.x ) * 0.5;
            y = ( a.y + b.y ) * 0.5;

            ctx.quadraticCurveTo( a.x, a.y, x, y );
        }

        a = points[i];
        b = points[i + 1];
        
        ctx.quadraticCurveTo( a.x, a.y, b.x, b.y );
    }
};

var Node = function( x, y ) {
    
    this.x = this.ox = x || 0.0;
    this.y = this.oy = y || 0.0;

    this.vx = 0.0;
    this.vy = 0.0;
};

var Tentacle = function( options ) {

    this.length = options.length || 10;
    this.radius = options.radius || 10;
    this.spacing = options.spacing || 20;
    this.friction = options.friction || 0.8;

    this.nodes = [];
    this.outer = [];
    this.inner = [];
    this.theta = [];

    for ( var i = 0; i < this.length; i++ ) {
        this.nodes.push( new Node() );
    }
};

Tentacle.prototype = {

    move: function( x, y, instant ) {
        
        this.nodes[0].x = x;
        this.nodes[0].y = y;
        if ( instant ) {

            var i, node;
            for ( i = 1; i < this.length; i++ ) {

                node = this.nodes[i];
                node.x = x;
                node.y = y;
            }
        }
    },

    update: function() {

        var i, n, s, c, dx, dy, da, px, py, node, prev = this.nodes[0];
        var radius = this.radius * settings.thickness;
        var step = radius / this.length;

        for ( i = 1, j = 0; i < this.length; i++, j++ ) {

            node = this.nodes[i];

            node.x += node.vx;
            node.y += node.vy;

            dx = prev.x - node.x;
            dy = prev.y - node.y;
            da = Math.atan2( dy, dx );

            px = node.x + cos( da ) * this.spacing * settings.length;
            py = node.y + sin( da ) * this.spacing * settings.length;

            node.x = prev.x - ( px - node.x );
            node.y = prev.y - ( py - node.y );

            node.vx = node.x - node.ox;
            node.vy = node.y - node.oy;

            node.vx *= this.friction * (1 - settings.friction);
            node.vy *= this.friction * (1 - settings.friction);

            node.vx += settings.wind;
            node.vy += settings.gravity;

            node.ox = node.x;
            node.oy = node.y;

            s = sin( da + HALF_PI );
            c = cos( da + HALF_PI );

            this.outer[j] = {
                x: prev.x + c * radius,
                y: prev.y + s * radius
            };

            this.inner[j] = {
                x: prev.x - c * radius,
                y: prev.y - s * radius
            };

            this.theta[j] = da;

            radius -= step;

            prev = node;
        }
    },

    draw: function( ctx ) {

        var r, g, b, e;

        s = this.outer[0];
        e = this.inner[0];

        ctx.beginPath();
        ctx.moveTo( s.x, s.y );
        utils.curveThroughPoints( this.outer, ctx );
        utils.curveThroughPoints( this.inner.reverse(), ctx );
        ctx.lineTo( e.x, e.y );
        ctx.closePath();

        ctx.fillStyle = '#f1f1f1';
        ctx.fill();

        if ( settings.thickness > 2 ) {

            ctx.strokeStyle = '#f1f1f1';
            ctx.lineWidth = 1;
            ctx.stroke();
        }
    }
};

var demo = true;
var ease = 0;
var modified = false;
var radius = settings.headRadius;
var tentacles = [];
var center = { x:0, y:0 };

var sketch = Sketch.create({

    container: document.getElementById( 'container' ),

    setup: function() {

        center.x = this.width / 2;
        center.y = this.height / 2;

        var tentacle;

        for ( var i = 0; i < 100; i++ ) {

            tentacle = new Tentacle({
                length: random( 10, 20 ),
                radius: random( 0.05, 1.0 ),
                spacing: random( 0.2, 1.0 ),
                friction: random( 0.7, 0.88 )
            });

            tentacle.move( center.x, center.y, true );
            tentacles.push( tentacle );
        }
    },

    update: function() {

        var t, cx, cy, pulse;

        t = this.millis * 0.001;

        if ( settings.pulse ) {

            pulse = pow( sin( t * PI ), 18 );
            radius = settings.headRadius * 0.5 + settings.headRadius * 0.5 * pulse;
        }

        if ( settings.interactive ) {

            ease += ( 0.7 - ease ) * 0.05;

            center.x += ( this.mouse.x - center.x ) * ease;
            center.y += ( this.mouse.y - center.y ) * ease;

        } else {

            t = this.millis;
            cx = this.width * 0.5;
            cy = this.height * 0.5;

            center.x = cx + sin( t * 0.002 ) * cos( t * 0.00005 ) * cx * 1 + Math.ceil(random(0, 40) - 20);
            center.y = cy + sin( t * 0.003 ) * tan( sin( t * 0.0003 ) * 1.15 ) * cy * 0.8 + Math.ceil(random(0, 40) - 20);
        }

        var px, py, theta, tentacle;
        var step = TWO_PI / settings.tentacles;

        for ( var i = 0, n = settings.tentacles; i < n; i++ ) {

            tentacle = tentacles[i];

            theta = i * step;

            px = cos( theta ) * radius;
            py = sin( theta ) * radius;

            tentacle.move( center.x + px, center.y + py );
            tentacle.update();
        }
    },

    draw: function() {

        this.globalAlpha = 0.1;

        for ( var i = 0, n = settings.tentacles; i < n; i++ ) {
            tentacles[i].draw( this );
        }
    }
});

              
            
!
999px

Console