OurSonic.Level.HeightMap.Draw C# (CSharp) Method

Draw() public method

public Draw ( CanvasRenderingContext2D canvas, Point pos, bool xflip, bool yflip, int solid, int angle ) : void
canvas System.Html.Media.Graphics.CanvasRenderingContext2D
pos Point
xflip bool
yflip bool
solid int
angle int
return void
        public void Draw(CanvasRenderingContext2D canvas, Point pos, bool xflip, bool yflip, int solid, int angle)
        {
            if (Items == null) return;
            canvas.Save();

            var oPos = new Point(pos);
            if (xflip) {
                pos.X = -pos.X - 16;
                canvas.Scale(-1, 1);
            }
            if (yflip) {
                pos.Y = -pos.Y - 16;
                canvas.Scale(1, -1);
            }
            var fd = SonicManager.Instance.SpriteCache.HeightMaps[Index + ( solid << 20 )];
            if (Index != -1 && fd.Truthy())
                canvas.DrawImage(fd.Canvas, pos.X, pos.Y);
            else {
                var ntcanvas = CanvasInformation.Create(16, 16, false);
                var ncanvas = ntcanvas.Context;

                if (solid > 0) {
                    for (int x = 0; x < 16; x++) {
                        for (int y = 0; y < 16; y++) {
                            var jx = 0;
                            var jy = 0;
                            if (ItemsGood(Items, x, y)) {
                                jx = x;
                                jy = y;
                                var _x = jx;
                                var _y = jy;
                                ncanvas.LineWidth = 1;
                                ncanvas.FillStyle = colors[solid];
                                ncanvas.FillRect(_x, _y, 1, 1);
                                if (angle != 255) {
                                    ncanvas.BeginPath();
                                    ncanvas.LineWidth = 1;
                                    ncanvas.StrokeStyle = "rgba(163,241,255,0.8)";
                                    ncanvas.MoveTo(16 / 2, 16 / 2);
                                    ncanvas.LineTo(16 / 2 - Help.Sin(angle) * 8, 16 / 2 - Help.Cos(angle) * 8);
                                    ncanvas.Stroke();
                                    /*ncanvas.BeginPath();
                                    ncanvas.FillStyle = "rgba(163,241,255,0.8)";
                                    ncanvas.Arc(16 / 2 - Help.Sin(angle) * 8,16 / 2 - Help.Cos(angle) * 8,5,0,2 * Math.PI,true);
                                    ncanvas.Fill();*/
                                }
/*
                                canvas.LineWidth = 1;
                                canvas.StrokeStyle = "#000000";
                                canvas.StrokeRect(pos.X, pos.Y, scale.X * 16, scale.Y * 16);
*/
                            }
                        }
                    }
                }
                SonicManager.Instance.SpriteCache.HeightMaps[Index + ( solid << 20 )] = ntcanvas;

                canvas.DrawImage(ntcanvas.Canvas, pos.X, pos.Y);
            }
            canvas.Restore();
            pos.X = oPos.X;
            pos.Y = oPos.Y;
        }