コード例 #1
0
        static void Main(string[] args)
        {
            //Set; Get;
            SetGetConstructor d = new SetGetConstructor()
            {
                Name = "Alma", Age = 45
            };

            Console.WriteLine(d.Name + " " + d.Age);

            // reference params
            RefValue r = new RefValue();
            int      x = 2;
            int      y = 10;

            Console.WriteLine(x + " " + y);
            r.ChangeValues(ref x, ref y);
            Console.WriteLine(x + " " + y);

            // object parameter
            ParamsObject p = new ParamsObject();

            p.PrintElements("one", "two");

            // default params
            DefaultParams dp = new DefaultParams(firstName: "Zsolt", lastName: "Annár", job: "UI");

            //dp.FirstName = "oké";
            Console.WriteLine(dp.FirstName);

            // Extended Method
            string s = "mystring";

            s.Print();
            ExtendedMethode.Print(s);

            // Class Library
            ClassLib.PrintHello();

            //PowFunction(x,y)
            double result = PowFunction.Pow(2, 10);

            result.Print();

            //Interface
            IAnimal anim = new Animal()
            {
                Age  = 15,
                Name = "Alma"
            };

            Console.WriteLine(anim.Name);


            Console.ReadKey();
        }
コード例 #2
0
        public static void RegisterAll()
        {
            BreakExpression.Register();
            ContinueExpression.Register();
            ReturnFunctionExpression.Register();
            AbsFunction.Register();
            ExecuteFile.Register();
            PowFunction.Register();
            ProductFunction.Register();
            HelpFunction.Register();
            SqrtFunction.Register();
            SumDeepFunction.Register();
            SumFunction.Register();
            LengthFunction.Register();

            ConsoleObject.Register();
            TrigonometryObject.Register();
            ThisConstant.Register();

            BooleanValue.Register();
            ComplexValue.Register();
            DecimalValue.Register();
            NullValue.Register();
        }
コード例 #3
0
        public void Start()
        {
            switch (Function)
            {
            case Animation.Key.Fct.LINEAR:
                linear.Checked = true;
                break;

            case Animation.Key.Fct.POWER:
                pow.Checked = true;
                break;

            case Animation.Key.Fct.ROOT:
                root.Checked = true;
                break;

            case Animation.Key.Fct.GAUSS:
                gauss.Checked = true;
                break;

            case Animation.Key.Fct.BINARY:
                binary.Checked = true;
                break;
            }
            coeff.Value = (decimal)Coefficient.Capped(1, 9999);

            Program.form.Enabled = false;
            Show(Program.form);
            var array = new VertexArray(PrimitiveType.LineStrip);

            while (Visible)
            {
                Application.DoEvents();
                App.DispatchEvents();

                array.Clear();
                for (int i = 0; i < App.Size.X; i++)
                {
                    float y = 0;
                    switch (Function)
                    {
                    case Animation.Key.Fct.LINEAR:
                        y = Utilities.Interpolation(Utilities.Percent(i, 0, (int)App.Size.X - 1), App.Size.Y - 1, 1f);
                        break;

                    case Animation.Key.Fct.POWER:
                        y = new PowFunction(Coefficient).Interpolation(Utilities.Percent(i, 0, (int)App.Size.X - 1), App.Size.Y - 1, 1f);
                        break;

                    case Animation.Key.Fct.ROOT:
                        y = new PowFunction(1f / Coefficient).Interpolation(Utilities.Percent(i, 0, (int)App.Size.X - 1), App.Size.Y - 1, 1f);
                        break;

                    case Animation.Key.Fct.GAUSS:
                        y = new ProgressiveFunction(Coefficient).Interpolation(Utilities.Percent(i, 0, (int)App.Size.X - 1), App.Size.Y - 1, 1f);
                        break;

                    case Animation.Key.Fct.BINARY:
                        if (i > App.Size.X / 2)
                        {
                            y = 1;
                        }
                        else
                        {
                            y = App.Size.Y - 1;
                        }
                        break;
                    }
                    array.Append(new Vertex(new Vector2f(i, y), SFML.Graphics.Color.Black));
                }

                App.Clear(SFML.Graphics.Color.White);

                App.Draw(array);

                App.Display();
            }
            Program.form.Enabled = true;
        }
コード例 #4
0
        public override void Update(RenderWindow app)
        {
            Time currTime = _chronometer.ElapsedTime;
            int  iSize    = (int)Size;

            Lines.Clear();
            Gradient.Clear();
            Light.Clear();
            int drawSecondBar = _chronometer.ElapsedTime < AnimDuration ? 1 : 0;

            if (drawSecondBar == 1 && oldPerc > PercentFilled)
            {
                drawSecondBar = 2;
            }
            float currentFilling;

            if (drawSecondBar == 2)
            {
                currentFilling = new PowFunction(1f / 6).Interpolation(Utilities.Percent(currTime, Time.Zero, AnimDuration), oldPerc, PercentFilled);
            }
            else
            {
                currentFilling = Utilities.Interpolation(Utilities.Percent(currTime, Time.Zero, AnimDuration), oldPerc, PercentFilled);
            }
            float secondFilling = 0;

            if (drawSecondBar == 1)
            {
                secondFilling = new PowFunction(1f / 6).Interpolation(Utilities.Percent(currTime, Time.Zero, AnimDuration), oldPerc, PercentFilled);
            }
            else if (drawSecondBar == 2)
            {
                secondFilling = Utilities.Interpolation(Utilities.Percent(currTime, Time.Zero, AnimDuration), oldPerc, PercentFilled);
            }
            if (_chronometer.Paused)
            {
                secondFilling  = PercentFilled;
                currentFilling = oldPerc;
            }
            float currentHue, secondHue;

            currentHue      = Utilities.Interpolation(currentFilling, Hue, Hue - 20);
            secondHue       = Utilities.Interpolation(secondFilling, Hue, Hue - 20);
            currentFilling *= Size;
            secondFilling  *= Size;
            currentFilling  = (int)currentFilling;
            secondFilling   = (int)secondFilling;
            Lines.Append(new Vertex(new Vector2f(-1, 0), NewColor(Hue, .2f, .1f)));
            Lines.Append(new Vertex(new Vector2f(iSize, 0), NewColor(Hue, .2f, .1f)));

            Lines.Append(new Vertex(new Vector2f(0, 0), NewColor(Hue, .2f, .1f)));
            Lines.Append(new Vertex(new Vector2f(0, 14), NewColor(Hue, .2f, .1f)));

            Lines.Append(new Vertex(new Vector2f(0, 14), NewColor(Hue, .2f, .6f)));
            Lines.Append(new Vertex(new Vector2f(iSize, 14), NewColor(Hue, .2f, .6f)));

            Lines.Append(new Vertex(new Vector2f(iSize + 1, 0), NewColor(Hue, .2f, .6f)));
            Lines.Append(new Vertex(new Vector2f(iSize + 1, 14), NewColor(Hue, .2f, .6f)));

            if (drawSecondBar != 0)
            {
                Gradient.Append(new Vertex(new Vector2f(1, 1), NewColor(Hue - 20, .25f, 1)));
                Gradient.Append(new Vertex(new Vector2f(1, 7), NewColor(Hue - 20, .25f, .9f)));
                Gradient.Append(new Vertex(new Vector2f(secondFilling, 7), NewColor(secondHue - 20, .25f, 1)));
                Gradient.Append(new Vertex(new Vector2f(secondFilling, 1), NewColor(secondHue - 20, .25f, 1)));
                Gradient.Append(new Vertex(new Vector2f(1, 7), NewColor(Hue - 20, .35f, .9f)));
                Gradient.Append(new Vertex(new Vector2f(1, 12), NewColor(Hue - 20, .35f, .9f)));
                Gradient.Append(new Vertex(new Vector2f(secondFilling, 12), NewColor(secondHue - 20, .35f, .9f)));
                Gradient.Append(new Vertex(new Vector2f(secondFilling, 7), NewColor(secondHue - 20, .35f, .9f)));

                Lines.Append(new Vertex(new Vector2f(0, 1), NewColor(Hue - 20, .2f, 1)));
                Lines.Append(new Vertex(new Vector2f(secondFilling, 1), NewColor(Hue - 20, .2f, 1)));
                Lines.Append(new Vertex(new Vector2f(1, 1), NewColor(Hue - 20, .2f, 1)));
                Lines.Append(new Vertex(new Vector2f(1, 13), NewColor(Hue - 20, .2f, 1)));
                Lines.Append(new Vertex(new Vector2f(0, 13), NewColor(Hue - 20, .35f, .74f)));
                Lines.Append(new Vertex(new Vector2f(secondFilling, 13), NewColor(Hue - 20, .35f, .74f)));
                Lines.Append(new Vertex(new Vector2f(secondFilling, 0), NewColor(Hue - 20, .35f, .74f)));
                Lines.Append(new Vertex(new Vector2f(secondFilling, 13), NewColor(Hue - 20, .35f, .74f)));
            }

            Gradient.Append(new Vertex(new Vector2f(1, 1), NewColor(Hue, .65f, .85f)));
            Gradient.Append(new Vertex(new Vector2f(1, 7), NewColor(Hue, .65f, .85f)));
            Gradient.Append(new Vertex(new Vector2f(currentFilling, 7), NewColor(currentHue, .65f, .85f)));
            Gradient.Append(new Vertex(new Vector2f(currentFilling, 1), NewColor(currentHue, .65f, .85f)));
            Gradient.Append(new Vertex(new Vector2f(1, 7), NewColor(Hue, .85f, .75f)));
            Gradient.Append(new Vertex(new Vector2f(1, 12), NewColor(Hue, .85f, .75f)));
            Gradient.Append(new Vertex(new Vector2f(currentFilling, 12), NewColor(currentHue, .85f, .75f)));
            Gradient.Append(new Vertex(new Vector2f(currentFilling, 7), NewColor(currentHue, .85f, .75f)));

            Lines.Append(new Vertex(new Vector2f(0, 1), NewColor(Hue, .5f, 1)));
            Lines.Append(new Vertex(new Vector2f(currentFilling, 1), NewColor(Hue, .5f, 1)));
            Lines.Append(new Vertex(new Vector2f(1, 1), NewColor(Hue, .5f, 1)));
            Lines.Append(new Vertex(new Vector2f(1, 13), NewColor(Hue, .5f, 1)));
            Lines.Append(new Vertex(new Vector2f(0, 13), NewColor(Hue, .85f, .4f)));
            Lines.Append(new Vertex(new Vector2f(currentFilling, 13), NewColor(Hue, .85f, .4f)));
            if (drawSecondBar == 0)
            {
                Lines.Append(new Vertex(new Vector2f(currentFilling, 0), NewColor(Hue, .85f, .4f)));
                Lines.Append(new Vertex(new Vector2f(currentFilling, 13), NewColor(Hue, .85f, .4f)));
            }
            Light.Append(new Vertex(new Vector2f(currentFilling, 7), NewColor(Hue - 20, .5f, 1)));

            var tr = Transform.Identity;

            tr.Scale(4, 14);
            for (int i = 0; i <= 20; i++)
            {
                Light.Append(new Vertex(new Vector2f(currentFilling, 7) + tr.TransformPoint((Angle.Loop * i / 20).GenerateVector()), NewColor(Hue, .5f, 1, 0)));
            }
        }