-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartproject.html
More file actions
109 lines (109 loc) · 3.66 KB
/
Copy pathartproject.html
File metadata and controls
109 lines (109 loc) · 3.66 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<head>
<title>Art Final Project</title>
<style>
body {
font-family: "Trebuchet MS";
margin: 0;
}
div.header {
background-color: gray;
position: fixed;
top: 0;
width: 100%;
margin: 0 auto;
padding: 1px;
padding-left: 20px;
}
h2.header {
display: block;
float: left;
}
#reset {
float: right;
padding-right: 50px;
}
#mask {
float: right;
padding-right: 5px;
}
button {
margin-top: 20px;
line-height: 20px;
font-weight: bold;
padding: 5px 40px;
background: #fdfd96;
border-style: solid;
border-color: black;
font-family: "Trebuchet MS";
font-size: 16px;
transition: 0.35s ease-in;
}
button:hover {
background: white;
}
a.header {
transition: 0.3s ease-in;
text-decoration: none;
color: #fdfd96;
}
a.header:hover {
color: white;
}
div.fixedBar {
padding-top: 70px;
}
div.image {
margin-top: 70px;
}
canvas {
width: 100%;
}
</style>
</head>
<body>
<div class="header">
<h2 class="header"><a class="header" href="artproject.html">The Masking Project</a></h2>
<div id="reset"></div>
<div id="mask"></div>
</div>
<div class="image">
<canvas id="image">
Your browser does not support HTML5 canvas tag.
</canvas>
<script>
var canvas = document.getElementById("image");
var context = canvas.getContext('2d');
context.canvas.width = window.innerWidth;
context.canvas.height = window.innerHeight;
var maskingPic = new Image();
maskingPic.onload = function() {
context.drawImage(maskingPic, 0, 0, maskingPic.width, maskingPic.height,
0, 0, canvas.width, canvas.height);
}
maskingPic.src = "maskingpic.JPG";
var maskButton = document.createElement("button");
var resetButton = document.createElement("button");
maskButton.innerHTML = "Mask";
resetButton.innerHTML = "Reset";
var maskDiv = document.getElementById("mask");
var resetDiv = document.getElementById("reset");
maskDiv.appendChild(maskButton);
resetDiv.appendChild(resetButton);
maskButton.addEventListener("click", function() {
context.fillStyle = "#black";
context.beginPath();
context.moveTo(Math.random() * window.innerWidth, Math.random() * window.innerHeight);
context.lineTo(Math.random() * window.innerWidth, Math.random() * window.innerHeight);
context.lineTo(Math.random() * window.innerWidth, Math.random() * window.innerHeight);
context.fill();
});
resetButton.addEventListener("click", function() {
context.drawImage(maskingPic, 0, 0, maskingPic.width, maskingPic.height,
0, 0, canvas.width, canvas.height);
});
</script>
</div>
</body>
</html>