public static Colour fromHexString(String s)
    {
        if (s.length() == 7) // in format of #ff00ff
        {
            char buf[] = new char[2];
            Colour ret = new Colour(1f, 1f, 1f, 1f);
            for (int i = 0; i < 3; i++)
            {
                buf[0] = s.charAt(1 + i * 2);
                buf[1] = s.charAt(1 + i * 2 + 1);
                switch (i)
                {
                    case 0: // red
                        ret.setRed((float)(hexDigitToDec(buf[0]) * 16 + hexDigitToDec(buf[1]))/255f);
                        break;
                    case 1: // green
                    	ret.setGreen((float)(hexDigitToDec(buf[0]) * 16 + hexDigitToDec(buf[1]))/255f);
                    	break;
                    case 2: // blue
                    	ret.setBlue((float)(hexDigitToDec(buf[0]) * 16 + hexDigitToDec(buf[1]))/255f);
                        break;
                }
            }
            return ret;
        }
        return null;
    }