Skip to content

Commit 2161d08

Browse files
authored
Add files via upload
0 parents  commit 2161d08

File tree

3 files changed

+173
-0
lines changed

3 files changed

+173
-0
lines changed

index.html

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
9+
</head>
10+
<body>
11+
<link rel="stylesheet" href="style.css">
12+
<h3>triangle drawer & its properties</h3>
13+
<canvas id="mycanvas" width="900" height="580" style="border:1px solid black; display: block;"></canvas>
14+
<div id="box">
15+
16+
<div>Enter side1</div>
17+
<input type="text" id="a">
18+
19+
<div> Enter side2</div>
20+
<input type="text" id="b">
21+
22+
<div>Enter side3</div>
23+
<input type="text" id="c"><br>
24+
25+
<br><button onclick="fun1()">check</button><br>
26+
<div> angle A</div>
27+
<div id="angles1" class="ang"></div>
28+
<div> angle B </div>
29+
<div id="angles2" class="ang"></div>
30+
<div> angle C</div>
31+
<div id="angles3" class="ang"></div>
32+
<div>sum of angles A + B + C</div>
33+
<div id="angles4" class="ang"></div>
34+
<div>value of s</div>
35+
<div id="angles5" class="ang"></div>
36+
<div>area</div>
37+
<div id="angles6" class="ang"></div>
38+
39+
</div>
40+
41+
42+
<script src="script.js"></script>
43+
</body>
44+
</html>

script.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
function fun1(){
3+
let a = parseInt(document.getElementById('a').value);
4+
let b = parseInt(document.getElementById('b').value);
5+
let c = parseInt(document.getElementById('c').value);
6+
let s = (a+b+c)/2;
7+
let w1 = a*20;
8+
let w2 = b*20;
9+
let w3 = c*20;
10+
let rough1 = ((c*c+a*a-b*b)/(2*c*a));
11+
let rough2 =((c*c+b*b-a*a)/(2*b*c));
12+
let rough3 = ((a*a+b*b-c*c)/(2*a*b));
13+
const pi = Math.PI;
14+
let B = Math.acos( rough1 );
15+
let A = Math.acos( rough2);
16+
let C = Math.acos( rough3);
17+
let area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
18+
let ans1=(A*180/pi);
19+
let ans2=(B*180/pi);
20+
let ans3 = (C*180/pi);
21+
let g = Math.sin(C);
22+
let h = g*w2;
23+
let g2 = Math.cos(C);
24+
let h2 = g2*w2;
25+
26+
27+
28+
document.getElementById("angles1").innerHTML = ans1;
29+
document.getElementById("angles2").innerHTML = ans2;
30+
document.getElementById("angles3").innerHTML = ans3;
31+
document.getElementById("angles4").innerHTML = ans1+ans2+ans3;
32+
document.getElementById("angles5").innerHTML = s;
33+
document.getElementById("angles6").innerHTML = area;
34+
35+
var d = document.getElementById("mycanvas");
36+
var ctx = d.getContext("2d");
37+
38+
39+
40+
ctx.beginPath();
41+
ctx.moveTo(200,550);
42+
ctx.lineTo(200+w1,550);
43+
ctx.lineTo(200+w1-h2,550-h);
44+
ctx.lineTo(200,550);
45+
ctx.closePath();
46+
47+
48+
49+
ctx.lineWidth = 3;
50+
ctx.strokeStyle = "#666666"
51+
ctx.stroke();
52+
53+
ctx.fillStyle = "#FFCC00";
54+
ctx.fill();
55+
56+
57+
// ctx.font = "100px 'Courier New', Courier, monospace";
58+
// ctx.filltext("A",200+w1-h2,550-h);
59+
// ctx.filltext("B",200,550);
60+
// ctx.filltext("B",200+w1,550);
61+
}

style.css

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
body{
3+
background-color: rgb(215, 226, 255);
4+
}
5+
input{
6+
outline:none;
7+
width: 190px;
8+
height: 14px;
9+
margin: 10px;
10+
11+
12+
}
13+
#box{
14+
position: absolute;
15+
top: 50px;
16+
left: 1000px;
17+
background-color: transparent;
18+
}
19+
#side1{
20+
width: 100px;
21+
background-color: rgb(0, 0, 0);
22+
height: 3px;
23+
transform: rotateZ(0);
24+
transform-origin: top right;
25+
border-radius: 40%;
26+
}
27+
28+
#side2{
29+
width: 100px;
30+
background-color: rgb(26, 54, 145);
31+
height: 3px;
32+
transform: rotateZ(0);
33+
border-radius: 40%;
34+
35+
}
36+
#side3{
37+
width: 100px;
38+
background-color: rgb(128, 0, 0);
39+
height: 3px;
40+
transform: rotateZ(0);
41+
transform-origin: top left;
42+
border-radius: 40%;
43+
44+
}
45+
#triangle{
46+
display: flex;
47+
margin-top: 200px;
48+
}
49+
.ang{
50+
margin-bottom: 5px;
51+
}
52+
div{
53+
background-color: rgb(22, 178, 206);
54+
color: rgb(0, 34, 0);
55+
width: 200px;
56+
height: 20px;
57+
padding: 2px 10px;
58+
59+
}
60+
button{
61+
margin: 10px;
62+
padding: 10px 20px;
63+
border: none;
64+
background-color: rgb(29, 59, 94);
65+
color: white;
66+
border-radius: 5px;
67+
68+
}

0 commit comments

Comments
 (0)