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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <canvas class="zdog-canvas"></canvas>

              
            
!

CSS

              
                body{
	display: grid;
	place-items: center;
	height: 100vh;
	width: 100vw;
	margin: 0;
	background: #D7E8FC;
}

.zdog-canvas{
	border-radius: 50%;
}
              
            
!

JS

              
                const sunClr = '#FFE6BF';
const boatClr = '#1C3B42';
const waterClr = '#3C6490';
const fishClr = '#618DB3';
const birdClr = '#AABAC5';

const illoElem = document.querySelector('canvas');
const illoSize = 600;
const minWindowSize = Math.min(window.innerWidth, window.innerHeight);
const zoomSize = (minWindowSize / illoSize);
const zoom = (zoomSize < 1) ? zoomSize : Math.floor(zoomSize);

illoElem.setAttribute('width', illoSize * zoom);
illoElem.setAttribute('height', illoSize * zoom);

const illo = new Zdog.Illustration({
  element: '.zdog-canvas',
  dragRotate: true,
	zoom: zoom
});

// Birds
const bird1 = new Zdog.Group({
	addTo: illo,
	translate: { x: -120, y: -150, z: 80 },
});

const wingLeft = new Zdog.Ellipse({
  addTo: bird1,
	width: 15,
	height: 20,
	rotate: { z: -Zdog.TAU / 6 },
	quarters : 2,
	translate: { x: -17, y: -6 },
	fill: true,
  color: fishClr,
});

const wingRight = new Zdog.Ellipse({
  addTo: bird1,
	width: 15,
	height: 20,
	rotate: { z: -Zdog.TAU / 3 },
	quarters : 2,
	translate: { x: -5, y: -6 },
	fill: true,
  color: fishClr,
});

const bird2 = bird1.copy({translate: { x: 0, y: -180, z: 80 }});
wingLeft.copy({ addTo: bird2 });
wingRight.copy({ addTo: bird2 });

// Sun
const sun = new Zdog.Shape({
  addTo: illo,
	stroke: 40,
  stroke: 100,
  translate: { x: 120, y: -140, z: 100 },
  fill: true,
  color: sunClr,
});

// Sea Group
const seaGroup = new Zdog.Group({
	  addTo: illo,
		translate: { y: 100, z: 200 },
});

// Sea
new Zdog.Ellipse({
  addTo: seaGroup,
	stroke: 60,
	diameter: 600,
	fill: true,
	quarters: 2,
	rotate: { z: Zdog.TAU/4 },
  color: waterClr,
});

// Waves
new Zdog.Shape({
  addTo: seaGroup,
	stroke: 40,
  path: [
    { x: -300, y: -10 },
    { bezier: [
      { x:  -280, y: -10 },
      { x:  -260, y:  10 },
      { x:  -240, y:  -10 }
    ]},
    { bezier: [
      { x:  -220, y: -10 },
      { x:  -200, y:  10 },
      { x:  -180, y:  -10 }
    ]},
		{ bezier: [
      { x:  -160, y: -10 },
      { x:  -140, y:  10 },
      { x:  -120, y:  -10 }
    ]},
		{ bezier: [
      { x:  -100, y: -10 },
      { x:  -80, y:  10 },
      { x:  -60, y:  -10 }
    ]},
		{ bezier: [
      { x:  -40, y: -10 },
      { x:  -20, y:  10 },
      { x:  0, y:  -10 }
    ]},
		{ bezier: [
      { x:  20, y: -10 },
      { x:  40, y:  10 },
      { x:  60, y:  -10 }
    ]},
		{ bezier: [
      { x:  80, y: -10 },
      { x:  100, y:  10 },
      { x:  120, y:  -10 }
    ]},
		{ bezier: [
      { x:  140, y: -10 },
      { x:  160, y:  10 },
      { x:  180, y:  -10 }
    ]},
		{ bezier: [
      { x:  200, y: -10 },
      { x:  220, y:  10 },
      { x:  240, y:  -10 }
    ]},
		{ bezier: [
      { x:  260, y: -10 },
      { x:  280, y:  10 },
      { x:  300, y:  -10 }
    ]},
  ],
  closed: false,
	color: waterClr,
});

// Fishes
const fish1 = new Zdog.Group({
	addTo: illo,
	translate: { x: 0, y: 150, z: 250 },
});

// Fish Tail
const fishTail = new Zdog.Shape({
  addTo: fish1,
  path: [
    { x:  0, y: 0 },
    { x:  0, y:  -12 },
    { x: 12, y:  -6 },
  ],
	fill: true,
  color: fishClr,
	stroke: 5,
});

// Fish Body
const fishBody = new Zdog.Ellipse({
  addTo: fish1,
	width: 20,
	height: 10,
	translate: { x: 17, y: -6 },
	fill: true,
	stroke: 5,
  color: fishClr,
});

const fish2 = fish1.copy({translate: { x: 70, y: 130, z: 250 }});
fishTail.copy({ addTo: fish2 });
fishBody.copy({ addTo: fish2 });

const fish3 = fish1.copy({translate: { x: 50, y: 180, z: 250 }});
fishTail.copy({ addTo: fish3 });
fishBody.copy({ addTo: fish3 });

const fish4 = fish1.copy({translate: { x: 130, y: 170, z: 250 }});
fishTail.copy({ addTo: fish4 });
fishBody.copy({ addTo: fish4 });

const fish5 = fish1.copy({translate: { x: 100, y: 215, z: 250 }});
fishTail.copy({ addTo: fish5 });
fishBody.copy({ addTo: fish5 });

const fish6 = fish1.copy({translate: { x: 20, y: 230, z: 250 }});
fishTail.copy({ addTo: fish6 });
fishBody.copy({ addTo: fish6 });

// Boat Group
const boatGroup = new Zdog.Group({
	addTo: illo,
	translate: { x: -100, y: 80, z: 180 },
});

//  Boat Base
new Zdog.Rect({
  addTo: boatGroup,
  width: 150,
  height: 8,
	fill: true,
	color: boatClr,
	stroke: 5,
});

// Boat Mast
new Zdog.Rect({
  addTo: boatGroup,
  width: 100,
  height: 2,
	fill: true,
	translate: { y: -50 },
	rotate: { z: Zdog.TAU/4 },
	color: boatClr,
	stroke: 5,	
});

// Boat Mairsall (right triangle)
new Zdog.Shape({
  addTo: boatGroup,
  path: [
    { x:  0, y: -120 },
    { x:  0, y:  -40 },
    { x: -60, y:  -40 },
  ],
	fill: true,
  color: boatClr,
	stroke: 5,
});

// Boat Jib (right triangle)
new Zdog.Shape({
  addTo: boatGroup,
  path: [
    { x:   0, y: -130 },
    { x:  0, y:  -30 },
    { x: 60, y:  -45 },
  ],
	fill: true,
  color: boatClr,
	stroke: 5,
});

let t = 0;
let deltaX = 1;
let deltaZ = 1;

function animate() {
    t += 1/600;
    const theta = Zdog.easeInOut( t % 1 ) * Zdog.TAU;
    const delta = Zdog.TAU * -3/154;
    illo.rotate.y = Math.sin( theta ) * delta;
    illo.rotate.x = ( -Math.cos( theta ) * -0.5 + 0.5 ) * delta;
	
	boatGroup.translate.x += deltaX;

	if (boatGroup.translate.x === 200 || boatGroup.translate.x === -200)
		deltaX *= -1;
	
	boatGroup.rotate.z += deltaZ * Zdog.TAU / 900;

	if (boatGroup.rotate.z > Zdog.TAU / 90 * 2 || boatGroup.rotate.z < -Zdog.TAU / 90 * 2)
		deltaZ *= -1;
	
  illo.updateRenderGraph();
  requestAnimationFrame( animate );
}

animate();
              
            
!
999px

Console