html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!--
This is based on the Wikipedia gif of Pascal's Triangle
-->
<!DOCTYPE html>
<html>
<head>
<title> Pascal's Triangle </title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
</head>
<body>
<div id="container">
<div id="intro">
Pascal's Triangle Visualization
</div>
<p id="please"> Enter your number:<span style="font-size:9px;">(min:2 max:7)</span>
</p>
<input type="number" id="input" min="2" max="7" value="4"/>
<button id="butt" > Create </button>
<div id="output">
<canvas id="canv"> </canvas>
</div>
</div>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
body{
font-family: sans-serif;
}
#intro {
border: 1px solid lightgray;
border-radius:5px;
font-weight:bold;
color: #16646D;
background-color: #5CD6F9;
text-align:center;
margin:10px;
}
#container {
border:1px solid lightgray;
border-radius:5px;
background-color: #B6EAF8;
}
p {
border:1px solid lightgray;
border-radius:5px;
text-indent:6px;
font-weight:bold;
color: #1A7781;
margin:5px;
text-align:center;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$(document).ready(function(){
$("#butt").on("click",function(){
$("#output").html("");
var canv = $("<canvas id='canv'> </canvas>");
$("#output").append(canv);
canv = $("#canv")[0];
var col2 = "#1a766c";
var c = canv.getContext("2d");
var x = 150, y = 50, s = 20;
var l = parseInt($("#input").val());
var arr = [], arr2 = [], nums = tri(l);
var once = true, plus = false;
var fs = 15
var t1 = 0, t2 = 0;
arr.length = l+1;
arr2.length = l+1;
var off1 = 0, off2 = 0, off3 = 0;
var za = 1, zb = 0, zc = 1, zd = 2;
var W = 40*l+100;
var H = 40*l+100;
canv.width = W;
canv.height = H;
var requestAnimationFrame = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame;
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run