Beispiel #1
0
        public static Color FromRRGGBB(string str)
        {
            int value = IntTools.ToInt_16(str);

            value = IntTools.ToRange(value, 0, 0xffffff);

            int b = value % 256;

            value /= 256;
            int g = value % 256;
            int r = value / 256;

            return(Color.FromArgb(r, g, b));
        }
Beispiel #2
0
        public static int arrComp <T>(T[] a, T[] b, Comparison <T> comp)
        {
            int minlen = Math.Min(a.Length, b.Length);

            for (int index = 0; index < minlen; index++)
            {
                int ret = comp(a[index], b[index]);

                if (ret != 0)
                {
                    return(ret);
                }
            }
            return(IntTools.comp(a.Length, b.Length));
        }
Beispiel #3
0
        public void drawLine(int x1, int y1, int x2, int y2, Dot dot)
        {
            int denom = Math.Max(Math.Abs(x1 - x2), Math.Abs(y1 - y2));

            for (int numer = 0; numer <= denom; numer++)
            {
                double rate = (double)numer / denom;

                table.set(
                    IntTools.toInt(x1 + rate * (x2 - x1)),
                    IntTools.toInt(y1 + rate * (y2 - y1)),
                    dot
                    );
            }
        }
Beispiel #4
0
        public static int Comp(byte[] a, byte[] b)
        {
            int minlen = Math.Min(a.Length, b.Length);

            for (int index = 0; index < minlen; index++)
            {
                int ret = Comp(a[index], b[index]);

                if (ret != 0)
                {
                    return(ret);
                }
            }
            return(IntTools.Comp(a.Length, b.Length));
        }
Beispiel #5
0
 public void toInt()
 {
     x = IntTools.toInt(x);
     y = IntTools.toInt(y);
 }
Beispiel #6
0
 public static bool toFlag(string str)
 {
     return(equalsIgnoreCase(str, S_TRUE) || IntTools.toInt(str, 0, 2, 0) == 1);
 }