Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!-- Steven Universe: Ameythest https://zzz.dog/ 
https://steven-universe.fandom.com/wiki/Amethyst
-->

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

              
            
!

CSS

              
                .zdog-canvas {

  cursor: move;
}

html { height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #435;
  color: white;
  font-family: sans-serif;
  text-align: center;
}

canvas {
  display: block;
  margin: 0 auto;
  cursor: move;
}

              
            
!

JS

              
                const TAU = Zdog.TAU;
const offWhite='#FED';
const skin = '#B998CA';
const shirt='#19151D';
const pants='#656D8E';
const shoe='#FBE8FD';
const garnet='#19151D';
const eggplant='#636';
const hair="#DCD3EF";
const gemstone="#DB68FF";
var glow = 'hsla(286,100%,30%)';
var shadow = 'hsla(286,100%,.10%,20%)'


function setup() {
 noCanvas();
}

let illo = new Zdog.Illustration({
  element: '.zdog-canvas',
  zoom: 10,
  dragRotate: true,
  
  // rotate for three-quarters view
  // rotate: { y: -Zdog.TAU/8 },
});

// ---- model ---- //

let hipX = 3.4;


let hips = new Zdog.Shape({
  addTo: illo,
  path: [ { x:  -hipX }, { x: hipX } 
        ],
  stroke: 5,
   // move down a little
  translate: { y: 2 },
  // rotate: { x: TAU/8 },
  color:  shirt,
});

let leg = new Zdog.Shape({
  addTo: hips,
  path: [ { y: 4 }, { y: 10 } ],
  translate: { x: -hipX },
  // rotate leg
  // rotate: { x: TAU/4 },
  color: pants,
  stroke: 5,
  fill:true,
});


// foot
let foot = new Zdog.RoundedRect({
  addTo: leg,
  width: 2,
  height: 4,
  cornerRadius: 1,
  // y: past leg end, z: scootch toward front
  translate: { y: 14, z: 2 },
    // rotate 90° along x-axis
  rotate: { x: Zdog.TAU/4 },
  color: shoe,
  fill: true,
  stroke: 4,
});

let standLeg =leg.copy({
  // position on right
  translate: { x: hipX },
  // rotate leg
  rotate: { x: -TAU/8 },
});

let shadowspot = 
    new Zdog.Cone({
  addTo: hips,
  diameter: 30,
  length: 0,
  stroke: 0,
  color: shadow,
  translate: {y:17.2},
  backface: true,
  rotate: {x: TAU/4.2},
});
// new Zdog.Ellipse({
//   addTo: hips,
//   diameter: 1,
//   stroke: 20,
//   color: shadow,
//   translate: {y:20},
//   rotate: {z: TAU/2},
// });

let star = new Zdog.Shape({
  addTo: leg,
  translate: { x: -hipX/2, y:4.5, z:2.4 },
path: [
 {line: {x:1.00, y:.10}},
 {line: {x:.40, y:1.98}},
 {line: {x:1.90, y:.78}},
 {line: {x:.10, y:.78}},
 {line: {x:1.60, y:1.98}}
 ],
 
  stroke: .8,
  scale:1.6,
  color: shirt,
  fill: true
});
star.copy ({
  addTo:standLeg,
});

// standfoot
foot.copy ({
  addTo:standLeg,
  rotate: { x: -TAU/8}
  
})

// separate anchor just for rotating upper body
let spine = new Zdog.Anchor({
  addTo: hips,
  // rotate: { x: TAU/8 },
});

let chest = new Zdog.Shape({
  addTo: spine,
  path: [ { x: -1.5 }, { x: 1.5 } ],
  // position right above hips
  // ( hips.stroke + chest.stroke ) / 2
  translate: { y: -6.5 },
  stroke: 10,
  color: garnet,
});

let gem = new Zdog.Hemisphere({
  addTo: illo,
  diameter: 3,
  translate: { y: -4.5,z: 4.2},
  // fill enabled by default
  // disable stroke for crisp edge
  stroke: false,
  color: gemstone,
  backface: pants,
});
gem.copy ({
  addTo:gem,
  rotate: { x: -TAU/2},
  translate: { y:0, z:-.21},
  diameter: 3.6,
  color:shirt,
  backface: glow,
})


let waist = new Zdog.Shape({
  addTo: spine,
  path: [ { x:  -hipX }, { x: hipX } 
        ],
  stroke: 2,
  translate: { y: -2 },
  color:  shirt,
});

var armSize = 6;

// left arm
let upperArm = new Zdog.Shape({
  addTo: chest,
  path: [ { y: 0 }, { y: armSize } ],
  translate: { x: -5 , y: -2},
  rotate: { x: -TAU/4 },
  color: skin,
  stroke: 5,
});

let forearm = new Zdog.Shape({
  addTo: upperArm,
  path: [ { y: 0 }, { y: armSize } ],
  translate: { y: armSize},
    rotate: { x: TAU/8 },
  color: skin,
  stroke: 4,
});
// hand
let hand = new Zdog.Shape({
  addTo: forearm,
  // connect to end of forearm
  // scootch toward front a bit
  translate: { y: armSize, z: 1 },
  stroke: 5,
  color: skin,
});
// arm on right
upperArm.copyGraph({
  translate: { x: 6, y: -1 },
  // rotate forward 90°
  rotate: { x: TAU/8, z: -TAU/15, y: TAU/20 },
});


let head = new Zdog.Shape({
  addTo: chest,
  stroke: 12,
  color: skin,
  translate: {y:-10.5},
});

let noseOutline = new Zdog.Ellipse({
  addTo: head,
  diameter: -2.0,
  quarters: 2, // semi-circle
  translate: { x: 0, y: .5, z: 4.5 },
  // rotate semi-circle to down
  rotate: { z: -TAU/4 },
  color: shirt,
  stroke: 0.8,
  // hide when front-side is facing back
  backface: false,
});
let nose = new Zdog.Hemisphere({
  addTo: head,
  diameter: 2.4,
  translate: { y: .6,z: 5.5},
  // fill enabled by default
  // disable stroke for crisp edge
  stroke: false,
  color: skin,
  backface: skin,
});
let neck = new Zdog.Ellipse({
  addTo: chest,
  diameter: 4,
  // quarters: 2, // semi-circle
  translate: { x: 0, y: -4, z: 1.4 },
  rotate: { x: TAU/10},
  color: skin,
  fill: true,
});
let eye = new Zdog.Ellipse({
  addTo: head,
  diameter: 2.4,
  translate: { x: -2.5, y: -1.2, z: 4.5 },
  color: '#fff',
  stroke: 0.5,
  fill: true,
});
let pupil = new Zdog.Ellipse({
  addTo: eye,
  diameter: .4,
  translate: { x: 0, y: .4, z: .2 },
  color: '#000',
  stroke: 0.5,
  fill: true,
});
// eye on right
eye.copy({
  translate: { x: 2.5, y: -1.2, z: 4.5 },
});
pupil.copy({
  translate: { x: 5, y: .4, z: .2 },
});

// smile
new Zdog.Ellipse({
  addTo: head,
  diameter: 6,
  quarters: 1,
  translate: { x: -.2, y: .7, z: 4.5 },
  rotate: { z: TAU/3 },
  closed: true,
  color: '#FFF',
  stroke: 0.5,
  fill: true,
  backface: false,
});



// hair started from from example 
// https://codepen.io/desandro/pen/RQeYYp?editors=0010  //
// hair ball
  new Zdog.Shape({
    path: [
      { x: -1 },
      { x: 1 },
      { z: -4 },
    ],
    addTo: head,
    translate: { y: -4, z: -1 },
    stroke: 15,
    color: hair,
  });

  var bang = new Zdog.Shape({
    path: [
      {},
      { arc: [
        { z: 5, y: 4 },
        { z: -2, y: 16 },
      ]},
    ],
    addTo: head,
    translate: { x: -1.4, y: -7.5, z: 2 },
    rotate: { x: 0.8, z: -0.4 },
    stroke: 3,
    color: hair,
    closed: false,
  });
  bang.copy({
    translate: { x: 5, y: -6, z: 5 },
    rotate: { x: -0.3, z: -0.5 },
    color: hair,
    stroke: 5,
    
  });
  bang.copy({
    translate: { x: 5, y: -6, z: 3 },
    rotate: { y: -0.7, z: -1 },
    color: hair,
    stroke: 5,
    
  });
  bang.copy({
    translate: { x: -2, y: -6, z: 3 },
    rotate: { y: 180, z: 1 },
    color: hair,
    stroke: 3,
    
  });


// hair covers the entry point of strands
  new Zdog.Shape({
    path: [
      { x: -3 },
      { x:  3 },
    ],
    addTo: head,
    stroke: 7,
    translate: { y: -8, z: 5 },
    color: hair,
  });



  // trail locks

  var trailLock = new Zdog.Shape({
    path: [
      { y: -4, z: 0 ,x:3 }, //start
      { bezier: [
        { y: -10, z: -4}, //start control pt
        { y: 25, z: -6}, //end ctrl pt
        { y: 20, z: -14, x:-15} //end
      ]},
    ],
    addTo: head,
    translate: { z: -3, y: 0 },
    stroke: 4,
    color: hair,
    closed: false,
  });

  trailLock.copy({
    translate: { x: -3, z: -4 },
    // rotate: { z: -TAU/8 },
    // stroke: 8,
  });
  trailLock.copy({
    translate: { x: 3, z: -4 },
    // rotate: { z: TAU/8 },
    // stroke: 8,
  });
  trailLock.copy({
    translate: { y: 2 },
    // rotate: { z: TAU/2 },
    scale: { y: 0.5 },
    stroke: 8,
  });

// -- animate --- //

function animate() {
  illo.updateRenderGraph();
  requestAnimationFrame( animate );
}
animate();
              
            
!
999px

Console