Don't use "new". On Sun, Apr 19, 2009 at 7:04 AM, Zak <el.za...@gmail.com> wrote: > > I can't get a null result from the fromString method. No matter what > I put in, it's never null. Generally, what I'm expecting it to do is > if I pass in a value that's not hex, not hsl, not rgb, that it should > drop through to the namedColor check and when it doesn't find the > named color, it should return null. But this just never seems to > happen. > > Also, it looks like there's not much validation once it's determined > that a color starts with #, rgb or hsl, not too worried about this as > I'll be checking my inputs before creating the color object, but is > this by design? > > Here's a short example: > > createLoggingPane(true); > > var myColor = new Color.fromString("xyz"); > log(myColor == null); > > ^^^ > > This always returns false for me, no matter what I put in the > constructor. Perhaps there's something wrong with my code? Here's > what I'm actually doing with it so far: > > function findColorsClick(text) { > createLoggingPane(true); > > var myColor = new Color.fromString("123lksdjf098234lkj"); > > if (myColor){ > var colorNameHash = Color.namedColors(); > var myColorName = "[No color name found]"; > for (var i in colorNameHash) > { > if (myColor.toHexString() == colorNameHash[i]){ > myColorName = i; > break; > } > } > alert("Color Name: " + myColorName + "\nRGB: " + myColor.toRGBString > () + "\nHSL: " + myColor.toHSLString() + "\nHEX: " + > myColor.toHexString() + "\nIs light: " + myColor.isLight() + "\nIs > dark: " + myColor.isDark()); > } > > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to mochikit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---