Reference Source Test
public class | source

ColorDriver

Extends:

src/drivers/motion/MotionDriverSimulator.js~EventEmitter → ColorDriver

Driver detects color based on RGB components

Method Summary

Public Methods
public

Get last read color

public

rgbToHsl(r: Number, g: Number, b: Number): *

Converts an RGB color value to HSL.

public

rgbToHsv(r: Number, g: Number, b: Number): *

Converts an RGB color value to HSV.

public

start(interval: Number)

Start reading data from sensor

public

stop()

Stop receiving RGB components

Public Methods

public getColor(): String source

Get last read color

Return:

String

Color

public rgbToHsl(r: Number, g: Number, b: Number): * source

Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and l in the set [0, 1].

Params:

NameTypeAttributeDescription
r Number

The red color value

g Number

The green color value

b Number

The blue color value

Return:

*

Array The HSL representation

public rgbToHsv(r: Number, g: Number, b: Number): * source

Converts an RGB color value to HSV. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and v in the set [0, 1].

Params:

NameTypeAttributeDescription
r Number

The red color value

g Number

The green color value

b Number

The blue color value

Return:

*

Array The HSV representation

public start(interval: Number) source

Start reading data from sensor

Params:

NameTypeAttributeDescription
interval Number

Receive RGB components every interval[ms]

public stop() source

Stop receiving RGB components