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>The Scale Transform</title>
		<style type="text/css">
			canvas {
				border: dotted 1px black;
				margin: 25px;
			}
		</style>
		<link rel="stylesheet" href="../style.css" />
		<script type="text/javascript">
			window.addEventListener("load", function () {
				var theCanvas = document.getElementById('Canvas1');
				if (theCanvas && theCanvas.getContext) {
					var ctx = theCanvas.getContext("2d");
					if (ctx) {
						ctx.fillStyle = "blue";
						ctx.fillRect(0, 0, 100, 50);

						// perform a scale transform and draw the same size rect
						ctx.save();
						ctx.scale(2, 2);
						ctx.fillRect(125, 50, 100, 50);
						ctx.restore();

						ctx.scale(.5, .5);
						ctx.fillRect(300, 0, 100, 50);
					}
				}
			});
		</script>
	</head>
	<body>
		<h1>The Scale Transform</h1>
		<div id='content'>
			<p>The scale transform causes drawing operations to be multiplied by the given scale multiples. Here, a rectangle is drawn,
				then a scale transform is applied, and the same rectangle is drawn again (but offset so the difference can be seen).
				Even though they are drawn with the same width and height, the scale transform causes the second rectangle to be drawn
				larger.
			</p>
			<canvas id="Canvas1" width="700" height="300">Your browser does not support canvas.</canvas>
		</div>
	</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console