css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              HTML, BODY {
    height: 100%; 
    min-height: 100%;
    }
BODY {
    /* padding: 2em; */
    background: #000;
    }

svg {
    position: absolute;
    overflow: visible;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 90%;
    height: 90%;
    margin: auto;
    }

            
          
!
            
              console.clear();

var sWidth = 600;
var sHeight = 500;

var s = Snap();
s.attr({
    viewBox: [0,0,sWidth,sHeight].join(' ')
});
var g = s.g();
var pi = 3;
var max = 10;
var shapeR = 100;
var strokeWidth = shapeR * 2;
var strokeWidthHalf = strokeWidth / 2;
var d = (shapeR + strokeWidthHalf) * 2;
var dashOffsetStep = 2 * pi * shapeR / max;
var colorStep = 360 / max;
var dur = 10000;
var patt;

var shapeObj = function() {
    var shape = s.circle(0, 0, 0);
    var dashOffset = 0;
    var dasharrayFirst = dashOffsetStep / 10 + (dashOffsetStep / 10) * Math.random();
    var strokeDasharray = [dasharrayFirst, dashOffsetStep].join(' ');
    var steps = [];
    var currentStep = 0;
    var cx = 0;
    var cy = 0;
    var thisDur = dur + Math.random() * dur;

    this.init = function(params) {
        cx = shapeR + strokeWidthHalf;
        cy = shapeR + strokeWidthHalf;
        var pos = params.pos;
        var color = getHSL(pos);
        dashOffset = dashOffsetStep * pos;

        shape.attr({
            cx: cx,
            cy: cy,
            r: shapeR,
            fill: 'none',
            stroke: color,
            'stroke-width': strokeWidth,
            'stroke-dasharray': strokeDasharray,
            'stroke-dashoffset': dashOffset
        });

        g.add(shape);

        myAnim();
    }; // init

    function myAnim() {

            var rotateList = [360, cx, cy].join(',');
            var rotateListInit = [0, cx, cy].join(',');

            shape.attr({
                transform: 'rotate(' + rotateListInit + ')'
            });

            shape.animate({
                    transform: 'rotate(' + rotateList + ')'
                },
                thisDur,
                myAnim
            );

            currentStep = currentStep < (steps.length - 1) ? currentStep + 1 : 0;

        } // end myAnim
};

function getHSL(pos) {
    var colorPos = max - pos;
    var color = [colorStep * colorPos, 100, 50].join(',');
    return 'hsl(' + color + ')';
}

function createShapes() {

    for (var i = 0; i < max; i++) {
        var shape = new shapeObj;
        shape.init({
            pos: i
        });
    }
}

function createPattern() {
    patt = g.toPattern(0, 0, d, d);
    patt.attr({
        width: 3,
        height: 3,
        x: -1,
        y: -1,
        patternUnits: 'objectBoundingBox'
    });
}

var starObj = function() {
    
    this.init = function ( params ) {
        var d = 'M29.9516425,11.0134272 C29.7896476,10.5068604 29.3921952,10.3992883 28.682055,10.3992883 L18.9698989,10.3992883 C18.9698989,10.3992883 18.9642479,10.3973325 18.9623643,10.3953766 L18.9698989,10.3953766 C18.9698989,10.3953766 16.2611943,1.94412124 15.9692269,1.03269217 C15.7507222,0.350098291 15.5265666,0 15.0010251,0 C14.4754837,0 14.2550954,0.338363153 14.0328234,1.03269217 C13.729554,1.97541494 11.0302678,10.3953766 11.0302678,10.3953766 L11.0340351,10.3953766 L11.0302678,10.3992883 L1.31811169,10.3992883 C0.609855158,10.3992883 0.210519028,10.5068604 0.0485241836,11.0134272 C-0.113470662,11.519994 0.135172589,11.8368428 0.719107496,12.2671312 C1.51024511,12.8499764 8.57774115,18.0545102 8.57774115,18.0545102 C8.57774115,18.0545102 5.86903665,26.5057656 5.57706919,27.4171946 C5.35856452,28.1017444 5.33596058,28.5163859 5.76166797,28.8312788 C6.18737535,29.1442158 6.56222389,29.0014383 7.14427514,28.5711499 C7.93541275,27.9883047 15.0010251,22.7837709 15.0010251,22.7837709 C15.0010251,22.7837709 22.0685212,27.9883047 22.8596588,28.5711499 C23.4417101,28.9994824 23.8184423,29.1442158 24.242266,28.8312788 C24.6679734,28.5183418 24.6453695,28.1017444 24.4268648,27.4171946 C24.1348973,26.5057656 21.4243092,18.0545102 21.4243092,18.0545102 C21.4243092,18.0545102 28.4918052,12.8499764 29.2829428,12.2671312 C29.8631104,11.8368428 30.1136373,11.519994 29.9516425,11.0134272 L29.9516425,11.0134272 L29.9516425,11.0134272 Z';

        var xOffset = params.xOffset || 0;
        var strokeW = params.strokeW;
        var fill = params.fill;
        var star = s.path(d);
        var starSize = 30;
        var scale = 3;
        var xPos = sWidth/2 - (starSize * scale / 2) + xOffset;
        var yPos = sHeight/2 - (starSize * scale / 2);
        star.attr({
            fill: fill,
            transform: 'translate(' + xPos + ',' + yPos + ') scale(' + scale + ')',
            'stroke-width': strokeW,
            stroke: patt
        });
    }; // init
};

function addStars() {
    var offsets = [-240, -120, 0, 120, 240];
    var strokeWidth = 1.5;
    
    for (var i = 0; i < offsets.length; i++ ){
        var mod = i % 2;
        var newStar = new starObj;
        var params = {
            xOffset: offsets[i],
            strokeW: mod == 1 ? 0 : strokeWidth,
            fill: mod == 1 ? patt : 'none'
        };
        newStar.init( params );
    }
}

function createDemo() {
    addStars();
    
    var text = s.text('50%','88%','Hello');
    
    text.attr({
        fill: patt,
        'text-anchor': 'middle',
        dy: '.25em',
        'font': 'bold 15em/1 Arial'
    });
    
    var textStroke = text.clone();
    
    textStroke.attr({
        fill: 'none',
        stroke: patt,
        'stroke-width': 5,
        'text-anchor': 'middle',
        y: '23%'
    });

}

createShapes();
createPattern();

createDemo();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console