cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <!-- <div class="test" id="test">123</div> -->

<svg>
    <defs>
        <path class="shape" d="M45,0 L90,30 90,80 45,110 0,80 0,30 z">
         </path>
    </defs>
    
    <mask id="mask">
        <text x="50%" y="50%"
          dy=".3em"
          text-anchor="middle">
            Pattern
        </text>
    </mask>
    
    <pattern id="patt" class="pattern"
              width="400" height="400"
              patternUnits="userSpaceOnUse" 
              viewBox="0 45 900 900">    
        <rect 
          fill="#FFF"
           width="1000" height="1000"
           ></rect>
        <g class="shapes-filled"></g>
        <g class="shapes-stroked"></g>
    </pattern>
    
   
    
    <g fill="url(#patt)">
        <text x="50%" y="50%"
              dy=".3em"
              text-anchor="middle"
              class="text">
                &hearts;
            </text>
    </g>
    
    
        
</svg>
            
          
!
            
              $size: 10vmin;
$grad-size: $size / 3;

HTML, BODY {
    height: 100%;
    overflow: hidden;
}

BODY {
    background: hsl(0, 0, 4%);
    background-image: linear-gradient(hsl(0, 0, 6%) 1px, transparent 1px),
        linear-gradient(to right, hsl(0, 0, 6%) 1px, transparent 1px);
    background-size: $grad-size $grad-size;
    }

svg {
    position: absolute;
    width: 100%;
    height: 100%;
}

path {
    fill-opacity: .6;
    
}

.shapes-filled path {
    /* stroke: red; */
}

.shapes-stroked path {
    fill: transparent;
    stroke: black;
    stroke: white;
    stroke-width: 2;
    stroke-dasharray: 10;
}

text {
    stroke: white;
    stroke-width: 1;
    stroke-dasharray: 5;
    
    font-size: 20vw;
    font-family: Tahoma;
    font-weight: bold;
}
            
          
!
            
              console.clear();
var doc = document;

var shape = doc.querySelector('.shape');
var shapeW = 90; // bad way
var shapeVOffset = shapeW / 2.5;
var shapeH = shapeW - shapeVOffset; // bad way
var shapeCounter = 0;

var pattern = doc.querySelector('.pattern');
var pattVbox = pattern.getAttribute('viewBox').split(' ');
var pattVboxHor = pattVbox[2];
var pattVboxVert = pattVbox[3];
var gFilled = doc.querySelector('.shapes-filled');
var gStroked = doc.querySelector('.shapes-stroked');

var tilesHor = pattVboxHor / shapeW;
var tilesVert = pattVboxVert / shapeH + 1;
var tilesMax = tilesHor * tilesVert;

var colorStep = 360 / tilesMax;

var duration = 3;

var text = doc.querySelector('.text');

fillPattern();
setTime(); 

function getRandColor() {
    var colorPos = Math.random() * 360;
    var colorS = Math.random() * 30 + 70 + '%';
    var colorB = Math.random() * 40 + 20 + '%';
    var colorVal = [ Math.floor(colorPos * colorStep), colorS, colorB].join(','); 
    var color = 'hsl(' + colorVal +')';
    return color;
}

var myInt = setInterval(setTime, 1000);

function setTime() {
    var myDate = new Date();
    var hours = myDate.getHours();
    var mins = myDate.getMinutes();
    var secs = myDate.getSeconds();
    
    var time = [hours, mins, secs];
    for( var i = 0; i < time.length; i++ ){
        time[i] = time[i] < 10 ? '0' + time[i] : time[i];        
    }
    
    time = time.join(':');
    text.textContent = time;
}

function Shape( x, y, hasAnim ) {
    hasAnim = hasAnim === undefined ? true : hasAnim;

    var newShape = shape.cloneNode();   
    var translateVal = [ shapeW * x, shapeH * y].join(' ');
    var tranform = 'translate(' + translateVal + ')'; 
    newShape.setAttribute('transform', tranform);
    
    if ( hasAnim ) {
        var color = getRandColor();
        newShape.setAttribute('fill', color);
        var newShapeAnim = new Animation( newShape );
    }
    
    shapeCounter++;
    return newShape;
}

function fillPattern(){
    for (var y = 0; y < tilesVert; y++) {
        for (var x = 0; x < tilesHor; x++ ) {
            var newShape = new Shape( x, y );
            var newItem = gFilled.appendChild(newShape);  
            
            var newShapeStroked = new Shape( x, y, false );
            var newItemStroked = gStroked.appendChild(newShapeStroked);  
            
            // console.log( gFilled );
        }
    }
    console.dir( pattern );
    // out(newItem);
}

// -----------------------------------------



function Animation( elem ) {
    
    var initFill = elem.getAttribute('fill');

    var to1 = {
        fill: getRandColor(),
        ease: Power0.easeNone
    };
    var to2 = {
        fill: getRandColor(),
        ease: Power0.easeNone
    };
    
    var to3 = {
        fill: getRandColor(),
        ease: Power0.easeNone,
        onComplete: forward
    };

    var myTween = new TimelineLite();
    forward();

    function forward() {
        myTween.to(elem, duration, to1);
        myTween.to(elem, duration, to2);
        myTween.to(elem, duration, to3);
    }
}

// -----------------------------------------

function out ( content ) {
    console.dir( content );
}

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console