Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     outlinecity     = new CoreDrawCity(Color.FromArgb(55, 82, 99), 1);
     outlinecity.g   = Graphics.FromImage(b);
     txtInfo.Text   += "Ширина холста: " + b.Width + Environment.NewLine;
     timer1.Enabled  = true;
     button1.Enabled = false;
 }
Пример #2
0
        public List <string> GradientSky(Point[] p)
        {
            CoreDrawCity  city           = new CoreDrawCity(1);
            List <string> str            = new List <string>();
            const int     gradientHeight = 20;

            for (int i = 0; i < p.Length; i++)
            {
                if (i < p.Length - 1)
                {
                    if (p[i].X == p[i + 1].X)
                    {
                        if (p[i].X - p[i - 1].X == city.BETWEEN && p[i].Y == city.UNDERGROUND)
                        {
                            Rectangle           rect = new Rectangle(p[i - 1].X, city.UNDERGROUND - gradientHeight, city.BETWEEN, gradientHeight * 2);
                            LinearGradientBrush gb   = new LinearGradientBrush(rect, Color.FromArgb(30, 36, 48), Color.FromArgb(206, 206, 209), LinearGradientMode.Vertical);
                            g.FillRectangle(gb, rect.X, rect.Y + 1, city.BETWEEN, p[i].Y == city.UNDERGROUND ? gradientHeight : p[i].Y);
                            str.Add("x=" + rect.X + ", y=;" + rect.Y + "; width=" + rect.Width + ", height=" + rect.Height + Environment.NewLine);
                        }
                    }
                    else if (p[i].Y == p[i + 1].Y && p[i].Y > city.UNDERGROUND - gradientHeight && p[i].Y != city.UNDERGROUND)
                    {
                        Rectangle           rect = new Rectangle(p[i].X, city.UNDERGROUND - gradientHeight, p[i + 1].X - p[i].X, gradientHeight * 2);
                        LinearGradientBrush gb   = new LinearGradientBrush(rect, Color.FromArgb(30, 36, 48), Color.FromArgb(206, 206, 209), LinearGradientMode.Vertical);
                        g.FillRectangle(gb, rect.X, rect.Y + 1, rect.Width, p[i].Y - (city.UNDERGROUND - gradientHeight));
                        str.Add("x=" + rect.X + ", y=;" + rect.Y + "; width=" + rect.Width + ", height=" + (p[i].Y - (city.UNDERGROUND - gradientHeight)) + Environment.NewLine);
                    }
                    else if (p[i].Y == p[i + 1].Y && p[i + 1].X > p[i].X + city.BETWEEN && p[i].Y == city.UNDERGROUND)
                    {
                        Rectangle           rect = new Rectangle(p[i].X, city.UNDERGROUND - gradientHeight, p[i + 1].X - p[i].X, gradientHeight * 2);
                        LinearGradientBrush gb   = new LinearGradientBrush(rect, Color.FromArgb(30, 36, 48), Color.FromArgb(206, 206, 209), LinearGradientMode.Vertical);
                        g.FillRectangle(gb, rect.X, rect.Y + 1, rect.Width, gradientHeight);
                        str.Add("x=" + rect.X + ", y=;" + rect.Y + "; width=" + rect.Width + ", height=" + rect.Height + Environment.NewLine);
                    }

                    //Rectangle rect1 = new Rectangle(200, 10, 200, 50);
                    //LinearGradientBrush gb1 = new LinearGradientBrush(rect1, Color.Blue, Color.White, LinearGradientMode.Vertical);
                    //g.FillRectangle(gb1, 200, 20, 200, 100);
                }
            }
            return(str);
        }
Пример #3
0
        public void DrawStars(int w, Moon m)
        {
            CoreDrawCity city = new CoreDrawCity(w);
            Random       rnd  = new Random();

            Point[] p = new Point[4];
            for (int i = 0; i < 100; i++)
            {
                p[0].X = rnd.Next(10, w - 10);
                p[0].Y = rnd.Next(10, city.UNDERGROUND - 125);
                p[1].X = p[0].X + 2;
                p[1].Y = p[0].Y;
                p[2].X = p[0].X + 2;
                p[2].Y = p[0].Y + 2;
                p[3].X = p[0].X;
                p[3].Y = p[0].Y + 2;
                if ((p[0].X <m.point[0].X - 5 || p[0].X> m.point[0].X + m.width + 5) ||
                    (p[0].Y <m.point[0].Y - 5 || p[0].Y> m.point[0].Y + m.height + 5))
                {
                    g.DrawPolygon(pen, p);
                    g.FillPolygon(brush, p);
                }
            }
        }