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 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

              
                #cc
              
            
!

CSS

              
                #cc
  max-width 1536px
  margin 0 auto
              
            
!

JS

              
                var w = 1536;
var h = 864;
var canvas;
var epoch = 0;
var ename = ["PROTON LIMIT EXCEEDED!", "hydrogen", "helium", "lithium", "beryllium", "boron", "carbon", "nitrogen", "oxygen", "fluorine", "neon", "natrium", "magnesium", "aluminium", "silicon", "phosphorus", "sulfur", "chlorine", "argon", "potassium", "calcium", "scandium", "titanium", "vanadium", "chromium", "manganese", "iron", "cobalt", "nickel", "copper", "zinc", "gallium", "germanicum", "arsenic", "selenium", "bromine", "krypton", "rubidium", "strontium", "yttrium", "zirconium", "niobium", "molybdenum", "technetium", "ruthenium", "rhodium", "palladium", "silver", "cadmium", "inidum", "tin", "antimony", "tellurium", "iodine", "xenon"];
var palette = [null, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
var period = [null, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2];
var group = [null, 0, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7];
var table = [[1, 0, 0, 0, 0, 0, 0, 2], [3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18]];
var dia = 60;
var cur = 1;
var ch1 = 0;
var ch2 = 0;

function setup() {
  canvas = createCanvas(w,h);
  canvas.parent("cc");
  textFont("Montserrat");
  colorMode(HSB);
  ellipseMode(CENTER);
  rectMode(CENTER);
  noStroke();
}

function draw() {
  background(255);
  switch (epoch) {
    case 0:
      textAlign(CENTER, CENTER);
      textSize(48);
      text("Find your way to", w/2, h*3/8);
      text("Click to continue...", w/2, h*5/8);
      textSize(144);
      text("VANADIUM", w/2, h/2);
      break;
    case 1:
      textSize(48);
      text("You have dreamed about it since time immemorial.\n\nVanadium!\n\nThe single most desired element of your life.\nNow you have access to this machine.\nStarting with hydrogen, it can skip to the element with its\nproton number equal to the next element of the previous\none's Z's Collatz sequence. It can also save elements up to argon\nfor later use in a palette (top row) and skip to those at any time.\nBesides, it can perform a lookup on the periodic table, using\nan element from the palette to determine the period\nand another to determine the group. However, it has a proton\nlimit of 54. This could be life-changing... Now get to 23!", w/2, h/2);
      break;
    case 2:
      drawpal();
      drawele(cur, true, 5, w/2, h/2);
      fill(0);
      textSize(48);
      text(ename[cur], w/2, h/4);
      if (cur) rect(w/2, h*13/16, w/2, h/8, h/32);
      fill(60);
      rect(w/2, h*15/16, w/2, h/16, h/32);
      fill(100);
      textSize(96);
      text("COLLATZ!", w/2, h*13/16);
      textSize(36);
      text("Periodic table lookup", w/2, h*15/16);
      break;
    case 3:
      drawpal();
      drawele(ch1, ch1, 5, w/3, h/2);
      drawele(ch2, ch2, 5, w*2/3, h/2);
      fill(0);
      textSize(36);
      if (!ch1) {
        text("Choose from above\nto determine the period", w/3, h/4);
      } else if (!ch2) {
        text("Choose from above\nto determine the group", w*2/3, h/4);
      } else if (table[period[ch1]][group[ch2]]) {
        rect(w/2, h*13/16, w/2, h/8, h/32);
      }
      fill(60);
      rect(w/2, h*15/16, w/2, h/16, h/32);
      fill(100);
      textSize(72);
      text("Perform lookup", w/2, h*13/16);
      textSize(36);
      text("Cancel lookup", w/2, h*15/16);
      break;
    case 4:
      fill(0);
      textSize(48);
      text("You've found your way to", w/2, h*3/8);
      text("Congratulations...", w/2, h*5/8);
      textSize(144);
      text("VANADIUM", w/2, h/2);
      break;
  }
}

function mouseClicked() {
  switch (epoch) {
    case 0:
    case 1:
      epoch += 1;
      break;
    case 2:
      if (mouseY > h/8-dia && mouseY < h/8+dia) {
        let e = Math.floor((mouseX-w/2)/dia*3/4+10);
        if (e == 19 || !palette[e]) e = 0;
        if (e) cur = e;
      } else if (mouseX > w/4 && mouseX < w*3/4) {
        if (mouseY > h*3/4 && mouseY < h*7/8) {
          if (cur%2) cur = cur*3+1;
          else cur /= 2;
          if (cur > 54) cur = 0;
          else if (cur && cur <= 18) palette[cur] = true;
          else if (cur == 23) epoch = 4;
        } else if (mouseY > h*29/32 && mouseY < h*31/32) {
          epoch += 1;
        }
      }
      break;
    case 3:
      if (mouseY > h/8-dia && mouseY < h/8+dia) {
        let e = Math.floor((mouseX-w/2)/dia*3/4+10);
        if (e == 19 || !palette[e]) e = 0;
        if (e) {
          if (!ch1) ch1 = e;
          else if (!ch2) ch2 = e;
        }
      } else if (mouseX > w/4 && mouseX < w*3/4) {
        if (mouseY > h*3/4 && mouseY < h*7/8 && ch1 && ch2) {
          cur = table[period[ch1]][group[ch2]];
          if (cur && cur <= 18) palette[cur] = true;
          epoch -= 1;
          ch1 = 0;
          ch2 = 0;
        } else if (mouseY > h*29/32 && mouseY < h*31/32) {
          epoch -= 1;
          ch1 = 0;
          ch2 = 0;
        }
      }
      break;
  }
}

function drawpal() {
  for (let i = 1; i <= 18; i += 1) {
    drawele(i, palette[i], 1, w/2+(i-9.5)*dia*4/3, h/8);
  }
}

function drawele(z, col, d, x, y) {
  push();
  noStroke();
  if (col) {
    fill(z*69%360, 100, 100);
  } else {
    fill(80);
  }
  ellipse(x, y, d*dia, d*dia);
  if (z) {
    fill(100);
    textSize(d*dia/2);
    text(z, x, y);
  }
  pop();
}
              
            
!
999px

Console