Пример #1
0
        public override void _Ready()
        {
            generator = new RandomNumberGenerator();
            generator.Randomize();

            var canvas = new DrawCanvas((pen) =>
            {
                var size = GetViewportRect().Size;

                // Follow mouse for fun
                var mousePosition = GetViewport().GetMousePosition();

                float xNum  = generator.Randfn(0, 1); // Gaussian distribution
                float yNum  = generator.Randfn(0, 1); // Gaussian distribution
                var colNumR = (byte)(generator.Randfn(0, 1) * 255);
                var colNumG = (byte)(generator.Randfn(0, 1) * 255);
                var colNumB = (byte)(generator.Randfn(0, 1) * 255);

                float x = (20 * xNum) + mousePosition.x;
                float y = (20 * yNum) + mousePosition.y;

                pen.DrawCircle(new Vector2(x, y), 8, Color.Color8(colNumR, colNumG, colNumB, 64));
            });

            canvas.QueueClearDrawing(Color.Color8(45, 45, 45));
            AddChild(canvas);
        }
Пример #2
0
        public override void _Ready()
        {
            var canvas = new DrawCanvas((pen) =>
            {
                // Stop when theta > MaxTheta
                if (theta < MaxTheta)
                {
                    for (int i = 0; i < Iterations; ++i)
                    {
                        float x    = (Width + margin) * Mathf.Cos(theta);
                        float y    = (Width + margin) * Mathf.Sin(theta);
                        var target = new Vector2(x, y);
                        var size   = GetViewportRect().Size;

                        pen.DrawCircle((size / 2) + target, Width / 2, MathUtils.RandColor());

                        theta  += 0.016f;
                        margin += 0.016f * 3;
                    }
                }
            });

            canvas.QueueClearDrawing(Color.Color8(45, 45, 45));
            AddChild(canvas);
        }
Пример #3
0
        public override void _Ready()
        {
            walker = new Walker();
            walker.SetXY(GetViewportRect().Size / 2);
            AddChild(walker);

            var canvas = new DrawCanvas((pen) => pen.DrawRect(walker.GetStepRect(), Colors.LightCyan, true));

            canvas.QueueClearDrawing(Color.Color8(45, 45, 45));
            AddChild(canvas);
        }
Пример #4
0
        public override void _Ready()
        {
            generator = new RandomNumberGenerator();
            generator.Randomize();

            var canvas = new DrawCanvas((pen) =>
            {
                var size   = GetViewportRect().Size;
                float num  = generator.Randfn(0, 1); // Gaussian distribution
                float sd   = size.x / 8;
                float mean = size.x / 2;
                float x    = (sd * num) + mean;
                pen.DrawCircle(new Vector2(x, size.y / 2), 8, Colors.LightCyan.WithAlpha(10));
            });

            canvas.QueueClearDrawing(Color.Color8(45, 45, 45));
            AddChild(canvas);
        }