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

              
                <canvas class="zdog-canvas" width="600" height="600"></canvas>

<div class='credit'>
    <p>Created by <a class='credit--link' href='https://codepen.io/travis_john'>Travis John</a></p>
  </div>
              
            
!

CSS

              
                body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

canvas {
  border-radius: 1em;
  // border: .25rem solid black;
}

.credit {
  position: fixed;
  bottom: 2%;
  right: 2%;
  font-family: 'Roboto', sans-serif;
  text-transform: uppercase;
  font-size: 1.125em;
  color: black;
  
  .credit--link {
    color: #1565C0;
    text-decoration: none;
    cursor: pointer;
    
    &:hover {
      text-decoration: underline;
    }
  }
}
              
            
!

JS

              
                //ToDo: use copy or copyGraph to generate second stars and stripes

//declaring colors
var colors = {
  red: '#c2002f',
  blue: '#212844',
  gold: '#D3A925'
}

//rendering to canvas
let illo = new Zdog.Illustration({
  element: '.zdog-canvas',
  dragRotate: true
});

//shield outline
new Zdog.Shape({
  addTo: illo,
  path: [
    {x: -120, y: -140}, // start point
    {x: 120, y: -140 },
    {x: 120, y: 45},
    {bezier: [
      { x:  120, y: 45 }, // start control point
      { x:  120, y:  150 }, // end control point
      { x:  0, y:  190 },
    ]},
    {bezier: [
      { x:  0, y: 190 }, // start control point
      { x:  -120, y:  150 }, // end control point
      { x:  -120, y:  45 },
    ]},
  ],
  translate: {z: 5},
  stroke: 5,
  fill: false,
  color: colors.blue,
});

//declaring star group
var crown = new Zdog.Group({
  addTo: illo,
  translate: { y: -180},
});
var topCrown = new Zdog.Group({
  addTo: illo,
  translate: { y: -240},
});

//declaring anchor groups
let firstStar = new Zdog.Anchor({
  addTo: crown,
  rotate: { z: Zdog.TAU/2 },
  scale: .15,
  translate: { x: -100 }
});
let secondStar = new Zdog.Anchor({
  addTo: crown,
  rotate: { z: Zdog.TAU/2 },
  scale: .15,
  translate: { x: -0 }
});
let thirdStar = new Zdog.Anchor({
  addTo: crown,
  rotate: { z: Zdog.TAU/2 },
  scale: .15,
  translate: { x: 100 }
});
let fourthStar = new Zdog.Anchor({
  addTo: topCrown,
  rotate: { z: Zdog.TAU/2 },
  scale: .15,
  translate: { x: 0 }
});

//pentagons
let pentagon = new Zdog.Polygon({
  addTo: firstStar,
  radius: 60,
  sides: 5,
  stroke: 4,
  color: colors.blue,
  fill: true,
});
let pentagon2 = new Zdog.Polygon({
  addTo: secondStar,
  radius: 60,
  sides: 5,
  stroke: 4,
  color: colors.blue,
  fill: true,
});
let pentagon3 = new Zdog.Polygon({
  addTo: thirdStar,
  radius: 60,
  sides: 5,
  stroke: 4,
  color: colors.blue,
  fill: true,
});
let pentagon4 = new Zdog.Polygon({
  addTo: fourthStar,
  radius: 60,
  sides: 5,
  stroke: 4,
  color: colors.gold,
  fill: true,
});

//triangles
let triangle = new Zdog.Shape({
  addTo: firstStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle2 = new Zdog.Shape({
  addTo: firstStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  rotate: { z: Zdog.TAU/5 },
  stroke: 2,
  fill: true,
});
let triangle3 = new Zdog.Shape({
  addTo: firstStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  rotate: { z: Zdog.TAU/2.5 },
  stroke: 2,
  fill: true,
});
let triangle4 = new Zdog.Shape({
  addTo: firstStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle5 = new Zdog.Shape({
  addTo: firstStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  rotate: { z: Zdog.TAU/1.25 },
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle6 = new Zdog.Shape({
  addTo: secondStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle7 = new Zdog.Shape({
  addTo: secondStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  rotate: { z: Zdog.TAU/5 },
  stroke: 2,
  fill: true,
});
let triangle8 = new Zdog.Shape({
  addTo: secondStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  rotate: { z: Zdog.TAU/2.5 },
  stroke: 2,
  fill: true,
});
let triangle9 = new Zdog.Shape({
  addTo: secondStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle10 = new Zdog.Shape({
  addTo: secondStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  rotate: { z: Zdog.TAU/1.25 },
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle11 = new Zdog.Shape({
  addTo: thirdStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle12 = new Zdog.Shape({
  addTo: thirdStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  rotate: { z: Zdog.TAU/5 },
  stroke: 2,
  fill: true,
});
let triangle13 = new Zdog.Shape({
  addTo: thirdStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.blue,
  rotate: { z: Zdog.TAU/2.5 },
  stroke: 2,
  fill: true,
});
let triangle14 = new Zdog.Shape({
  addTo: thirdStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle15 = new Zdog.Shape({
  addTo: thirdStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  rotate: { z: Zdog.TAU/1.25 },
  color: colors.blue,
  stroke: 2,
  fill: true,
});
let triangle16 = new Zdog.Shape({
  addTo: fourthStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.gold,
  stroke: 2,
  fill: true,
});
let triangle17 = new Zdog.Shape({
  addTo: fourthStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.gold,
  rotate: { z: Zdog.TAU/5 },
  stroke: 2,
  fill: true,
});
let triangle18 = new Zdog.Shape({
  addTo: fourthStar,
  path: [
    { x:   0, y: 125 },
    { x:  40, y:  50 },
    { x: -40, y:  50 },
  ],
  color: colors.gold,
  rotate: { z: Zdog.TAU/2.5 },
  stroke: 2,
  fill: true,
});
let triangle19 = new Zdog.Shape({
  addTo: fourthStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  color: colors.gold,
  stroke: 2,
  fill: true,
});
let triangle20 = new Zdog.Shape({
  addTo: fourthStar,
  path: [
    { x:   125, y: 40 },
    { x:  40, y:  50 },
    { x: 61, y:  -20 },
  ],
  rotate: { z: Zdog.TAU/1.25 },
  color: colors.gold,
  stroke: 2,
  fill: true,
});

//declaring stripe group
var stripes = new Zdog.Group({
  addTo: illo,
  // translate: { y: -40, z: 10 },
});

//indvidual stripes
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: -20 }, // start at 1st point
    { y: 80 }, // line to 2nd point
  ],
  translate: {x: -90, y: 0},
  stroke: 15,
  color: colors.red,
});
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: -5 }, // start at 1st point
    { y: 130 }, // line to 2nd point
  ],
  translate: {x: -60, y: 0},
  stroke: 15,
  color: colors.red,
});
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: 10 }, // start at 1st point
    { y: 150 }, // line to 2nd point
  ],
  translate: {x: -30, y: 0},
  stroke: 15,
  color: colors.red,
});
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: 25 }, // start at 1st point
    { y: 170 }, // line to 2nd point
  ],
  translate: {x: 0, y: 0},
  stroke: 15,
  color: colors.red,
});
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: 10 }, // start at 1st point
    { y: 150 }, // line to 2nd point
  ],
  translate: {x: 30, y: 0},
  stroke: 15,
  color: colors.red,
});
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: -5 }, // start at 1st point
    { y: 130 }, // line to 2nd point
  ],
  translate: {x: 60, y: 0},
  stroke: 15,
  color: colors.red,
});
new Zdog.Shape({
  addTo: stripes,
  path: [
    { y: -20 }, // start at 1st point
    { y: 80 }, // line to 2nd point
  ],
  translate: {x: 90, y: 0},
  stroke: 15,
  color: colors.red,
});

//declaring words group
var USA = new Zdog.Group({
  addTo: illo,
  translate: { x: -80, y: -120 },
});

//individual letters
let letterU = new Zdog.Shape({
  addTo: USA,
  path: [
    { x: -100, y: 0 }, // start at 1st point
    { x: -100, y: 60 }, // line to 2nd point
    { x: -70,  y: 85},
    { x: -70,  y: 0},
  ],
  translate: {x: 90, y: 0},
  stroke: 15,
  color: colors.blue,
  closed: false
});
let letterS = new Zdog.Shape({
  addTo: USA,
  path: [
    { x: 20, y: 20 }, // start at 1st point
    { x: 20, y:0},
    { x: -40, y: 0},
    {x: -40, y: 35},
    {x: 20, y: 65},
    {x: 20, y: 95},
    {x: -10, y: 120},
    {x: -40, y: 95},
    {x: -40, y: 75}
  ],
  translate: {x: 90, y: 0},
  stroke: 15,
  color: colors.blue,
  closed: false
});
let letterA = new Zdog.Shape({
  addTo: USA,
  path: [
    { x: 50, y: 85 }, // start at 1st point
    { x: 50, y: 0},
    { x: 80, y:  0},
    { x: 80, y: 65},
    { x: 80, y: 35},
    { x: 50, y: 50}
    
  ],
  translate: {x: 90, y: 0},
  stroke: 15,
  color: colors.blue,
  closed: false
});


//rotate function
function animate() {
  illo.rotate.y -= 0.01;
  illo.updateRenderGraph();
  requestAnimationFrame(animate);
}

animate();
              
            
!
999px

Console