Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <main id=app>
  
  <h1>Squircles with Vue</h2>
  
  <section>
    
    <Squircle width=50 roundness=0.1 color="#ff5800">0.1</Squircle>
    <Squircle width=75 roundness=0.3 color="#ffe600">0.3</Squircle>
    <Squircle width=100 roundness=0.6 color="#c6ff00">0.6</Squircle>
    <Squircle width=150 roundness=1 color="mediumspringgreen" class="middle">1</Squircle>
    <Squircle width=100 roundness=1.2 color="#00e2ff">1.2</Squircle>
    <Squircle width=75 roundness=1.6 color="#877df9">1.6</Squircle>
    <Squircle width=50 roundness=1.8 color="#d48af7">1.8</Squircle>
    
  </section>

  <h3>Inspired by, and code/ideas influenced from: <a href="https://medium.com/@nikolskayaolia/a5ba4e1139ed">@nikolskayaolia</a>, <a href="https://blog.christopherkylehorton.com/2015/05/how-to-make-squircle-in-svg.html">@christopherkylehorton</a></h3>
  
  <section class="other">
    <Squircle width=80 height=120 roundness=0.1>0.1</Squircle>
    <Squircle width=120 height=80 roundness=0.35>0.35</Squircle>
    <Squircle width=100 height=90 roundness=0.8>0.8</Squircle>
    <Squircle width=150 height=120>1</Squircle>
    <Squircle width=90 height=100 roundness=1.25>1.25</Squircle>
    <Squircle width=80 height=120 roundness=1.6>1.6</Squircle>
    <Squircle width=120 height=80 roundness=2>2</Squircle>
  </section>
    
  <p>some other, random shapes and roundesses</p>
  
  <section class="bottom">
    <Squircle width=40 roundness="0.1">0.1</Squircle>
    <Squircle width=40 roundness="0.2">0.2</Squircle>
    <Squircle width=40 roundness="0.3">0.3</Squircle>
    <Squircle width=40 roundness="0.4">0.4</Squircle>
    <Squircle width=40 roundness="0.5">0.5</Squircle>
    <Squircle width=40 roundness="0.6">0.6</Squircle>
    <Squircle width=40 roundness="0.7">0.7</Squircle>
    <Squircle width=40 roundness="0.8">0.8</Squircle>
    <Squircle width=40 roundness="0.9">0.9</Squircle>
    <Squircle width=40 roundness="1">1</Squircle>
    <Squircle width=40 roundness="1.2">1.2</Squircle>
    <Squircle width=40 roundness="1.3">1.3</Squircle>
    <Squircle width=40 roundness="1.4">1.4</Squircle>
    <Squircle width=40 roundness="1.5">1.5</Squircle>
    <Squircle width=40 roundness="1.6">1.6</Squircle>
    <Squircle width=40 roundness="1.7">1.7</Squircle>
    <Squircle width=40 roundness="1.8">1.8</Squircle>
    <Squircle width=40 roundness="1.9">1.9</Squircle>
  </section>
  
  <section class="other">
    <Squircle width=200>
      <Squircle width=90 roundness="1.2" color="rgba(255,222,222,0.5)">
        <Squircle width=13 roundness="2" color="black" class="pupil">
        </Squircle>
      </Squircle>
      <Squircle width=90 roundness="1.2" color="rgba(222,255,255,0.5)">
        <Squircle width=14 roundness="2" color="black" class="pupil">
        </Squircle>
      </Squircle>
    </Squircle>
  </section>
  
</main>
            
          
!
            
              .squircle {
  
  color: #333844aa;
  font-weight: 800;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  position: relative;
  filter: drop-shadow( 0 3px 6px rgba(0,0,0,0.4) );
  
}







/******************************/

body {
  color: white;
  background: #333844;
  padding: 20px;
  font-family: "Heebo", sans-serif;
  text-align: center;
}

main section {
  display: flex;
  justify-content: center;
  align-items: center;
  &.other {
    margin-top: 150px;
  }
  .squircle {
    margin: 0 10px;
  }
  &.bottom .squircle {
    margin: 0 4px;
  }
}

.middle {
  font-size: 40px;
}

.icon {
  width: 50%;
  margin: auto;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

a {
  color: #00e2ff;
}

h3,p {
  font-weight: 300;
  opacity: 0.8;
}

.squircle .squircle {
  margin: 2px;
}
            
          
!
            
              
Vue.component( "Squircle", {
  template: `
    <div class="squircle" :style="{ width: w + 'px', height: h + 'px', 'background-image': bgImage }">
        <slot></slot>
    </div>
  `,
  props: {
    width: { type: Number, default: 100 },
    height: { type: Number },
    roundness: { type: Number, default: 1 },
    color: { type: String, default: "#7788aa" }
  },
  computed: {
    w() {
      return this.width;
    },
    h() {
      return this.height || this.width;
    },
    path() {
      let w = this.w;
      let h = this.h;
      let wm = w * ( h / w );
      let r = -( w / 20 ) + ( w / 10 * this.roundness );
      let path = `
        M ${w/2},0
        C ${r},0        0,${r}        0,${wm/2} 
          0,${wm-r}     ${r},${wm}    ${w/2},${wm} 
          ${w-r},${wm}  ${w},${wm-r}  ${w},${wm/2} 
          ${w},${r}     ${w-r},0      ${w/2},0
      `;
      return path.replace( /  +/g, " " ).replace( /\n/gi,"" );
    },
    svg() {
      let svg = `<svg xmlns='http://www.w3.org/2000/svg'><path d='${this.path}' fill='${this.color}'></path></svg>`;
      return svg.replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E");
    },
    bgImage() {
      return `url("data:image/svg+xml;utf8,${this.svg}")`;
    }
  }
});

let app = new Vue({
  el: "#app",
  data: {}
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console