Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                h1 Arrest me!
h2 I'm brown, and I made a digital clock!

canvas#canv(width= '1300' height='200')

ul
  li: a(href="http://ihnatko.com/2015/09/16/im-achmed-except-im-not-brown/") I’m Ahmed. Except I’m Not Brown.
  li: a(href="http://techcrunch.com/2015/09/16/14-year-old-boy-arrested-for-bringing-homemade-clock-to-school/") 14-Year-Old Boy Arrested For Bringing Homemade Clock To School
  
  li: a(href="http://motherboard.vice.com/read/here-is-the-diy-clock-that-a-muslim-teen-was-arrested-for-bringing-to-school?utm_source=mbtwitter") This DIY Clock Got a Muslim Teen Arrested at School
  
  li: a(href="http://www.vice.com/read/a-muslim-kid-got-arrested-because-everyone-thought-his-homemade-clock-was-a-bomb-vgtrn-958?utm_source=vicetwitterus") A Muslim Kid Got Arrested Because His Teacher Thought His Homemade Clock Was a Bomb
              
            
!

CSS

              
                *
  box-sizing border-box

body
  background hsl(30, 50%, 70%)
  font-family 'roboto slab'
  font-size 18px
  line-height 1.5
  padding 3rem
  color #4f4f4f
  display flex
  flex-direction column
  align-items center
  justify-content center
  height 100vh
  width 100vw
  
h1
  color hsl(30, 50%, 20%)
  font-family 'roboto condensed'
  font-size 6rem
  font-weight 900
  text-align center
  text-transform uppercase
  animation: wiggle 3s linear infinite
  
h2
  color hsl(30, 50%, 50%)
  font-size 3rem
  text-align center

ul
  background hsl(30, 50%, 80%)
  border-radius 5px
  padding 1rem
a
  background hsl(30, 50%, 80%)
  color hsl(30, 50%, 30%)
  display block
  
  &:hover
    color hsl(210, 50%, 50%)
    text-decoration none

canvas
  margin 3rem 0
  width:50%

@keyframes wiggle
  0%, 7% 
    transform: rotateZ(0)
  
  15%
    transform: rotateZ(-5deg)
  
  20% 
    transform: rotateZ(0deg)
  
  25% 
    transform: rotateZ(-3deg)
  
  30% 
    transform: rotateZ(3deg)
  
  35% 
    transform: rotateZ(-2deg)
  
  40%, 100% 
    transform: rotateZ(0)  
              
            
!

JS

              
                var c = document.getElementById("canv"),
$ = c.getContext("2d");
main();

// bitmap font
var clockAlpha = {
    " ": [ 0x00, 0x00, 0x00, 0x00, 0x00 ],
    "0": [ 0x3e, 0x45, 0x49, 0x51, 0x3e ],
    "1": [ 0x00, 0x21, 0x7f, 0x01, 0x00 ],
    "2": [ 0x21, 0x43, 0x45, 0x49, 0x31 ],
    "3": [ 0x22, 0x41, 0x49, 0x49, 0x36 ],
    "4": [ 0x0c, 0x14, 0x24, 0x7f, 0x04 ],
    "5": [ 0x72, 0x51, 0x51, 0x51, 0x4e ],
    "6": [ 0x1e, 0x29, 0x49, 0x49, 0x06 ],
    "7": [ 0x40, 0x47, 0x48, 0x50, 0x60 ],
    "8": [ 0x36, 0x49, 0x49, 0x49, 0x36 ],
    "9": [ 0x30, 0x49, 0x49, 0x4a, 0x3c ],
    ":": [ 0x00, 0x36, 0x36, 0x00 ]
};

var sec;   //seconds
var ld;    //last date
var colhue = 0; //color hue

var blkSize = 25;  //num block size
var blkGap = 2;   // block spacing
var charGap = 15;  //letter spacing
var hue_clk_Inc = 3;  //increment clock hue
var hue_row_Inc = 5; //increment row hue

function main() {
    window.setInterval(clkInt, 100); //clock interaval
    window.setInterval(rnbwInt, 30); //rainbow interval
}

function clkInt() {    
    var d = new Date();
    var s = d.getSeconds();

    if (s != sec) {
        sec = s;
        ld = d;
    }
}

function rnbwInt() {
    if (ld !== undefined) {
        colhue = incHue(colhue, hue_clk_Inc);

        draw();
    }
}

function draw() {
    var h = ld.getHours();
    var m = ld.getMinutes();
    var s = ld.getSeconds();
  
   //easy conversion to 'normal' hours:
   if(h == 00){  //if midnight (00 hours) hour = 12
      h=12;
   }
   else if (h >= 13 ){  //convert military hours at and over 1300 (1pm) to regular hours by subtracting 12. 
      h -=12;
   }
   //display
    var text = twoDigStr(h, " ") + ":" + twoDigStr(m, "0") + ":"
            + twoDigStr(s, "0");
   
    clear();

    var x = 10;
    var y = 10;
    var hue = colhue;

    for ( var i = 0; i < text.length; i++) {
        var ch = text.charAt(i);

        var rows = clockAlpha[ch];

        for ( var s = 0; s < rows.length; s++) {
            var row = rows[s];

            var color = new RGBACol();
            color.setFromHSV(hue, 1, 1, 1);
            $.shadowColor = 'hsla(0, 0%, 0%, .8)';
            $.shadowBlur = 25;
            $.shadowOffsetX = 10;
            $.shadowOffsetY = 5; 
            $.fillStyle = "rgb(" + color.r + "," + color.g + ","
                    + color.b + ")";

            for ( var d = 0; d < 7; d++) {
                if ((row & 1) != 0) {
                    var blkIdx = 6 - d;

                    var blkX = x;
                    var blkY = y + blkIdx * (blkSize + blkGap);

                    $.fillRect(blkX, blkY, blkSize, blkSize);
                }

                row >>= 1;
            }

            x += blkSize + blkGap;
            hue = incHue(hue, hue_row_Inc);
        }

        x += charGap;
    }
}

function clear() {
    $.clearRect(0, 0, c.width, c.height);
}

function twoDigStr(v, padding) {
    var s = String(v);
    return s.length == 1 ? padding + s : s;
}

function incHue(hue, inc) {
    return (hue + inc) % 360;
}


function RGBACol(r, g, b, alpha) {
    this.r = r;
    this.g = g;
    this.b = b;
    this.alpha = alpha;
}

RGBACol.prototype.setFromHSV = function(h, s, v, alpha) {
    h = h % 360;

    if (h < 0) {
        h += 360;
    }

    var c = v * s;
    var h1 = h / 60;
    var x = c * (1 - Math.abs(h1%2 - 1));
    var r1 = 0, g1 = 0, b1 = 0;

    switch (Math.floor(h1)) {
    case 0: r1 = c; g1 = x; b1 = 0; break;
    case 1: r1 = x; g1 = c; b1 = 0; break;
    case 2: r1 = 0; g1 = c; b1 = x; break;
    case 3: r1 = 0; g1 = x; b1 = c; break;
    case 4: r1 = x; g1 = 0; b1 = c; break;
    case 5: r1 = c; g1 = 0; b1 = x; break;
    }

    var m = v - c;

    this.r = Math.floor((r1 + m) * 255);
    this.g = Math.floor((g1 + m) * 255);
    this.b = Math.floor((b1 + m) * 255);
    this.alpha = alpha;
};

RGBACol.prototype.setRGBA = function(r, g, b, alpha) {
    this.r = r;
    this.g = g;
    this.b = b;
    this.alpha = alpha;
};
              
            
!
999px

Console