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

              
                <div class="contents">
	<h2>Holy Buckets</h2>
	<div class="note">SVG Drawing based on the sketch by Shirley Wu and Jason Lengstorf for <a href="https://www.youtube.com/watch?v=S3TS6IGSUS4" target="_blank">Generative Data Visualization in D3.js</a> (Learn with Jason)</div>
	<div class="note">[simple svg]</div>
	<svg width="300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 260">
		<ellipse class="bucket-fill-inside" cx="144.26" cy="102.69" rx="66.73" ry="17.57"/>
		<path class="bucket-lines" d="M77.53,102.69c0-9.71,29.88-17.58,66.73-17.58S211,93,211,102.69"/>
		<path class="bucket-contents" d="M97.46,113.66a140.59,140.59,0,0,0,18.44,3.43l.12,0,2.71.31.23,0,2.72.28,1.06.09,1.62.14,1.39.11,1.37.1,1.47.1,1.46.09,2.15.11,1.86.08,1.29,0,1.72.06,1.22,0,1.94,0h1l3,0,3,0,1.28,0,1.61,0,1.71,0,1,0,2.16-.08h.08a206.85,206.85,0,0,0,24.24-2.41l.41-.07,1.7-.29c3.42-.61,6.65-1.31,9.64-2.1,1.11-.29,2.16-.6,3.19-.91-5.47-6.61-19.8-7.85-28.95-8.12-12.76-.37-8.63,2.63-21.05,3s-16.49-1.45-30.75,0c-8.56.87-14.05,3.68-17.09,5.79Z"/>
		<path id="bucket-fill-front" class="bucket-fill-front" d="M144.26,120.26c-29.27,0-54.12-5-63.12-11.87h0L98.94,219.13S124.32,233,147.82,233c34,0,51.28-17.26,51.28-17.26l9.26-108.17h0C200.28,114.91,174.65,120.26,144.26,120.26Z"/>
		<path class="bucket-handle" d="M103.54,138.05s-5.55,51.81,64.2,51.43c69.07-.38,38.4-49.55,38.4-49.55"/>
		<path class="moustache" d="M186.81,168.12a22.54,22.54,0,0,1-7.14-2.07c-3.37-1.87-1.71-5.61-5.32-6.57s-3.09,2.33-6.66,2.49-3.05-3.17-7.14-2.14-2.78,3.58-4.23,6.11c-1.83,3.19-9.38,4-9.38,4s9.44,3.38,13,1.25,4.27-5.37,7.93-5.29c3.65-.41,4.64,2.74,8.39,4.54S186.81,168.12,186.81,168.12Z"/>
		<circle class="eye eyeR" cx="178.45" cy="146.12" r="6.01"/>
		<circle class="eye eyel" cx="152.18" cy="148.69" r="6.01"/>
		<path class="bucket-lines" d="M144.26,120.26c-29.27,0-54.12-5-63.12-11.87h0L98.94,219.13S124.32,233,147.82,233c34,0,51.28-17.26,51.28-17.26l9.26-108.17h0C200.28,114.91,174.65,120.26,144.26,120.26Z"/>
		<path class="bucket-lines" d="M211,102.69c0,9.7-29.87,17.57-66.73,17.57s-66.73-7.87-66.73-17.57"/>
		<path class="wing wingR" d="M227.72,122.59c9.21-7,16.41-13.13,59.23-14.6,0,0-2,17.37-14.77,15.25,0,0,8.49,24.76-22.64,14.5,0,0,9.53,23.41-17.35,16.76C219.52,151.37,218.52,129.57,227.72,122.59Z"/>
		<path class="wing wingL" d="M70.76,133.36c-11.11-8.14-16.94-9.73-56.64-11.09,0,0,1.88,16.11,13.69,14.14,0,0-7.87,23,21,13.45,0,0-8.84,21.71,16.09,15.54C76.65,162.5,81.87,141.51,70.76,133.36Z"/>
		<path class="star" d="M212.63,30.08s0,19.25,19.46,19.25c0,0-19.46-.46-19.46,17.69,0,0,0-18.15-18.12-18.15C194.51,48.87,212.63,48.55,212.63,30.08Z"/>
		<path class="star" d="M236.85,58.09s0,19.25,19.46,19.25c0,0-19.46-.46-19.46,17.68,0,0,0-18.14-18.13-18.14C218.72,76.88,236.85,76.56,236.85,58.09Z"/>
		<path class="star" d="M251.42,20.21S251.42,35,266.35,35c0,0-14.93-.35-14.93,13.57,0,0,0-13.92-13.91-13.92C237.51,34.63,251.42,34.38,251.42,20.21Z"/>
		<path class="halo" d="M94.33,34c-26.88,6.12-46.6,20.16-44,31.36s26.4,15.31,53.28,9.19,46.59-20.16,44-31.35S121.2,27.92,94.33,34ZM96,65.69c-19.11,3.94-35.73,1.65-37.13-5.11s13-15.43,32.09-19.37,35.73-1.65,37.12,5.11S115.07,61.75,96,65.69Z"/>
	</svg>

	<div class="note">[d3.js generated svg with css animation]</div>
	<div id="hb"></div>

</div>
              
            
!

CSS

              
                /* Basic Page Layout Styles  */
	.contents {
		padding-top: 2rem;
		text-align: center;
    font-family: Helvetica, sans-serif;
	}
  h2 {
    color: #777;
  }
	.note {
		color: #999;
    line-height: 1.4;
		margin-top: 1rem;
		margin-bottom: 1rem;
		padding-left: 3rem;
		padding-right: 3rem;
	}

	/* Holy Bucket SVG Styles >> Apply to Both Examples */
	.bucket-fill-inside {
	  fill: #e2e2e2;
	}
	.bucket-lines, .bucket-handle {
	  fill: none;
	  stroke: #231f20;
	  stroke-linecap: round;
	  stroke-width: 3px;
	}
	.bucket-contents {
	  fill: #d6a9b2;
	}
	.bucket-fill-front {
	  fill: #f2f0f1;
	}
	.eye, .moustache {
	  fill: #231f20;
	}
	.wing {
	  fill: #b2dfd6;
	}
	.star {
	  fill: #eacf5d;
	}
	.halo {
	  fill: #f2dd83;
	}

	/* Holy Bucket Animation Styles >> For D3 version  */
	.wingRight {
		transform-origin: 20px 30px;
		animation: wingAnimateR 2s ease infinite;
	}
	.wingLeft {
		transform-origin: 50px 30px;
		animation: wingAnimateL 2s ease infinite;
	}
	@keyframes wingAnimateR {
		0%   {transform: rotate(15deg)}
		50%  {transform: rotate(-15deg )}
		100% {transform: rotate(15deg)}
	}
	
	@keyframes wingAnimateL {
		0%   {transform: rotate(-15deg)}
		50%  {transform: rotate(15deg )}
		100% {transform: rotate(-15deg)}
	}

	.star1 {
		transform-origin: 18px 18px;
		animation: animateStar 1.5s ease infinite;
	}
	.star2 {
		transform-origin: 18px 18px;
		animation: animateStar 2.0s ease infinite;
	}
	.star3 {
		transform-origin: 18px 18px;
		animation: animateStar 2.5s ease infinite;
	}
	@keyframes animateStar {
		0%   {transform: scale(0.8)}
		50%  {transform: scale(1.1)}
		100% {transform: scale(0.8)}
	}

	.holy-bucket {
		transform-origin: center;
		animation: animateGroup 2s ease infinite;
	}
	@keyframes animateGroup {
		0%   {transform: rotate(-3deg);}
		50%  {transform: rotate(3deg);}
		100% {transform: rotate(-3deg);}
	}
              
            
!

JS

              
                // Bucket Path Collection. All the bkt items are drawing with reference to the group, other elements are drawn from their own top left
	let hbPaths = {
		bktLinesRimBack: "M1.5,19.07C1.5,9.37,31.38,1.5,68.23,1.5s66.73,7.87,66.73,17.57",
		bktContents: "M21.43,30.05c5.44,1.43,11.68,2.59,18.44,3.43c0.04,0.01,0.08,0.01,0.12,0.02c0.9,0.11,1.8,0.22,2.72,0.32c0.07,0.01,0.15,0.02,0.22,0.02c0.9,0.1,1.81,0.19,2.73,0.28c0.35,0.03,0.71,0.06,1.06,0.1c0.54,0.05,1.08,0.1,1.62,0.14c0.46,0.04,0.92,0.07,1.39,0.11c0.45,0.03,0.91,0.07,1.37,0.1c0.49,0.03,0.97,0.07,1.47,0.1c0.49,0.03,0.98,0.06,1.47,0.09c0.71,0.04,1.43,0.08,2.15,0.11c0.62,0.03,1.24,0.06,1.86,0.08c0.43,0.02,0.86,0.03,1.29,0.05c0.57,0.02,1.14,0.04,1.72,0.06c0.41,0.01,0.82,0.02,1.23,0.03c0.64,0.02,1.29,0.03,1.94,0.04c0.34,0.01,0.69,0.01,1.03,0.02c1,0.01,1.99,0.02,3,0.02c1,0,2-0.01,3-0.02c0.43-0.01,0.85-0.01,1.28-0.02c0.54-0.01,1.07-0.02,1.61-0.03c0.57-0.01,1.15-0.03,1.72-0.05c0.33-0.01,0.65-0.02,0.98-0.03c0.72-0.02,1.44-0.05,2.15-0.08c0.03,0,0.05,0,0.08,0c8.71-0.38,16.94-1.21,24.24-2.4c0.14-0.02,0.27-0.05,0.41-0.07c0.57-0.1,1.14-0.19,1.7-0.29c3.42-0.61,6.65-1.31,9.64-2.1c1.11-0.29,2.17-0.6,3.19-0.91c-5.47-6.61-19.8-7.85-28.94-8.12c-12.76-0.38-8.63,2.63-21.05,2.96s-16.49-1.45-30.75,0c-8.56,0.87-14.05,3.68-17.08,5.79C20.74,29.86,21.07,29.96,21.43,30.05z",
		bktFillFront: "M68.23,36.65c-29.27,0-54.12-4.96-63.12-11.87l-0.02,0l17.82,110.74c0,0,25.38,13.89,48.88,13.89c34.01,0,51.28-17.27,51.28-17.27l9.26-108.17l-0.02,0C124.25,31.29,98.62,36.65,68.23,36.65z",
		bktHandle: "M27.51,54.43c0,0-5.55,51.81,64.2,51.43c69.08-0.38,38.41-49.55,38.41-49.55",
		bktMoustache: "M110.78,84.5c0,0-4.26-0.47-7.13-2.06c-3.38-1.88-1.71-5.61-5.33-6.57c-3.61-0.96-3.09,2.32-6.65,2.49s-3.06-3.17-7.14-2.14s-2.78,3.58-4.23,6.11c-1.83,3.19-9.38,4-9.38,4s9.43,3.38,13,1.25c3.57-2.13,4.26-5.36,7.93-5.29c3.65-0.41,4.64,2.74,8.38,4.54C103.97,88.63,110.78,84.5,110.78,84.5z",
		bktLinesFront: "M68.23,36.65c-29.27,0-54.12-4.96-63.12-11.87l-0.02,0l17.82,110.74c0,0,25.38,13.89,48.88,13.89c34.01,0,51.28-17.27,51.28-17.27l9.26-108.17l-0.02,0C124.25,31.29,98.62,36.65,68.23,36.65",
		bktLinesRimFront: "M134.97,19.07c0,9.71-29.88,17.57-66.73,17.57S1.5,28.78,1.5,19.07",
		wingR: "M6.1,14.6C15.31,7.62,22.51,1.47,65.33,0c0,0-2.03,17.37-14.77,15.25c0,0,8.49,24.76-22.64,14.5c0,0,9.53,23.4-17.36,16.76C-2.11,43.38-3.11,21.58,6.1,14.6zM227.72,122.59c9.21-7,16.41-13.13,59.23-14.6,0,0-2,17.37-14.77,15.25,0,0,8.49,24.76-22.64,14.5,0,0,9.53,23.41-17.35,16.76C219.52,151.37,218.52,129.57,227.72,122.59Z",
		wingL: "M56.64,11.09C45.54,2.95,39.71,1.36,0,0c0,0,1.88,16.11,13.69,14.14c0,0-7.87,22.96,21,13.45c0,0-8.84,21.7,16.1,15.54C62.54,40.23,67.75,19.24,56.64,11.09z",
		star1: "M18.13,0c0,0,0,19.25,19.46,19.25c0,0-19.46-0.46-19.46,17.69c0,0,0-18.15-18.13-18.15C0,18.79,18.13,18.47,18.13,0z",
		star2: "M18.13,0c0,0,0,19.25,19.46,19.25c0,0-19.46-0.46-19.46,17.69c0,0,0-18.15-18.13-18.15C0,18.79,18.13,18.47,18.13,0z",
		star3: "M13.91,0c0,0,0,14.77,14.93,14.77c0,0-14.93-0.35-14.93,13.57c0,0,0-13.92-13.91-13.92C0,14.42,13.91,14.17,13.91,0z",
		halo: "M44.27,2.83C17.39,8.95-2.33,22.99,0.22,34.19s26.4,15.32,53.28,9.2c26.87-6.12,46.59-20.16,44.04-31.35C94.99,0.83,71.14-3.28,44.27,2.83z M45.9,34.48c-19.11,3.94-35.74,1.65-37.13-5.11S21.75,13.94,40.86,10c19.11-3.94,35.74-1.65,37.13,5.11C79.38,21.87,65.02,30.54,45.9,34.48z"
	}

	// Generate SVG Container 
	let svg = d3.select("#hb").append("svg")
		.attr("width", 300) // Sets width of whole svg and will scale everything inside
		.attr("viewBox", "0 0 300 260"); // Needs to stay the same to scale elements properly

	// Group for all elements
	let group = svg
    .append("g") // outer group that css animation can be applied to
		.attr("class", "holy-bucket")
		.append("g") // inner groupd to center elements
		.attr("transform", "translate(150 130)"); // half of viewport width and height

	// Bucket
	let bucket = group.append("g")
		.attr("class", "bucket")
		.attr("transform", "translate(-75 -40)");

	bucket.append('ellipse')
		.attr('class', 'bucket-fill-inside')
		.attr("cx", 68.23)
		.attr("cy", 19.07)
		.attr("rx", 66.73) 
		.attr("ry", 17.57);

	bucket.append('path')
		.attr('class', 'bucket-lines')
		.attr("d", hbPaths.bktLinesRimBack);

	bucket.append('path')
		.attr('class', 'bucket-fill-front')
		.attr("d", hbPaths.bktFillFront);

	bucket.append('path')
		.attr('class', 'bucket-contents')
		.attr("d", hbPaths.bktContents);
	
	bucket.append('path')
		.attr('class', 'bucket-handle')
		.attr("d", hbPaths.bktHandle);

	bucket.append('path')
		.attr('class', 'bucket-lines')
		.attr("d", hbPaths.bktLinesFront);

	bucket.append('path')
		.attr('class', 'bucket-lines')
		.attr("d", hbPaths.bktLinesRimFront);

	bucket.append('circle')
		.attr("class", "eye eyeRight")
		.attr("cx","102")
		.attr("cy", "62")
		.attr("r", "6.00");

	bucket.append('circle')
		.attr("class", "eye eyeLeft")
		.attr("cx","76")
		.attr("cy", "65")
		.attr("r", "6.00");

	bucket.append('path')
		.attr('class', 'bucket-moustache')
		.attr("d", hbPaths.bktMoustache);

	// Halo
	group.append("g")
		.attr("transform", "translate(-100 -100)") // Set initial position
		.append('path')
		.attr('class', 'halo')
		.attr("d", hbPaths.halo)

	// Stars
	group.append("g")
		.attr("transform", "translate(40 -90)") // Set initial position
		.append('path')
		.attr('class', 'star star1')
		.attr("d", hbPaths.star1)

	group.append("g")
		.attr("transform", "translate(65 -65)") // Set initial position
		.append('path')
		.attr('class', 'star star2')
		.attr("d", hbPaths.star2)

	group.append("g")
		.attr("transform", "translate(80 -100)") // Set initial position
		.append('path')
		.attr('class', 'star star3')
		.attr("d", hbPaths.star3)

	// Wings
	group.append("g") // Apply transform to outer group so inner path can animate
		.attr("transform", function () {
			let scale = 1.0; // use to set wing scale > This function needs refinement
			 return `translate(${10+(scale*60)} -10) scale(${scale})`;
		})
		.append('path')
		.attr('class', 'wing wingRight')
		.attr("d", hbPaths.wingR)
	
	group.append("g")
		.attr("transform", function () {
			let scale = 1.0; // use to set wing scale > This function needs refinement 
			 return `translate(${-80-(scale*60)} 0) scale(${scale})`;
		})
		.append('path')
		.attr('class', 'wing wingLeft')
		.attr("d", hbPaths.wingL);
		
              
            
!
999px

Console