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

              
                <!DOCTYPE html>
<!--
Experiments with HTML5. Works in Chrome. SVG text does not show in Firefox and performance is terrible.

Author: Mark Clarke 
Company: https://www.jumpingbean.co.za

-->
<html>
    <head>
        <title>Artificial Intelligence - HTML 5 Experiments</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            html, body {
                margin: 0;
                height: 100%;
                overflow:hidden;
            }

            .cuber {
                transform-origin: top right;
                -webkit-animation: rotatet 5s alternate infinite;
                -moz-animation: rotatet 5s alternate infinite;
                transform-origin: top left;
            }

            @-webkit-keyframes rotatet {
                0% { transform: rotateY(0deg) rotateX(0deg)}
                100%{ transform: rotateY(360deg)rotateX(360deg) }
            }
            @-moz-keyframes rotatet {
                0% { transform: rotateY(0deg) rotateX(0deg)}
                100%{ transform: rotateY(360deg)rotateX(360deg) }
            }

        </style>
        <script>
            var currx = 0;
            var curry = 0;
            var colour = "#04d9ff";
            var svgns = "http://www.w3.org/2000/svg";
            var shade = shadeColour(colour, -(0.9));
            var shade2 = "#39FF14"; //shadeColour(colour, (0.5));

            document.onreadystatechange = function () {
                if (document.readyState === 'complete') {
                    var width = document.body.clientWidth;
                    var height = document.body.clientHeight;
                    //build cube
                    //svg doesn't work well for this
                    for (var cubes = 0; cubes < 10; cubes++) {
                        var cube = {
                            front: getRect("front" + cubes),
                            back: getRect("back" + cubes),
                            top: getRect("top" + cubes),
                            bottom: getRect("bottom" + cubes),
                            left: getRect("left" + cubes),
                            right: getRect("right" + cubes)
                        };
                        var cos = Math.cos(Math.PI / 2);
                        var sin = Math.sin(Math.PI / 2);
                        cos = cos.toFixed(6);
                        sin = sin.toFixed(6);
                        cube.front.setAttributeNS(null, "style", cube.front.getAttribute("style") + " transform:matrix3d(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);");
                        cube.back.setAttributeNS(null, "style", cube.back.getAttribute("style") + "transform:matrix3d(1,0,0,0, 0,1,0,0, 0,0,1,0, -110,0,-100,1);");
                        cube.top.setAttributeNS(null, "style", cube.top.getAttribute("style") + "transform:matrix3d(1,0,0,0, 0," + cos + "," + -sin + ",0,0," + sin + "," + cos + ",0, -215,-49,-50,1);");
                        cube.bottom.setAttributeNS(null, "style", cube.bottom.getAttribute("style") + "transform:matrix3d(1,0,0,0, 0," + cos + "," + -sin + ",0, 0," + sin + "," + cos + ",0,-325,50,-50,1);");
                        cube.left.setAttributeNS(null, "style", cube.left.getAttribute("style") + "transform:matrix3d(" + cos + ",0," + -sin + ",0, 0,1,0,0," + sin + ",0," + cos + ",0, -485,0,-50,1);");
                        cube.right.setAttributeNS(null, "style", cube.right.getAttribute("style") + "transform:matrix3d(" + cos + ",0," + -sin + ",0, 0,1,0,0," + sin + ",0," + cos + ",0, -500,0,-50,1);");
                        var outer = document.createElement("div");
                        outer.setAttribute("style", "transform-style:preserve-3d;");
                        outer.setAttribute("class", "cuber");
                        var inner = document.createElement("div");
                        outer.appendChild(inner);
                        inner.setAttribute("style", "transform-style:preserve-3d; transform: translate3d(" + (Math.random() * width).toFixed(0) + "px," + (Math.random() * height).toFixed(0) + "px," + (Math.random() * -1000).toFixed(0) + "px);")
                        inner.appendChild(cube.front);
                        inner.appendChild(cube.back);
                        inner.appendChild(cube.top);
                        inner.appendChild(cube.bottom);
                        inner.appendChild(cube.left);
                        inner.appendChild(cube.right);
                        document.body.appendChild(outer);
                    }

                    //build floating blocks
                    var counter = 1;
                    for (var layer = 0; layer < 6; layer++) {
                        for (var block = 0; block < 6; block++) {
                            var g = document.createElementNS(svgns, "g");
                            //create some svg text nodes!
                            var blockwidth = 100 + Math.round(Math.random() * 250);
                            var blockheight = 100 + Math.round(Math.random() * (height - 100));
                            for (var i = 0; i < blockwidth; i++) {
                                var text = document.createElementNS(svgns, "text");
                                text.setAttributeNS(null, "x", i * 10);
                                text.setAttributeNS(null, "y", -210);
                                text.setAttributeNS(null, "writing-mode", "tb");
                                text.setAttributeNS(null, "glyph-orientation-vertical", "0");
                                text.setAttributeNS(null, "opacity", Math.random());
                                text.setAttributeNS(null, "fill", colour)
                                var str = "";
                                for (var j = 0; j < 125; j++) {
                                    str += Math.round(Math.random()) * 1;
                                }
                                var textn = document.createTextNode(str);
                                text.appendChild(textn);
                                text.setAttributeNS(null, "style", "font-family:Liberation Mono; font-size:9pt;" + i + ".end");
                                text.setAttributeNS(null, "text-rendering", "optimize-speed")
                                //animate text
                                var animateTransform = document.createElementNS(svgns, "animateTransform");
                                animateTransform.setAttributeNS(null, "type", "translate");
                                animateTransform.setAttributeNS(null, "id", "anim" + i);
                                animateTransform.setAttributeNS(null, "attributeName", "transform");
                                animateTransform.setAttributeNS(null, "attributeType", "xml");
                                animateTransform.setAttributeNS(null, "values", "0,0;0,200;0,0");
                                animateTransform.setAttributeNS(null, "keyTimes", "0;0.5;1");
                                animateTransform.setAttributeNS(null, "dur", Math.round((Math.random() * 5) + 5) + "s");
                                animateTransform.setAttributeNS(null, "begin", "0;anim" + i + ".end");
                                text.appendChild(animateTransform);
                                g.appendChild(text);
                            }

                            var svgElm = document.createElementNS(svgns, "svg");
                            svgElm.appendChild(g);
                            container.appendChild(svgElm);
                            var x = (Math.round(Math.random() * (width) * 3)) - width;
                            var y = (Math.round(Math.random() * height * 3)) - height;
                            var z = -1 * (Math.round(Math.random() * 1000));
                            var matrixw = x + "px," + y + "px," + z + "px";
                            svgElm.setAttribute("style", "position:absolute; top:0; left:0; "
                                    + "opacity:0.7; background-color: " + shade + "; "
                                    + "box-shadow:inset 0 0 40px " + colour + "; border-radius:10px; border-style:outset; "
                                    + "width:" + blockwidth + "px;" + " height:" + blockheight + "px; -webkit-animation: rotateinspace"
                                    + counter + " " + (8 + Math.round(10 * Math.random())) + "s alternate infinite;"
                                    + " -moz-animation: rotateinspace" + counter + " " + (8 + Math.round(10 * Math.random())) + "s alternate infinite;");
                            try {
                                document.styleSheets[0].insertRule("@-webkit-keyframes rotateinspace" + counter
                                        + " { 0% { transform:translate3d(" + matrixw + ") rotateY(0deg);} "
                                        + " 100% { transform:translate3d(" + matrixw + ") rotateY(360deg); } }", document.styleSheets[0].cssRules.length);
                            } catch (e) {
                                console.log(e.message);
                                //not chrome!
                            }
                            try {
                                document.styleSheets[0].insertRule("@-moz-keyframes rotateinspace" + counter
                                        + " { 0% { transform:translate3d(" + matrixw + ") rotateY(0deg);} "
                                        + " 100% { transform:translate3d(" + matrixw + ") rotateY(360deg); } }", document.styleSheets[0].cssRules.length);
                            } catch (e) {
                                console.log(e.message);
                                //not firefox
                            }
                            counter++;
                        }
                    }
                }
            };
            function shadeColour(color, percent) {
                var f = parseInt(color.slice(1), 16), t = percent < 0 ? 0 : 255, p = percent < 0 ? percent * -1 : percent, R = f >> 16, G = f >> 8 & 0x00FF, B = f & 0x0000FF;
                return "#" + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
            }


            function getRect(id) {
                var div = document.createElement("div");
                div.setAttributeNS(null, "id", id);
                div.setAttributeNS(null, "style", "background-color:" + shade2 + ";" +
                        "height:100px; width:100px; opacity:0.5; " +
                        "box-shadow:inset 0 0 40px; border-style: groove;" +
                        "margin:0px; padding:0px; display:inline-block;");
                return div;
            }
        </script>
    </head>
    <body id="container" style="perspective:1000px; transform-style: preserve-3d; 
          background-image:url(background-9.jpg); 
          background-color:black;
          background-size:cover;
          background-position: center; background-repeat: no-repeat;">
    </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console