Example #1
0
        private int GetFractionIndex(int x)
        {
            for (int i = 1; i < fractions.Count(); i++)
            {
                FractionPosition start = fractions[i - 1];
                FractionPosition end   = fractions[i];
                if (start == null || end == null)
                {
                    return(-1);
                }
                if (i == 1)
                {
                    if (x >= start.x && x <= end.x)
                    {
                        return(i);
                    }
                }
                else
                {
                    if (x > start.x && x <= end.x)
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
Example #2
0
 public void SetFraction(int index, int x, int percent)
 {
     fractions[index] = new FractionPosition
     {
         x   = x,
         y   = Raw.GetPoint(x),
         blp = percent
     };
 }
Example #3
0
 public void SetFraction(int index, int x, int percent)
 {
     fractions[index] = new FractionPosition
     {
         x = x,
         y = Raw.GetPoint(x),
         blp = percent
     };
 }
Example #4
0
        public int GetVal(int x)
        {
            int fraIndex = GetFractionIndex(x);

            if (fraIndex == -1)
            {
                return(0);
            }
            FractionPosition start = fractions[fraIndex - 1];
            FractionPosition end   = fractions[fraIndex];

            if (start.x == end.x)
            {
                return(0);
            }
            int rawVal   = Raw.GetPoint(x);
            int discount = (end.bly - start.bly) * (x - start.x) / (end.x - start.x) + start.bly;

            return((rawVal > discount) ? (rawVal - discount) : 0);
        }