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

              
                
- var markers = 9;
- var directionIndicator = true;
- var circles = 141;
// Max circle nr seems to be 170 circles.
// Bigger than that and it won't save for me.

- var maxBorderWidth = 5;
- var maxDiameter = 60;
- var maxOpacity = 0.7;
- var oddsOfColor = 0.2;


//////////////////////////
///////// COLORS /////////

// Uncomment a row for different looks:

// - var colors = ['EF6F6C', '465775', '56E39F', '59C9A5', '5B6C5D'];
// - var colors = ['495867', '577399', 'FE5F55', 'BDD5EA', 'F7F7FF'];
// - var colors = ['4D9DE0', 'E15554', 'E1BC29', '3BB273', '7768AE'];
- var colors = ['CA054D', '25CED1', 'E55934', 'EA526F', 'FF8A5B'];
// - var colors = ['3B1F2B', 'DB162F', 'DBDFAC', '5F758E', '383961'];
// - var colors = ['009DDC', 'F26430', '2A2D34', '6761A8', '009B72'];
// - var colors = ['0D0106', '3626A7', '657ED4', 'FF331F', 'A83759'];
// - var colors = ['DD6E42', 'ACF39D', '484A47', '773344', 'E3B5A4'];
// - var colors = ['4B4237', 'FF4E00', '8ED081', 'CC2936', 'ADB221'];

//////////////////////////
////////// APP ///////////

- var markerSize = '256px';
- var possibleLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- var markerNameLength = 8;

section
  h1 ARkit and Vuforia optimized markers
  p For different looks, play with the variables in the Codepen HTML editor.
  p If you have trouble saving the png, try turning down the number of circles.
  br
  p The generator is made by <a href="http://evry.one" target="_blank">evry.one</a> / <a href="https://twitter.com/evryone_XR" target="_blank">@evryone_XR</a>
  p See my other generator for AR.js here: <a href="https://codepen.io/staus/pen/oEOJpq" target="_blank">Markers for AR.js</a>

ul
  - for (var a = 0; a < markers; a++)
    - var text = ""
    - for (var o = 0; o < markerNameLength; o++)
      - text += possibleLetters.charAt(Math.floor(Math.random() * possibleLetters.length));
    li(id=a + '-' + text)
      figure(style='width: ' + markerSize + ';')
        ul.circles
          - if(directionIndicator == true)
            div.arrow
          - for (var u = 0; u < circles; u++)
            - var posx = Math.random() * 100;
            - var posy = Math.random() * 100;
            - var diameter = Math.random() * maxDiameter + 8;
            - var border = Math.random() * maxBorderWidth + 2;
            - var alpha = Math.random() * maxOpacity;
            - var color = '#000000';
            - if (Math.random() < oddsOfColor)
              - color = Math.round(Math.random() * (colors.length - 1))
            li(
            style=
            'left: ' + posx + '%; ' +
            'top: ' + posy + '%;' +
            'width: ' + diameter + 'px; height: ' + diameter + 'px;' +
            'border-width: ' + border + 'px;' + 
            'border-color: #' + colors[color] + ';' +
            'opacity: ' + alpha + ';'
            )
      .download
        button.download-marker .png
        
        

              
            
!

CSS

              
                $padding: 20px;
$easeOutCubic: 0.215, 0.610, 0.355, 1.000;

body{
  background-color: #FFFfff;
}

section{
  text-align: center;
  -webkit-font-smoothing: antialiased;
  h1{
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    max-width: 500px;
    font-family: "grad", serif;
    line-height: 1.1em;
    color: #3A405A;
    font-size: 3em;
    margin-bottom: 0.3em;
  }
  p, a{
    font-family: "freight-sans-pro";
    color: #3A405A;
    margin: 0;
    line-height: 1.3em;
  }
}
body>ul{
  display: flex;
  padding: $padding / 4;
  box-sizing: border-box;
  justify-content: space-evenly;
  flex-wrap: wrap;
  >li{
    position: relative;
    display: inline-block;
    // overflow: hidden;
    padding: $padding / 2;
    box-sizing: border-box;
  }
}
figure{
  position: relative;
  margin: 0px;
  margin-bottom: $padding / 4;
  overflow: hidden;
  background-color: white;
  
  &:before{
    content: "";
    display: block;
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    // background-color: black;
  }
  .arrow{
    position: absolute;
    top: $padding / 4;
    right: $padding / 4;
    z-index: 100;
    width: 0; 
    height: 0; 
    border-left: 1px solid transparent;
    border-right: 1px solid transparent;

    border-bottom: 3px solid black;
    // transform: scaleX(0.5);
  }
  ul{
    position: absolute;
    top: 0;
    padding: 0;
    margin: 0;
    // overflow: hidden;
    width: 100%;
    height: 100%;
    transform: translateZ(0);
    li{
      list-style-type: none;
      position: absolute;
      width: 10%;
      height: 10%;
      border: 10px solid black;
      border-radius: 50%;
      transform: translate(-50%, -50%);
    }
  }
}

.download{
  display: flex;
  justify-content: space-evenly;
  button{
    display: inline-block;
    font-family: "freight-sans-pro";
    width: 50%;
    height: $padding * 2;
    background-color: #999;
    border: none;
    will-change: transform; 
    transition: transform 0.3s cubic-bezier($easeOutCubic);
    transform: scale(1);
    cursor: pointer;
    color: white;
    &:first-of-type{
      margin-right: 3px;
      transform-origin: 66.666% 50%;
    }
    &:last-of-type{
      margin-left: 3px;
      transform-origin: 33.333% 50%;
    }
    &:hover{
      transform: scale(0.95);
    }
  }
}

li.saving{
  opacity: 0;
  figure{
    overflow: visible;
    transform: scale(4);
    ul{
      transform: translate(37.5%, 37.5%)
    }
  }
}

@media print { 
  a{
    display: none;
  }
}
              
            
!

JS

              
                const markerDownload = document.getElementsByClassName("download-marker")
for (let i = 0; i < markerDownload.length; i++) {
  markerDownload[i].addEventListener("click", downloadMarker)
}

function downloadMarker() {
  const item = this.parentElement.parentElement
  const name = item.id
  const marker = item.getElementsByTagName("figure")[0]
  const save = marker.getElementsByTagName("ul")[0]
  // const pattern = marker.getElementsByClassName("border")[0]
  item.classList.add("saving");
  setTimeout(function(){
    html2canvas(marker, {width: 1024, height: 1024}).then(canvas => {
      const image = canvas.toDataURL("image/png")
      console.log(image)
      downloadFile(image, name, '.png')
      item.classList.remove("saving");
    })
  }, 0)
}

function downloadFile(fileString, name, type) {
  // tech from https://stackoverflow.com/questions/3665115/create-a-file-in-memory-for-user-to-download-not-through-server
	var domElement = window.document.createElement('a');
  if (type == '.png') {
    domElement.href = fileString;
  } else {
    domElement.href = window.URL.createObjectURL(new Blob([fileString], {type: 'text/plain'}));
  }
  domElement.download = 'marker-' + name + type;
  document.body.appendChild(domElement)
  domElement.click();
  document.body.removeChild(domElement)
}
              
            
!
999px

Console