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

              
                <!DOCTYPE html>
<html>
	<head>
		<title>Drawing Shadows</title>
		<style type="text/css">
			#Canvas1 {
				border: dotted 1px black;
			}
		</style>
		<link rel="stylesheet" href="../style.css" />
		<script>
			window.addEventListener("load", function () {
				var theCanvas = document.getElementById('Canvas1');
				if (theCanvas && theCanvas.getContext) {
					var ctx = theCanvas.getContext("2d");
					if (ctx) {
						// set up our basic shadow settings
						ctx.shadowColor = "#000000";
						ctx.shadowOffsetX = 10;
						ctx.shadowOffsetY = 10;
						ctx.shadowBlur = 10;

						// draw a simple rectangle with a shadow effect
						ctx.fillStyle = "rgba(0,0,255,1)";
						ctx.fillRect(20, 20, 200, 100);

						var theString = "Drawing Text on a Canvas";
						// draw the string with some font information
						// change the shadow settings to be a bit lighter
						ctx.fillStyle = "green";
						ctx.shadowColor = "rgba(0,100,100,0.5)";
						ctx.shadowOffsetX = 5;
						ctx.shadowOffsetY = 5;
						ctx.shadowBlur = 5;
						ctx.font = "25pt Georgia";
						ctx.fillText(theString, 250, 75);

						// draw a red line with a purplish shadow
						ctx.lineCap = "round";
						ctx.lineWidth = 25;
						ctx.shadowColor = "rgba(150,0,150,0.75)";
						ctx.shadowBlur = 15;
						ctx.strokeStyle = "red";
						ctx.beginPath();
						ctx.moveTo(50, 200);
						ctx.lineTo(450, 200);
						ctx.stroke();
					}
				}
			});
		</script>
	</head>
	<body>
		<h1>Drawing Shadows</h1>
		<div id="content">
			<p>All drawing operations can produce shadows. This example shows how to make shadows on a variety of canvas operations.</p>
			<canvas id="Canvas1" width="700" height="300">Your browser does not support canvas.</canvas>
		</div>
	</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console