forked from andrewmunsell/RaspberryPixels
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPixel.js
More file actions
34 lines (30 loc) · 626 Bytes
/
Pixel.js
File metadata and controls
34 lines (30 loc) · 626 Bytes
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
var color = require('tinycolor2')
/**
* Representation of a single pixel
* @param {number} r Red value
* @param {number} g Green value
* @param {number} b Blue value
*/
function Pixel(r, g, b){
this.color = {
r: r,
b: b,
g: g
}
}
/**
* Get the RGB value of the pixel
* @return {object} Object representing the RGB values of the pixel
*/
Pixel.prototype.getRGB = function(){
return this.color
}
/**
* Get the HSL value of the pixel
* @return {number} Object representing the HSL values of the pixel
*/
Pixel.prototype.getHSL = function(){
return color(this.color)
.toHsl()
}
module.exports = Pixel;