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

              
                
              
            
!

CSS

              
                html,
body {
	padding: 0;
	margin: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
              
            
!

JS

              
                var s = 120;
var tri;

function setup() {
  createCanvas(windowWidth, windowHeight);
  fill(255, 25);

  tri = [
    [0, -s / sqrt(3)],
    [-s / 2, s * 0.5 / sqrt(3)],
    [s / 2, s * 0.5 / sqrt(3)]
  ];

  newTween();
}


function draw() {
  background(255);

  for (var i = 0; i <= width; i++) {
    var j = map(i, 0, width, 0, 1);
    var c = lerpColor(c1, c2, j);
    stroke(c);
    line(i, 0, i, height);
  }

  push();
    noStroke();
    translate(width / 4, height / 4);
    triangle(tri[0][0], tri[0][1], tri[1][0], tri[1][1], tri[2][0], tri[2][1]);
  pop();
}


function newTween() {
  var gradStart = randomGradient();
    c1 = gradStart[0];
    c2 = gradStart[1];

  t = new MOTION.Tween(30)
            .add(this, 'c1', gradStart[0])
            .add(this, 'c2', gradStart[1])
            .easing(Sine.InOut)
            .relative()
            .play()
            .onEnd(function() {
              var gradEnd = randomGradient();
              t.get('c1').setEnd(gradEnd[0]);
              t.get('c2').setEnd(gradEnd[1]);
              t.play();
            });
}


function randomGradient() {
  var gradient = gradients[Math.floor( Math.random() * gradients.length )];

  var _c1 = hexToRgb(gradient.colour1);
  var _c2 = hexToRgb(gradient.colour2);

  return [color(_c1.r, _c1.g, _c1.b), color(_c2.r, _c2.g, _c2.b)];
}


function hexToRgb(hex) {
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  return result ? {r: parseInt(result[1], 16),
      g: parseInt(result[2], 16),
      b: parseInt(result[3], 16)
  } : null;
}


// -------------------------------------
// -------------------------------------
// Gradients From
// https://github.com/Ghosh/uiGradients
// By Indrashish Ghosh

var gradients = [
  {
    "name":"Emerald Water",
    "colour1":"#348F50",
    "colour2":"#56B4D3"
  },
  {
    "name":"Lemon Twist",
    "colour1":"#3CA55C",
    "colour2":"#B5AC49"
  },
  {
    "name":"Horizon",
    "colour1":"#003973",
    "colour2":"#E5E5BE"
  },
  {
    "name":"Rose Water",
    "colour1":"#E55D87",
    "colour2":"#5FC3E4"
  },
  {
    "name":"Frozen",
    "colour1":"#403B4A",
    "colour2":"#E7E9BB"
  },
  {
    "name":"Mango Pulp",
    "colour1":"#F09819",
    "colour2":"#EDDE5D"
  },
  {
    "name":"Bloody Mary",
    "colour1":"#FF512F",
    "colour2":"#DD2476"
  },
  {
    "name":"Aubergine",
    "colour1":"#AA076B",
    "colour2":"#61045F"
  },
  {
    "name":"Aqua Marine",
    "colour1":"#1A2980",
    "colour2":"#26D0CE"
  },
  {
    "name":"Sunrise",
    "colour1":"#FF512F",
    "colour2":"#F09819"
  },
  {
    "name":"Purple Paradise",
    "colour1":"#1D2B64",
    "colour2":"#F8CDDA"
  },
  {
    "name":"Sea Weed",
    "colour1":"#4CB8C4",
    "colour2":"#3CD3AD"
  },
  {
    "name":"Pinky",
    "colour1":"#DD5E89",
    "colour2":"#F7BB97"
  },
  {
    "name":"Cherry",
    "colour1":"#EB3349",
    "colour2":"#F45C43"
  },
  {
    "name":"Mojito",
    "colour1":"#1D976C",
    "colour2":"#93F9B9"
  },
  {
    "name":"Juicy Orange",
    "colour1":"#FF8008",
    "colour2":"#FFC837"
  },
  {
    "name":"Mirage",
    "colour1":"#16222A",
    "colour2":"#3A6073"
  },
  {
    "name":"Steel Gray",
    "colour1":"#1F1C2C",
    "colour2":"#928DAB"
  },
  {
    "name":"Kashmir",
    "colour1":"#614385",
    "colour2":"#516395"
  },
  {
    "name":"Electric Violet",
    "colour1":"#4776E6",
    "colour2":"#8E54E9"
  },
  {
    "name":"Venice Blue",
    "colour1":"#085078",
    "colour2":"#85D8CE"
  },
  {
    "name":"Bora Bora",
    "colour1":"#2BC0E4",
    "colour2":"#EAECC6"
  },
  {
    "name":"Moss",
    "colour1":"#134E5E",
    "colour2":"#71B280"
  },
  {
    "name":"Shroom Haze",
    "colour1":"#5C258D",
    "colour2":"#4389A2"
  },
  {
    "name":"Mystic",
    "colour1":"#757F9A",
    "colour2":"#D7DDE8"
  },
  {
    "name":"Midnight City",
    "colour1":"#232526",
    "colour2":"#414345"
  },
  {
    "name":"Sea Blizz",
    "colour1":"#1CD8D2",
    "colour2":"#93EDC7"
  },
  {
    "name":"Opa",
    "colour1":"#3D7EAA",
    "colour2":"#FFE47A"
  },
  {
    "name":"Titanium",
    "colour1":"#283048",
    "colour2":"#859398"
  },
  {
    "name":"Mantle",
    "colour1":"#24C6DC",
    "colour2":"#514A9D"
  },
  {
    "name":"Dracula",
    "colour1":"#DC2424",
    "colour2":"#4A569D"
  },
  {
    "name":"Peach",
    "colour1":"#ED4264",
    "colour2":"#FFEDBC"
  },
  {
    "name":"Moonrise",
    "colour1":"#DAE2F8",
    "colour2":"#D6A4A4"
  },
  {
    "name":"Clouds",
    "colour1":"#ECE9E6",
    "colour2":"#FFFFFF"
  },
  {
    "name":"Stellar",
    "colour1":"#7474BF",
    "colour2":"#348AC7"
  },
  {
    "name":"Bourbon",
    "colour1":"#EC6F66",
    "colour2":"#F3A183"
  },
  {
    "name":"Calm Darya",
    "colour1":"#5f2c82",
    "colour2":"#49a09d"
  },
  {
    "name":"Influenza",
    "colour1":"#C04848",
    "colour2":"#480048"
  },
  {
    "name":"Shrimpy",
    "colour1":"#e43a15",
    "colour2":"#e65245"
  },
  {
    "name":"Army",
    "colour1":"#414d0b",
    "colour2":"#727a17"
  },
  {
    "name":"Miaka",
    "colour1":"#FC354C",
    "colour2":"#0ABFBC"
  },
  {
    "name":"Pinot Noir",
    "colour1":"#4b6cb7",
    "colour2":"#182848"
  },
  {
    "name":"Day Tripper",
    "colour1":"#f857a6",
    "colour2":"#ff5858"
  },
  {
    "name":"Namn",
    "colour1":"#a73737",
    "colour2":"#7a2828"
  },
  {
    "name":"Blurry Beach",
    "colour1":"#d53369",
    "colour2":"#cbad6d"
  },
  {
    "name":"Vasily",
    "colour1":"#e9d362",
    "colour2":"#333333"
  },
  {
    "name":"A Lost Memory",
    "colour1":"#DE6262",
    "colour2":"#FFB88C"
  },
  {
    "name":"Petrichor",
    "colour1":"#666600",
    "colour2":"#999966"
  },
  {
    "name":"Jonquil",
    "colour1":"#FFEEEE",
    "colour2":"#DDEFBB"
  },
  {
    "name":"Sirius Tamed",
    "colour1":"#EFEFBB",
    "colour2":"#D4D3DD"
  },
  {
    "name":"Kyoto",
    "colour1":"#c21500",
    "colour2":"#ffc500"
  },
  {
    "name":"Misty Meadow",
    "colour1":"#215f00",
    "colour2":"#e4e4d9"
  },
  {
    "name":"Aqualicious",
    "colour1":"#50C9C3",
    "colour2":"#96DEDA"
  },
  {
    "name":"Moor",
    "colour1":"#616161",
    "colour2":"#9bc5c3"
  },
  {
    "name":"Almost",
    "colour1":"#ddd6f3",
    "colour2":"#faaca8"
  },
  {
    "name":"Forever Lost",
    "colour1":"#5D4157",
    "colour2":"#A8CABA"
  },
  {
    "name":"Winter",
    "colour1":"#E6DADA",
    "colour2":"#274046"
  },
  {
    "name":"Autumn",
    "colour1":"#DAD299",
    "colour2":"#B0DAB9"
  },
  {
    "name":"Candy",
    "colour1":"#D3959B",
    "colour2":"#BFE6BA"
  },
  {
    "name":"Reef",
    "colour1":"#00d2ff",
    "colour2":"#3a7bd5"
  },
  {
    "name":"The Strain",
    "colour1":"#870000",
    "colour2":"#190A05"
  },
  {
    "name":"Dirty Fog",
    "colour1":"#B993D6",
    "colour2":"#8CA6DB"
  },
  {
    "name":"Earthly",
    "colour1":"#649173",
    "colour2":"#DBD5A4"
  },
  {
    "name":"Virgin",
    "colour1":"#C9FFBF",
    "colour2":"#FFAFBD"
  },
  {
    "name":"Ash",
    "colour1":"#606c88",
    "colour2":"#3f4c6b"
  },
  {
    "name":"Shadow Night",
    "colour1":"#000000",
    "colour2":"#53346D"
  },
  {
    "name":"Cherryblossoms",
    "colour1":"#FBD3E9",
    "colour2":"#BB377D"
  },
  {
    "name":"Parklife",
    "colour1":"#ADD100",
    "colour2":"#7B920A"
  },
  {
    "name":"Dance To Forget",
    "colour1":"#FF4E50",
    "colour2":"#F9D423"
  },
  {
    "name":"Starfall",
    "colour1":"#F0C27B",
    "colour2":"#4B1248"
  },
  {
    "name":"Red Mist",
    "colour1":"#000000",
    "colour2":"#e74c3c"
  },
  {
    "name":"Teal Love",
    "colour1":"#AAFFA9",
    "colour2":"#11FFBD"
  },
  {
    "name":"Neon Life",
    "colour1":"#B3FFAB",
    "colour2":"#12FFF7"
  },
  {
    "name":"Man of Steel",
    "colour1":"#780206",
    "colour2":"#061161"
  },
  {
    "name":"Amethyst",
    "colour1":"#9D50BB",
    "colour2":"#6E48AA"
  },
  {
    "name":"Cheer Up Emo Kid",
    "colour1":"#556270",
    "colour2":"#FF6B6B"
  },
  {
    "name":"Shore",
    "colour1":"#70e1f5",
    "colour2":"#ffd194"
  },
  {
    "name":"Facebook Messenger",
    "colour1":"#00c6ff",
    "colour2":"#0072ff"
  },
  {
    "name":"SoundCloud",
    "colour1":"#fe8c00",
    "colour2":"#f83600"
  },
  {
    "name":"Behongo",
    "colour1":"#52c234",
    "colour2":"#061700"
  },
  {
    "name":"ServQuick",
    "colour1":"#485563",
    "colour2":"#29323c"
  },
  {
    "name":"Friday",
    "colour1":"#83a4d4",
    "colour2":"#b6fbff"
  },
  {
    "name":"Martini",
    "colour1":"#FDFC47",
    "colour2":"#24FE41"
  },
  {
    "name":"Metallic Toad",
    "colour1":"#abbaab",
    "colour2":"#ffffff"
  },
  {
    "name":"Between The Clouds",
    "colour1":"#73C8A9",
    "colour2":"#373B44"
  },
  {
    "name":"Crazy OrangeI",
    "colour1":"#D38312",
    "colour2":"#A83279"
  },
  {
    "name":"Hersheys",
    "colour1":"#594a41",
    "colour2":"#9a8478"
  }
];
              
            
!
999px

Console