Skip to content

Commit 271b2bf

Browse files
committed
README.md updated
1 parent 983ff61 commit 271b2bf

File tree

2 files changed

+39
-124
lines changed

2 files changed

+39
-124
lines changed

README.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ If you want to know more about the course visit [this website](https://drawwithc
1919
* [Federico Pozzi](https://federicopozzi.github.io/portfolio/index.html)
2020

2121
### Table of Contents
22+
0. [How to run](#how-to-run)
2223
1. [Concept](#concept)
2324
* Project idea
2425
* Communication aim
@@ -36,6 +37,13 @@ If you want to know more about the course visit [this website](https://drawwithc
3637
* ES6 features
3738
4. [Credits](#credits)
3839

40+
## How to run
41+
42+
Be sure to have [node and npm](https://nodejs.org/) installed.
43+
44+
* Install node dependencies: `npm install`
45+
* Run local server: `node server.js`
46+
3947
## Concept
4048

4149
### Project idea
@@ -116,7 +124,8 @@ class Player {
116124
}
117125
```
118126

119-
We gave shape to the landmarks by connecting them with a stroke.
127+
We gave shape to the landmarks by connecting them with a stroke.
128+
We used the same function to avoid code repetitions.
120129

121130
```js
122131
const col = palette[this.feeling];
@@ -145,8 +154,8 @@ function onPlayerLeft(id) {
145154
}
146155
```
147156

148-
Detect performs facial recognition.
149-
157+
Face detection is triggered through `detectFace()` function. It runs recursively, with a little
158+
delay in some cases to avoid client overload.
150159
```js
151160
async function detectFace() {
152161
if (!me) {
@@ -159,13 +168,16 @@ async function detectFace() {
159168

160169
detection = await faceapi.detectSingleFace(video.elt,
161170
detectionOptions).withFaceLandmarks().withFaceExpressions();
171+
}
162172
```
163173

164174
If face-api.js finds a face but has a degree of certainty lower than the threshold value, detection starts again.
175+
When the detection runs correctly, the result is assigned to detection (which actually is a `setter` function) of `me`.
176+
After that, other players connected are updated through socket.
165177

166178
```js
167-
if (detection) {
168-
const threshold = .8;
179+
if (detection) {
180+
const threshold = .9;
169181

170182
const score = detection.detection._score;
171183

@@ -177,7 +189,7 @@ If face-api.js finds a face but has a degree of certainty lower than the thresho
177189
me.detection = detection;
178190

179191
me.broadcast();
180-
192+
}
181193
```
182194

183195
Initially, face-api recognised many expressions as neutral. We therefore tried to **decrease the neutrals**, favouring
@@ -196,9 +208,9 @@ for (const feeling of feelings) {
196208

197209
#### Position of the avatar
198210

199-
The position of the avatar is calculated by the browser of each user, making the site faster. The position is calculated
200-
on the basis of gravity points
201-
that [apply forces to points](https://www.youtube.com/watch?v=MkXoQVWRDJs&ab_channel=TheCodingTrain) with the same
211+
The position of the avatar is calculated by the browser of each user, making the site faster and avoiding lagging.
212+
The position is calculated on the basis of gravity points
213+
that [apply forces to players](https://www.youtube.com/watch?v=MkXoQVWRDJs&ab_channel=TheCodingTrain) with the same
202214
feeling.
203215

204216
This class generates the **centres of gravity** of the emotions.
@@ -245,13 +257,14 @@ class GravityPoint {
245257
text(this.feeling.toUpperCase(), this.pos.x, this.pos.y + 20);
246258
pop();
247259
}
260+
}
248261
```
249262

250-
Set the position of the **centre of gravity**.
263+
The position of the **centre of gravity** are created in this class method, which is also run
264+
by `windowResized()`.
251265

252266
```js
253-
setPosition()
254-
{
267+
setPosition() {
255268
let hUnit = height / 8;
256269

257270
switch (this.feeling) {
@@ -330,8 +343,7 @@ class Room {
330343

331344
### Background
332345

333-
For the background, we decided very early in development that we wanted to design a **responsive generative artwork**
334-
.The artwork needed to further the connection between the users and their algorithmic representation. In order to
346+
For the background, we decided very early in development that we wanted to design a **responsive generative artwork**. The artwork needed to further the connection between the users and their algorithmic representation. In order to
335347
achieve this result, we decided that we needed to show the **sum of the emotions** of every person in the room at any
336348
given time.
337349

@@ -427,7 +439,7 @@ setInterval(function() {
427439
In the p5 `draw()` function, the interpolated values are set to the shader with the `setUniform()` function.
428440

429441
```js
430-
const {prev, next, lastTimestamp, interval} = summedFeelings;
442+
const {prev, next, lastTimestamp, interval} = summedFeelings;
431443
if (prev && next) {
432444
bg.shader(bgShader);
433445
const now = Date.now();
@@ -439,14 +451,13 @@ if (prev && next) {
439451
bg.quad(-1, -1, 1, -1, 1, 1, -1, 1);
440452
bgShader.setUniform('time', millis() / 1000.0);
441453
}
442-
}
443454
```
444455

445456
The user also has the option of **saving** the background.
446457

447458
```html
448-
449-
<button class="menu btn btn-text p-0 cool-underlined" onclick="bg.saveCanvas('MOODboard', 'png')">Save</button>
459+
<button class="menu btn btn-text p-0 cool-underlined"
460+
onclick="bg.saveCanvas('MOODboard', 'png')">Save</button>
450461
```
451462

452463
## Miscellaneus
@@ -577,7 +588,7 @@ function onPlayerUpdated(id, feelings, landmarks, dimensions) {
577588
#### For...of
578589

579590
[For...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) was used to improve
580-
the readability and to iterate `Map` objects.
591+
the readability and to iterate `Map` and other iterables objects.
581592

582593
```js
583594
for (const feeling of feelings) {
@@ -587,12 +598,13 @@ for (const feeling of feelings) {
587598

588599
## Credits
589600

590-
Font: [Karrik](https://velvetyne.fr/fonts/karrik/)
591-
Libraries: P5js
592-
593-
## How to run
601+
Font: [Karrik](https://velvetyne.fr/fonts/karrik/).
594602

595-
Be sure to have node installed: https://nodejs.org/
603+
Libraries and frameworks:
596604

597-
* install node dependencies: `npm install`
598-
* run local server: `node server.js`
605+
* [p5.js](https://p5js.org/)
606+
* [face-api.js](https://github.com/justadudewhohacks/face-api.js/)
607+
* [socket.io](https://socket.io/)
608+
* [Bootstrap 5](https://getbootstrap.com/)
609+
* [uuid](https://github.com/uuidjs/uuid)
610+
* [Express](https://expressjs.com/it/)

public/css/main.css

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
a {
88
color: black;
9-
text-decoration: none;
9+
text-decoration: none;
1010
}
1111

1212
.textAbout > a {
@@ -46,34 +46,12 @@ p {
4646
border-radius: 40px;
4747
}
4848

49-
50-
/*.carousel-item {
51-
width: 1000px;
52-
height: 400px;
53-
}*/
54-
5549
.ww {
5650
width: 1000px;
5751
height: 400px;
5852

5953
}
6054

61-
/*#about.collapse {
62-
position: fixed;
63-
top:0;
64-
bottom: 0;
65-
width:30vw;
66-
right:-30vw;
67-
}
68-
69-
#about.show {
70-
right:0;
71-
}
72-
73-
#about.collapsing {
74-
transition: right 2s;
75-
}*/
76-
7755
.menu {
7856
font-family: var(--font-main-reg);
7957
font-size: var(--font-size-header);
@@ -139,7 +117,6 @@ p {
139117
z-index: -9999;
140118
}
141119

142-
143120
.sidenav {
144121
height: 100%;
145122
width: 45vw;
@@ -173,8 +150,6 @@ p {
173150
padding-top: 170px;
174151
}
175152

176-
177-
178153
.sidenav .closebtn {
179154
position: absolute;
180155
top: 0;
@@ -183,7 +158,6 @@ p {
183158
margin-left: 50px;
184159
}
185160

186-
187161
.resp-sharing-button__link,
188162
.resp-sharing-button__icon {
189163
display: inline-block
@@ -227,21 +201,6 @@ p {
227201
stroke: none
228202
}
229203

230-
.resp-sharing-button--twitter {
231-
background-color: #55acee
232-
}
233-
234-
.resp-sharing-button--twitter:hover {
235-
background-color: #2795e9
236-
}
237-
238-
.resp-sharing-button--pinterest {
239-
background-color: #bd081c
240-
}
241-
242-
.resp-sharing-button--pinterest:hover {
243-
background-color: #8c0615
244-
}
245204

246205
.resp-sharing-button--facebook {
247206
background-color: #3b5998
@@ -251,54 +210,6 @@ p {
251210
background-color: #2d4373
252211
}
253212

254-
.resp-sharing-button--tumblr {
255-
background-color: #35465C
256-
}
257-
258-
.resp-sharing-button--tumblr:hover {
259-
background-color: #222d3c
260-
}
261-
262-
.resp-sharing-button--reddit {
263-
background-color: #5f99cf
264-
}
265-
266-
.resp-sharing-button--reddit:hover {
267-
background-color: #3a80c1
268-
}
269-
270-
.resp-sharing-button--google {
271-
background-color: #dd4b39
272-
}
273-
274-
.resp-sharing-button--google:hover {
275-
background-color: #c23321
276-
}
277-
278-
.resp-sharing-button--linkedin {
279-
background-color: #0077b5
280-
}
281-
282-
.resp-sharing-button--linkedin:hover {
283-
background-color: #046293
284-
}
285-
286-
.resp-sharing-button--email {
287-
background-color: #777
288-
}
289-
290-
.resp-sharing-button--email:hover {
291-
background-color: #5e5e5e
292-
}
293-
294-
.resp-sharing-button--xing {
295-
background-color: #1a7576
296-
}
297-
298-
.resp-sharing-button--xing:hover {
299-
background-color: #114c4c
300-
}
301-
302213
.resp-sharing-button--whatsapp {
303214
background-color: #25D366
304215
}
@@ -315,14 +226,6 @@ p {
315226
background-color: #FB6200
316227
}
317228

318-
.resp-sharing-button--vk {
319-
background-color: #507299
320-
}
321-
322-
.resp-sharing-button--vk:hover {
323-
background-color: #43648c
324-
}
325-
326229
.resp-sharing-button--whatsapp {
327230
background-color: #25D366;
328231
border-color: #25D366;

0 commit comments

Comments
 (0)