Horay Horay - 4 months ago 17
Javascript Question

Error: Cannot read property of undefiended

I'm trying to make a simple conversion with color.js from this library, and I can't seem to do it. I tried dong the following:

var myColor = new Colors();

var hslColor = myColor.colorConverter.hsv2hsl({
h: 100,
s: 100,
v: 100
});


But I get an error:


Uncaught TypeError: Cannot read property 'hsv2hsl' of undefined


Why am I getting the error, and how can I fix it?

JSFiddle



Code Snippet



var myColor = new Colors();

var hslColor = myColor.colorConverter.hsv2hsl({
h: 100,
s: 100,
v: 100
});
console.log(hslColor);

<script src="https://rawgit.com/PitPik/colorPicker/master/colors.js"></script>




Answer

Just dig in a little bit and found the right way

var myColor = new Colors();
var hslColor = myColor.convertColor({
  h: 100,
  s: 100,
  v: 100
},'hsv2hsl')