Example #1
0
 public Controller(Bitmap bm, int w, int h)
 {
     Surface = bm;
     maxLength = w * h;
     // Here it starts
     System.Drawing.Imaging.BitmapData lockData = Surface.LockBits(
         new Rectangle(0, 0, Surface.Width, Surface.Height),
         System.Drawing.Imaging.ImageLockMode.ReadWrite,
         System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     // Create an array to store image data
     Space s = new Space(w, h);
     // Use the Marshal class to copy image data
     Marshal.Copy(lockData.Scan0, s.Cells, 0, maxLength);
     // Creating palette
     Gfx.Palette.Map paletteMap = new Gfx.Palette.Map();
     paletteMap.setColorStop(0, new ColorStop(0, Color.White));
     paletteMap.setColorStop(3, new ColorStop(3, Color.LightSteelBlue)); // Color.Yellow));
     paletteMap.setColorStop(10, new ColorStop(10, Color.SteelBlue)); // Color.Lime));
     //paletteMap.setColorStop(80, new ColorStop(85, Color.DarkSeaGreen)); // Color.DarkRed));
     paletteMap.setColorStop(95, new ColorStop(99, Color.DarkBlue)); //.SaddleBrown));
     paletteMap.setColorStop(100, new ColorStop(100, Color.Black));
     Calc = new Calc(s, paletteMap);
     if(!continued && !uploaded) {
         Calc.Randomize();
     }
     // Copy image data back
     Marshal.Copy(s.Cells, 0, lockData.Scan0, maxLength);
     // Unlock image
     Surface.UnlockBits(lockData);
     // Here it ends
 }
Example #2
0
 public Calc(Space s, Color alive, Color dead)
 {
     Space = s;
     cAlive = alive;
     cDead = dead;
     init();
 }
Example #3
0
 public Calc(Space s, Gfx.Palette.Map m)
 {
     Space = s;
     palette = new Color[ageToDie];
     //step = 1.0f / ageToDie;
     double ratio = 100.0f / ageToDie;
     //Console.WriteLine(step);
     int stops = m.getMap().Count;
     Console.WriteLine("stops: {0}", stops);
     int stop = 0;
     int age = (int) ageToDie / (stops - 1);
     Console.WriteLine("age: {0}", age);
     int p = 0;
     Gfx.Palette.ColorStop first = null;
     Gfx.Palette.ColorStop last = null;
     foreach (var pair in m.getMap()) {
         p++;
         if (p == 1) {
             if (first == null) {
                 first = pair.Value;
                 last = null;
             } else if (last != null) {
                 first = last;
                 last = pair.Value;
                 p = 0;
                 stop++;
             }
         } else { // 2
             last = pair.Value;
             p = 0;
             stop++;
         }
         if ((first != null) && (last != null)) {
             Console.WriteLine("stop: {0}", stop);
             //double lambda;
             int start = (int)(first.getPosition() / ratio);
             int end = (int)(last.getPosition() / ratio);
             Console.WriteLine("start: {0}", start);
             Console.WriteLine("end: {0}", end);
             //for (int i = start; i < end; i++) {
             //	lambda = i * step;
             //	palette[i] = ColorInterpolator.InterpolateBetween(first.getColor(), last.getColor(), lambda);
             //}
             int i = start;
             int walk = end - start;
             foreach (Color c in ColorInterpolator.GetGradients(first.getColor(), last.getColor(), walk)) {
                 palette[i] = c;
                 i++;
             }
         }
     }
     init();
 }
Example #4
0
 //public Controller (Bitmap bm, int w, int h, Map paletteMap)
 public Controller(Bitmap bm, int w, int h, List<Gfx.Palette.GradientEditor.GradientStop> paletteMap)
 {
     Surface = bm;
     maxLength = w * h;
     // Here it starts
     System.Drawing.Imaging.BitmapData lockData = Surface.LockBits(
         new Rectangle(0, 0, Surface.Width, Surface.Height),
         System.Drawing.Imaging.ImageLockMode.ReadWrite,
         System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     // Create an array to store image data
     Space s = new Space(w, h);
     // Use the Marshal class to copy image data
     Marshal.Copy(lockData.Scan0, s.Cells, 0, maxLength);
     Calc = new Calc(s, paletteMap);
     if(!continued && !uploaded) {
         Calc.Randomize();
     }
     // Copy image data back
     Marshal.Copy(s.Cells, 0, lockData.Scan0, maxLength);
     // Unlock image
     Surface.UnlockBits(lockData);
     // Here it ends
 }
Example #5
0
 //public Calc (Space s, Gfx.Palette.Map m)
 public Calc(Space s, List<Gfx.Palette.GradientEditor.GradientStop> m)
 {
     Space = s;
     initPalette(m);
     init();
 }
Example #6
0
 public Calc(Space s, Color[] p)
 {
     Space = s;
     palette = p;
     init();
 }
Example #7
0
 public Calc(Space s)
 {
     Space = s;
     init();
 }
Example #8
0
 public void setSpace(Space s)
 {
     Space = s;
     init();
 }
Example #9
0
 public void loadSurface(Bitmap bm)
 {
     Surface = bm;
     maxLength = bm.Width * bm.Height;
     // Here it starts
     System.Drawing.Imaging.BitmapData lockData = Surface.LockBits(
         new Rectangle(0, 0, Surface.Width, Surface.Height),
         System.Drawing.Imaging.ImageLockMode.ReadWrite,
         System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     // Create an array to store image data
     Space s = new Space(bm.Width, bm.Height);
     // Use the Marshal class to copy image data
     Marshal.Copy(lockData.Scan0, s.Cells, 0, maxLength);
     Calc.setSpace(s);
     // Copy image data back
     Marshal.Copy(s.Cells, 0, lockData.Scan0, maxLength);
     // Unlock image
     Surface.UnlockBits(lockData);
     // Here it ends
 }