//[Inject]
        //protected HttpClient Http { get; set; }

        protected override void OnAfterRender()
        {
            _ctx = _canvas.CreateCanvas2d();
            Console.WriteLine("Canvas happening");
            _ctx.FillStyle = "green";
            _ctx.FillRect(10, 10, 50, 50);
        }
示例#2
0
        protected override void OnAfterRender()
        {
            this._context           = this._canvasReference.CreateCanvas2d();
            this._context.FillStyle = "green";

            this._context.FillRect(10, 100, 100, 100);

            this._context.Font = "48px serif";
            this._context.StrokeText("Hello Blazor!!!", 10, 100);
        }
        private void Draw()
        {
            this._context = this._canvasReference.CreateCanvas2d();
            const double height = 400;
            const double width  = 400;

            Complex   c         = new Complex(-0.1, 0.65);
            Complex   copy      = null;
            const int divider   = 2;
            const int pixelSize = 6; // resolution

            for (double h = -(height / divider); h < (height / divider); h = h + pixelSize)
            {
                for (double w = -(width / divider); w < (width / divider); w = w + pixelSize)
                {
                    var zNum = new Complex(w / (width / divider), h / (height / divider));

                    int i = 0;
                    copy = zNum;
                    do
                    {
                        i++;
                        zNum = zNum.kwadrat().Add(c);
                    } while (zNum.modul2() < 2 && i < 30);
                    int argument = i;
                    do
                    {
                        i++;
                        zNum = zNum.kwadrat().Add(c);
                    } while (zNum.modul2() < 2 && i < argument * 100);

                    if (argument < 30)
                    {
                        this._context.FillStyle = String.Concat("hsl(", argument * 12, ",100%,50%)");
                        this._context.FillRect((copy.getX() + 1) * (width / divider), (copy.getY() + 1) * (height / divider), pixelSize, pixelSize);
                    }
                    if (i > 30)
                    {
                        this._context.FillStyle = String.Concat("hsl(", (i / 6) % 360, ",100%,50%)");
                        this._context.FillRect((copy.getX() + 1) * (width / divider), (copy.getY() + 1) * (height / divider), pixelSize, pixelSize);
                    }
                }
            }
        }
示例#4
0
        public void Frame()
        {
            _ctx = _canvas.CreateCanvas2d();
            Console.WriteLine("Canvas happening");

            if (first)
            {
                scene = new Scene(0, 500, 0, 500, new V(250, 250), new V(250, 0), 1, new Random());
                Console.WriteLine("Made the scene");

                charges = new ChargeSet();
                charges.AdjustCount(10, scene);
                charges.Mutate(1000000, 0, 0, scene);
                Console.WriteLine("Adjusted Count");

                particle = new Particle(scene.start);
                first    = false;
            }

            particle.PassTime(.1, charges);
            _ctx.FillStyle = "red";
            _ctx.FillRect(particle.location.x, particle.location.y, 5, 5);
            Console.WriteLine("Location: " + particle.location.x + " " + particle.location.y);

            foreach (Charge charge in charges.set)
            {
                Console.WriteLine("Draw Charge");
                _ctx.FillStyle = "gray";
                _ctx.FillRect(charge.location.x, charge.location.y, 5, 5);
            }

            if (scene.InBounds(particle.location))
            {
                Console.WriteLine("ping");
                Frame();
            }
        }
示例#5
0
        private const int Ch = 10;     // cell height

        public PlanCanvasDrawing(Canvas2dContext canvasContext, int width, int height)
        {
            _canvasContext = canvasContext;
            _width         = width;
            _height        = height;
        }
示例#6
0
 public void Draw(Canvas2dContext _ctx)
 {
     _ctx.FillStyle = "gray";
 }