-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.html
97 lines (85 loc) · 2.31 KB
/
draw.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="styleSheet.css">
<title>Draw a Whiteboard</title>
<style>
/*canvas {
position: relative;
left: 125px;
height: 600px;
width: 800px;
}*/
.drawingFooter {
height:200px;
background-color:rgb(155,155,155);
margin-top:10px;
}
#canvas-holder {
position:relative;
width:800px;
height:400px;
border: 2px solid black;
margin: auto;
float: left;
}
</style>
</head>
<body>
<!-- THIS IS THE HEADER SECTION. !-->
<div class="header">
<img
class="logo"
src="pics/logo-img.png"
alt="Whiteboard online logo"
>
</div>
<!-- THIS IS THE NAVBAR SECTION. NO CONTAINER DIV !-->
<a href="index.html"><div class="navlink">HOME</div></a>
<a href="#"><div class="navlink">LESSONS</div></a>
<a href="draw.html"><div class="navlink current-page">DRAW</div></a>
<a href="about.html"><div class="navlink">ABOUT</div></a>
<a href="contact.html"><div class="navlink">CONTACT</div></a>
<div id="canvas-holder"></div>
<!-- THIS IS THE DRAWING CANVAS SECTIN !-->
<!-- THIS IS THE FOOTER SECTION !-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.14/p5.js"></script>
<script>
function displayButton(col, x, y) {
fill(col);
ellipseMode(CENTER);
ellipse(x, y, 40, 40);
if (dist(x, y, mouseX, mouseY) < 40/2 && mouseIsPressed) {
selectedColor = col;
}
}
// set up our canvas on the page
function setup() {
let canvas = createCanvas(800, 400);
canvas.parent('canvas-holder');
background(255, 255, 255);
}
// define our variables
let colors = ['red', 'green', 'blue', 'black', 'white'];
let selectedColor = 'red';
// define our draw function
function draw() {
// make grey side bar
fill(150,150,150);
rect(0,0, 50, 400);
// make mousePressed painting function
if (mouseIsPressed) {
noStroke();
fill(selectedColor);
ellipse(mouseX,mouseY,20,20);
}
// draw out the paint color selectors
for (var i = 0 ; i < colors.length ; i++){
var color = colors[i];
displayButton(color, 25, 100+i*50);
}
}
</script>
</body>
</html>