Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

	<title>Geometry Assignment page 498, problem #1</title>
	<meta charset="utf-8">
	<!-- Importing Libraries -->
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="">
	<script src=""></script>
	<script src=""></script>
	<script src=""></script>

	<div class="container"> <!-- Start Container -->
		<h1 class="header1">Nathan Lackie's Geometry Coding Assignment #1</h1>
		<div class="row"> <!-- Start Row -->
			<div class="col-lg-8"> <!-- Start left panel -->
				<img id="personClipart" width="40" height="110" src=""> <!-- Loads the person -->
				<img id="treeClipart" width="40" height="110" src=""> <!-- Loads the tree -->
				<canvas-area id="ca" cartesian="false" height="450"> <!-- creates the canvas -->
					<canvas id="c"></canvas>
				<div style="clear: left;"></div> <!-- Makes the numbers go in the right place -->
				<div class="magicNumbers">
					<span id="coords">./.</span> | <span id="size">./.</span> <!-- Makes the numbers -->
				<script src=""></script> <!-- Loads Grid Canvas -->
			</div> <!-- End left panel -->

			<div class="col-lg-4"> <!-- start right panel -->
				<!-- Creating nav pills to switch between tabs-->
				<ul class="nav nav-pills"> <!-- Makes the nav Pills -->
					<li class="nav-item">
						<a class="nav-link active" data-toggle="pill" href="#BaEx">Question
					<li class="nav-item">
						<a class="nav-link" data-toggle="pill" href="#TeEx">Explanation</a>
					<li class="nav-item">
						<a class="nav-link" data-toggle="pill" href="#Co">Code</a>

				<div class="tab-content"> <!-- Makes the content the nav pills open -->
					<div id="BaEx" class="container tab-pane active"><br>
						<div class="alert alert-info"><h5>Based on page 498, problem #1</h5><p>The triangles shown are similar triangles (Mirrored and Enlarged)</p><p>Find X</p></div>
						<input name="answer" id="answer" placeholder="Input your answer here" class="form-control">
						<button class="btn btn-md btn-info" onclick="checkAnswer()">Check Answer</button>
						<span id="answerresults"></span>
					<div id="TeEx" class="container tab-pane fade"><br>
						<div class="teacherSection" style="overflow:scroll; width: 100%">
							<p>This problem is based of of page 498, problem number 1, in our Student Text <sub>Volume 1</sub>. In this problem, you use similar triangles and ratios to determine the missing side (the height of the tree).</p> 
							<button data-toggle="collapse" data-target="#answer2Problem">Click for Solution!</button> <!-- Makes a colapsable solution -->
							<p id="answer2Problem" class="collapse">To find the solution, you must create a ratio between the small triangle and the large one. Since you know the triangles are similar, you can see that the 4ft side corresponds to the 12ft side. You can divide 12 by 4 and get 3 as a result. Then, you take 5 times 3, and get 16.5 as your final answer!</p>
					<div id="Co" class="container tab-pane fade"><br>
						<div class="momSection">
							<p data-height="340" data-theme-id="0" data-slug-hash="RxQdNN" data-default-tab="html,result" data-user="Naitron" data-embed-version="2" data-pen-title="RxQdNN" class="codepen">See the Pen <a href="">RxQdNN</a> by Nate (<a href="">@Naitron</a>) on <a href="">CodePen</a>.</p>
							<script async src=""></script>
			</div>	<!-- End right panel -->
		</div> <!-- End row -->
		<div class="clear"></div>
		<div class="row">
			<div class="col-lg-8">
				<div class="alert alert-warning">
					Click and drag on the graph window to move the veiwpoint around.<br>Scroll on the graph window to zoom in and out.
	</div> <!-- End container -->
              /*Setting the graph to not hug up against the edge*/
	.container {
		padding-left: 0px;
		padding-right: 0px;
		margin-left: 50px;
		margin-right: 0px;  
	/*Editing the MASTER_HOLDER the holder of EVERYTHING YOU SEEEEEEE*/
		margin-left: 50px
	/*Just a header...*/
	.header1 {
		margin: auto;
	/*The boy that holds the navpills*/
	.ultimateTablistCarrierBoy {
		width: 28vw;
		float: right;
		margin-right: 200px; 
	/*Canvas CSS*/
	#ca {
		width: 54vw;
		float: left;
	/*If u gots a 2 big screen, this makes the canvas not 2 big*/
	@media screen and (min-width: 1400px) {
		#ca {
			width: 700px;
	/*Makes the things go in the right spot*/
	.clear {
		clear: both;
		padding: 10px;
	/*Does absolutly nothing (In here to annoy you)*/
	.momSection {

	/*Styles the teacher section*/
	.teacherSection {
		border-style: solid;
		border-color: #c0c0c0;
		border-width: 2px;
		padding: 10px;
	/*Again, does nothing*/
	.resize1 {
		float: right;
	/*Creates the tutorial text that explains how to navigate the graph*/
	.tutorialText {
		font-size: 2.5vh;
		color: rgb( 255, 100, 100);
	/*Used to style the answer button, leaving it in just in case I need code for a hideous looking button*/
	.answerButton {
		display: block;
		margin: 0 auto;
		font-size: 2.5vh;
		color: rgb( 0, 100, 255);
		border-radius: 8px;
		border: 2px solid black;
		background-color: rgb(150, 150, 150);
		box-shadow: 0 8px #555;
		height: 7vh;
		width: 20vw;
		float: left;
	.answerButton:hover {
		background-color: rgb(100, 100, 100);
		color: rgb( 0, 0, 255);
		box-shadow: 0 8px #444;
	.answerButton:active {
		box-shadow: 0 3px #444;
		transform: translateY(5px);
	/*Oh boy... there's a whole lot of nothing*/
	.explanationText {
		font-size: 2.5vh;
		color: green;
	/*Styles it to where there's no random blue person at the top of the screen. (He was peeking at the guests creepily)*/
	#personClipart {
		display: none;
	/*Trees don't belong at the top of the screen!*/
	#treeClipart {
		display: none;
	#app {
		display: grid;
	/*styles the area around the canvas*/
	canvas-area {
		display: block;
		overflow: hidden;
		border:solid 1px black;
	/*Styles all h1's on the page*/
	h1 {
		padding-top: 20px;
		padding-bottom: 20px;
	.tab-content {
		margin-left: -48px;
		padding-right: 5px;
              let opacityBalue = 0 //Sets the opacity value for the grid, gets set to 1 if answer is correct
		let drawAnswer = 0 //Sets if the value of x is draw, again gets set to 1 if answer is correct
		const ctx = document.getElementById('c').getContext('2d'), //sets up values that will be pulled from later
		ca = document.getElementById('ca'),
		coords = document.getElementById('coords'),
		size = document.getElementById('size');

		window.onload = () => {
			ca.observe('pointer', e => {
				let {x,y} = ca.pntToUsr(e), 
				prec = Math.max(Math.log(ca.view.scl)/Math.log(2), 0);
				coords.innerHTML = `${(x).toFixed(prec)} / ${(y).toFixed(prec)}`;
			ca.observe('resize', e => {
				size.innerHTML = `size: ${e.width} / ${e.height}`;
				ca.resize({width,height}=ca);  // cause single initial notification ..
			}; //sets up the canvas when the window is loaded

			function draw(view) { //draws the actual stuff on the canvas
				let w = ctx.canvas.width, h = ctx.canvas.height, 
				sz = 20*view.scl, xoff = view.x%sz, yoff = view.y%sz;


				// draw Grid
				if (view.scl > 0.2) {
					ctx.strokeStyle = 'rgba(204, 204, 204, ' + opacityBalue +')';
					ctx.lineWidth = 1;
					for (let x=xoff,nx=w+1; x<nx; x+=sz) { ctx.moveTo(x,0); ctx.lineTo(x,h); }
						for (let y=yoff,ny=h+1; y<ny; y+=sz) { ctx.moveTo(0,y); ctx.lineTo(w,y); }

				// draw Triangles;
				ctx.strokeStyle = "#000000";
				ctx.fillStyle = "rgba(0, 0, 0, 0.2)";
				ctx.moveTo(140, 400);
				ctx.lineTo(140, 290);
				ctx.lineTo(220, 400);
				ctx.lineTo(140, 400);
				ctx.moveTo(220, 400);
				ctx.lineTo(460, 400);
				ctx.lineTo(460, 70);
				ctx.lineTo(220, 400);

				// draw person and tree
				let personC = document.getElementById("personClipart");
				ctx.drawImage(personC, 90, 290, 40, 110);
				let treeC = document.getElementById("treeClipart");
				ctx.drawImage(treeC, 460, 60, 310, 340);

				//draw numbers
				ctx.font = "20px Arial";
				ctx.fillStyle = "black";
				ctx.fillText("4 ft",160,420);
				ctx.fillText("5.5 ft",40,360);
				ctx.fillText("12 ft",320,420);

				if (drawAnswer == 1) {

			function checkAnswer() { //checks if the answer is correct, if it is, then opacityBalue and drawAnswer to 1 
				let problemAnswer = document.getElementById('answer').value;
				let trimAnswer = problemAnswer.replace(/ /g,'');
				if (trimAnswer == 'x=16.5' || trimAnswer == '16.5' || trimAnswer == '16.5ft' || trimAnswer == 'x=16.5ft') {
					document.getElementById("answerresults").innerHTML = "<span class='alert alert-success'>Yay! Correct</span>";
					opacityBalue = 1;
					drawAnswer = 1
				} else {
					document.getElementById("answerresults").innerHTML = "<span class='alert alert-danger'>Oops! Try Again!</div>";

			function goDrawAnswer() { //draws the answer on the canvas
				ctx.font = "20px Arial";
				ctx.fillStyle = "black";
				ctx.fillText('= 16.5',490,300);

			function render() { //renders the canvas
			//creates hilarous jokes in a parallel universe
			function jokeMaker () {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.