コード例 #1
0
        public Bitmap AddShadows()
        {
            Bitmap hm = new Bitmap(size.Width, size.Height);

            for (int i = 0; i < size.Width; i++)
            {
                for (int j = 0; j < size.Height; j++)
                {
                    int z = GetZ(i, j);
                    if (z != bg)
                    {
                        PointInt cur = Rotation.Transform(i, j, z, turnKoefs);

                        Color curPixColor = img.GetPixel(i, j);
                        if (cur.x < 0 || cur.y < 0 || cur.x >= size.Width || cur.y >= size.Height)
                        {
                            hm.SetPixel(i, j, curPixColor);
                            continue;
                        }

                        if (ZbufFromSun[cur.y, cur.x] > cur.z + 5)
                        {
                            Console.WriteLine("Yes");
                            hm.SetPixel(i, j, Colors.Mix(Color.DarkGray, curPixColor, 0.5f));
                        }
                        else
                        {
                            hm.SetPixel(i, j, curPixColor);
                        }
                    }
                }
            }

            return(hm);
        }
コード例 #2
0
 private void ProcessPoint(int[,] buffer, Bitmap image, PointInt point, Color color)
 {
     if (!(point.x < 0 || point.x >= size.Width || point.y < 0 || point.y >= size.Height))
     {
         if (point.z > buffer[point.y, point.x])
         {
             buffer[point.y, point.x] = point.z;
             image.SetPixel(point.x, point.y, color);
         }
     }
 }