public DrawLoopSection()
		{
			drawable = new Drawable
			{
				Style = "direct",
				BackgroundColor = Colors.Black
			};
			drawable.Paint += (sender, e) => renderer.DrawFrame(e.Graphics, drawable.Size);
			renderer = new DirectDrawingRenderer();

			var layout = new DynamicLayout(new Padding(10));
			layout.AddSeparateRow(null, UseTexturesAndGradients(), UseCreateGraphics(), null);
			layout.Add(content = new Panel { Content = drawable });
			this.Content = layout;
		}
Exemple #2
0
        public DrawLoopSection()
        {
            drawable = new Drawable
            {
                Style           = "direct",
                BackgroundColor = Colors.Black
            };
            drawable.Paint += (sender, e) => renderer.DrawFrame(e.Graphics, drawable.Size);
            renderer        = new DirectDrawingRenderer();

            var layout = new DynamicLayout(new Padding(10));

            layout.AddSeparateRow(null, UseTexturesAndGradients(), UseCreateGraphics(), null);
            layout.Add(content = new Panel {
                Content = drawable
            });
            this.Content = layout;
        }
Exemple #3
0
            public Box(Size canvasSize, bool useTexturesAndGradients, DirectDrawingRenderer renderer)
            {
                this.renderer = renderer;
                var size     = new SizeF(random.Next(50) + 50, random.Next(50) + 50);
                var location = new PointF(random.Next(canvasSize.Width - (int)size.Width), random.Next(canvasSize.Height - (int)size.Height));

                position  = new RectangleF(location, size);
                increment = new SizeF(random.Next(3) + 1, random.Next(3) + 1);
                if (random.Next(2) == 1)
                {
                    increment.Width = -increment.Width;
                }
                if (random.Next(2) == 1)
                {
                    increment.Height = -increment.Height;
                }

                angle    = random.Next(360);
                rotation = (random.Next(20) - 10f) / 4f;

                var rect = new RectangleF(size);

                color = GetRandomColor(random);
                var colorPen   = new Pen(color, generator: renderer.Generator);
                var blackPen   = Pens.Black(renderer.Generator);
                var blackBrush = Brushes.Black(renderer.Generator);

                switch (random.Next(useTexturesAndGradients ? 4 : 2))
                {
                case 0:
                    draw  = g => g.DrawRectangle(colorPen, rect);
                    erase = g => g.DrawRectangle(blackPen, rect);
                    break;

                case 1:
                    draw  = g => g.DrawEllipse(colorPen, rect);
                    erase = g => g.DrawEllipse(blackPen, rect);
                    break;

                case 2:
                    switch (random.Next(2))
                    {
                    case 0:
                        fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height), renderer.Generator);
                        break;

                    case 1:
                        fillBrush = new TextureBrush(renderer.texture, 1f, renderer.Generator)
                        {
                            Transform = Matrix.FromScale(size / 80, renderer.Generator)
                        };
                        break;
                    }
                    draw  = g => g.FillEllipse(fillBrush, rect);
                    erase = g => g.FillEllipse(blackBrush, rect);
                    break;

                case 3:
                    switch (random.Next(2))
                    {
                    case 0:
                        fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height), renderer.Generator);
                        break;

                    case 1:
                        fillBrush = new TextureBrush(renderer.texture, 1f, renderer.Generator)
                        {
                            Transform = Matrix.FromScale(size / 80, renderer.Generator)
                        };
                        break;
                    }
                    draw  = g => g.FillRectangle(fillBrush, rect);
                    erase = g => g.FillRectangle(blackBrush, rect);
                    break;
                }
            }
			public Box(Size canvasSize, bool useTexturesAndGradients, DirectDrawingRenderer renderer)
			{
				this.renderer = renderer;
				var size = new SizeF(random.Next(50) + 50, random.Next(50) + 50);
				var location = new PointF(random.Next(canvasSize.Width - (int)size.Width), random.Next(canvasSize.Height - (int)size.Height));
				position = new RectangleF(location, size);
				increment = new SizeF(random.Next(3) + 1, random.Next(3) + 1);
				if (random.Next(2) == 1)
					increment.Width = -increment.Width;
				if (random.Next(2) == 1)
					increment.Height = -increment.Height;

				angle = random.Next(360);
				rotation = (random.Next(20) - 10f) / 4f;

				var rect = new RectangleF(size);
				color = GetRandomColor(random);
				var colorPen = new Pen(color, generator: renderer.Generator);
				var blackPen = Pens.Black(renderer.Generator);
				var blackBrush = Brushes.Black(renderer.Generator);
				switch (random.Next(useTexturesAndGradients ? 4 : 2))
				{
					case 0:
						draw = g => g.DrawRectangle(colorPen, rect);
						erase = g => g.DrawRectangle(blackPen, rect);
						break;
					case 1:
						draw = g => g.DrawEllipse(colorPen, rect);
						erase = g => g.DrawEllipse(blackPen, rect);
						break;
					case 2:
						switch (random.Next(2))
						{
							case 0:
								fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height), renderer.Generator);
								break;
							case 1:
								fillBrush = new TextureBrush(renderer.texture, 1f, renderer.Generator)
								{
									Transform = Matrix.FromScale(size / 80, renderer.Generator)
								};
								break;
						}
						draw = g => g.FillEllipse(fillBrush, rect);
						erase = g => g.FillEllipse(blackBrush, rect);
						break;
					case 3:
						switch (random.Next(2))
						{
							case 0:
								fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height), renderer.Generator);
								break;
							case 1:
								fillBrush = new TextureBrush(renderer.texture, 1f, renderer.Generator)
								{
									Transform = Matrix.FromScale(size / 80, renderer.Generator)
								};
								break;
						}
						draw = g => g.FillRectangle(fillBrush, rect);
						erase = g => g.FillRectangle(blackBrush, rect);
						break;
				}
			}
Exemple #5
0
            public Box(Size canvasSize, bool useTexturesAndGradients, bool ShowTextCoordinates, DirectDrawingRenderer renderer)
            {
                DisplayTextCoordinates = ShowTextCoordinates;
                var size     = new SizeF(random.Next(50) + 50, random.Next(50) + 50);
                var location = new PointF(random.Next(canvasSize.Width - (int)size.Width), random.Next(canvasSize.Height - (int)size.Height));

                position  = new RectangleF(location, size);
                increment = new SizeF(random.Next(3) + 1, random.Next(3) + 1);
                if (random.Next(2) == 1)
                {
                    increment.Width = -increment.Width;
                }
                if (random.Next(2) == 1)
                {
                    increment.Height = -increment.Height;
                }

                angle    = random.Next(360);
                rotation = (random.Next(20) - 10f) / 4f;



                var rect = new RectangleF(size);

                color = GetRandomColor(random);
                var colorPen   = new Pen(color);
                var blackPen   = Pens.Black;
                var blackBrush = Brushes.Black;

                switch (random.Next(useTexturesAndGradients ? 5 : 2))
                {
                case 0:
                    draw  = g => g.DrawRectangle(colorPen, rect);
                    erase = g => g.DrawRectangle(blackPen, rect);
                    break;

                case 1:
                    draw  = g => g.DrawEllipse(colorPen, rect);
                    erase = g => g.DrawEllipse(blackPen, rect);
                    break;

                case 2:
                    switch (random.Next(2))
                    {
                    case 0:
                        fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height));
                        break;

                    case 1:
                        fillBrush = new TextureBrush(renderer.texture)
                        {
                            Transform = Matrix.FromScale(size / 80)
                        };
                        break;
                    }
                    draw  = g => g.FillEllipse(fillBrush, rect);
                    erase = g => g.FillEllipse(blackBrush, rect);
                    break;

                case 3:
                    switch (random.Next(3))
                    {
                    case 0:
                        fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height));
                        break;

                    case 1:
                        fillBrush = new TextureBrush(renderer.texture)
                        {
                            Transform = Matrix.FromScale(size / 80)
                        };
                        break;

                    case 2:
                        fillBrush = new RadialGradientBrush(GetRandomColor(random), GetRandomColor(random), (PointF)size / 2, (PointF)size / 2, size);
                        break;
                    }
                    draw  = g => g.FillRectangle(fillBrush, rect);
                    erase = g => g.FillRectangle(blackBrush, rect);
                    break;

                case 4:
                    var font = Fonts.Sans(random.Next(20) + 4);
                    draw  = g => g.DrawText(font, color, 0, 0, "Some Text");
                    erase = g => g.DrawText(font, Colors.Black, 0, 0, "Some Text");
                    break;
                }
            }