예제 #1
0
 public ColoredMandel(ICalculatorFactory factory)
     : base(factory)
 {
     c_layers = new List<ColorLayer>();
       c_inscol = new ColorValue(true, 0, 0, 0);
       c_outcol = new ColorValue(true, 1, 1, 1);
 }
예제 #2
0
 public ColoredMandel()
     : base()
 {
     c_layers = new List<ColorLayer>();
       c_inscol = new ColorValue(true, 0, 0, 0);
       c_outcol = new ColorValue(true, 1, 1, 1);
 }
예제 #3
0
 public DictGradientMap(ColorValue start, ColorValue end)
 {
     c_points = new SortedDictionary<double, ColorValue>();
       c_type = GradientType.GRADIENT_MAP_RGB;
       c_points[0] = start;
       c_points[1] = end;
       c_shift = 0;
 }
예제 #4
0
 public DictGradientMap()
 {
     c_points = new SortedDictionary<double, ColorValue>();
       c_type = GradientType.GRADIENT_MAP_RGB;
       c_points[0] = new ColorValue(true, 0.0, 0.0, 0.0);
       c_points[1] = new ColorValue(true, 1.0, 1.0, 1.0);
       c_shift = 0;
 }
예제 #5
0
 public virtual void PutPoint(int layernum, int flags, int x, int y, ColorValue c)
 {
     if (oldx == -1)
       {
     old = c;
     oldx = x;
     oldy = y;
       }
       else if ((oldx != x) || (oldy != y))
       {
     SetPoint(flags, oldx, oldy, old);
     old = c;
     oldx = x;
     oldy = y;
       }
       else
       {
     old.Blend(c);
       }
 }
예제 #6
0
 public abstract void SetPoint(int flags, int x, int y, ColorValue c);
예제 #7
0
 public override void SetPoint(int flags, int x, int y, ColorValue c)
 {
     if (!buffered) {
     if (flags!=2) file.Seek(pos+(getHeight()-1-y)*pitch+x*3, SeekOrigin.Begin);
     byte[] buffer = new byte[3];
     buffer[0] = (byte)Math.Floor(c.Blue*255);
     buffer[1] = (byte)Math.Floor(c.Green * 255);
     buffer[2] = (byte)Math.Floor(c.Red * 255);
     file.Write(buffer, 0, 3);
       } else {
     buf[pos+(getHeight()-1-y)*pitch+x*3] = (byte)Math.Floor(c.Blue*255);
     buf[pos+(getHeight()-1-y)*pitch+x*3+1] = (byte)Math.Floor(c.Green*255);
     buf[pos+(getHeight()-1-y)*pitch+x*3+2] = (byte)Math.Floor(c.Red*255);
       }
 }
예제 #8
0
        public void Blend(ColorValue sec, double alpha = 1, double saturation = 1, double value = 1)
        {
            if ((alpha <= 0) || (sec.c_a <= 0)) return;
              if (alpha < 0) alpha = 0;
              if (alpha > 1) alpha = 1;
              if (saturation < 0) saturation = 0;
              if (saturation > 1) saturation = 1;
              if (value < 0) value = 0;
              if (value > 1) value = 1;

              ColorValue sec2 = sec;
              if (saturation != 1)
              {
            sec2.Saturation = sec2.Saturation * saturation;
              }
              if (value != 1)
              {
            sec2.Value = sec2.Value * value;
              }
              if (alpha != 1)
              {
            if ((alpha != 0) && (sec2.c_a != 0))
            {
              c_r = c_r + (sec2.c_r - c_r) * sec2.c_a * alpha;
              c_g = c_g + (sec2.c_g - c_g) * sec2.c_a * alpha;
              c_b = c_b + (sec2.c_b - c_b) * sec2.c_a * alpha;
              RGBtoHSV(c_r, c_g, c_b, out c_h, out c_s, out c_v);
            }
              }
              else if (sec2.c_a != 1)
              {
            if ((alpha != 0) && (sec2.c_a != 0))
            {
              c_r = c_r + (sec2.c_r - c_r) * sec2.c_a;
              c_g = c_g + (sec2.c_g - c_g) * sec2.c_a;
              c_b = c_b + (sec2.c_b - c_b) * sec2.c_a;
              RGBtoHSV(c_r, c_g, c_b, out c_h, out c_s, out c_v);
            }
              }
              else
              {
            c_a = sec2.c_a;
            c_r = sec2.c_r;
            c_g = sec2.c_g;
            c_b = sec2.c_b;
            c_h = sec2.c_h;
            c_s = sec2.c_s;
            c_v = sec2.c_v;
              }
        }
예제 #9
0
 public virtual void setPoint(double pos, ColorValue point)
 {
     if (pos < 0) pos = 0;
       if (pos > 1) pos = 1;
       c_points[pos] = point;
 }
예제 #10
0
        public virtual bool LoadFromFile(string filename, bool type = false)
        {
            try
              {
            using (FileStream fs = new FileStream(filename, FileMode.Open))
            {
              using (StreamReader f = new StreamReader(fs))
              {
            string s;
            s = f.ReadLine();
            s = f.ReadLine();
            int numlines = Convert.ToInt32(f.ReadLine());
            double[] a = new double[13];
            double[] save = new double[4];
            c_points.Clear();
            c_points[0] = new ColorValue(true, 0, 0, 0, 0);
            c_points[1] = new ColorValue(true, 1, 0, 0, 0);
            for (int i = 0; i < numlines; i++)
            {
              string[] ss = f.ReadLine().Split(' ');

              for (int i2 = 0; i2 < 13; i2++) { double.TryParse(ss[i2], System.Globalization.NumberStyles.Float, CultureInfo.InvariantCulture, out a[i2]); };
              //std::cout << std::endl;
              if ((i != 0) && (type))
              {
                if ((save[0] != a[3]) || (save[1] != a[4]) || (save[2] != a[5]) || (save[3] != a[7]))
                {
                  c_points[a[0] - double.Epsilon] = new ColorValue(true, save[0], save[1], save[2], save[3]);
                }
              }
              c_points[a[0]] = new ColorValue(true, a[3], a[4], a[5], a[6]);
              if (type) c_points[a[1]] = new ColorValue(true, a[3] + (a[7] - a[3]) / 2, a[4] + (a[8] - a[4]) / 2, a[5] + (a[9] - a[5]) / 2, a[6] + (a[10] - a[6]) / 2);
              save[0] = a[7];
              save[1] = a[8];
              save[2] = a[9];
              save[3] = a[10];
            }
            c_points[1] = new ColorValue(true, a[7], a[8], a[9], a[10]);
              }
            }
            return true;
              }
              catch (FileNotFoundException)
              {
            return false;
              }
        }