Restore() public méthode

public Restore ( ) : void
Résultat void
        /* this.uploadImage = function (sprite) {
        this.width = sprite.width;
        this.height = sprite.height;
        this.offsetX = _H.floor(sprite.width / 2);
        this.offsetY = _H.floor(sprite.height / 2);

        var ca = _H.defaultCanvas(this.width, this.height);

        ca.context.drawImage(sprite, 0, 0);
        var imgd = ca.context.getImageData(0, 0, this.width, this.height);
        var pix = imgd.data;

        var palette = {};
        var paletteLength = 0;

        for (var x = 0; x < this.width; x++) {
            this.colorMap[x] = [];
            for (var y = 0; y < this.height; y++) {
                var pl = _H.colorFromData(pix, (x * 4) + y * this.width * 4);
                var ind = 0;
                if (palette[pl] != undefined) {
                    ind = palette[pl];
                } else {
                    ind = paletteLength;
                    palette[pl] = paletteLength;
                    paletteLength++;
                }
                this.colorMap[x][y] = ind;
            }
        }
        this.palette = [];
        var ind = 0;
        for (var p in palette) {
            this.palette[ind++] = p.replace("#", "");
        }

    };*/

        public void DrawSimple(CanvasRenderingContext2D mainCanvas, Point pos, int width, int height, bool xflip, bool yflip)
        {
            var c = GetCache(false, false, false);

            mainCanvas.Save();
            mainCanvas.Translate(pos.X, pos.Y);
            mainCanvas.Scale(((double)width / Width), ((double)height / Height));

            mainCanvas.DrawImage(c.Canvas, 0, 0);
            mainCanvas.Restore();
        }
        public void DrawUI(CanvasRenderingContext2D _canvas,
                           Point pos,
                           bool showOutline,
                           bool showCollideMap,
                           bool showHurtMap,
                           bool showOffset,
                           bool xflip,
                           bool yflip)
        {
            var fd = GetCache(showOutline, showCollideMap, showHurtMap);



            _canvas.Save();

            _canvas.Translate(pos.X, pos.Y);
            if (xflip)
            {
                if (yflip)
                {
                    _canvas.Translate(fd.Canvas.Width / 2d, fd.Canvas.Height / 2d);
                    _canvas.Rotate(-90 * Math.PI / 180);
                    _canvas.Translate(-fd.Canvas.Width / 2d, -fd.Canvas.Height / 2d);

                    _canvas.Translate(0, Height);
                    _canvas.Scale(1, -1);
                }
                else
                {
                    _canvas.Translate(fd.Canvas.Width / 2d, fd.Canvas.Height / 2d);
                    _canvas.Rotate(-90 * Math.PI / 180);
                    _canvas.Translate(-fd.Canvas.Width / 2d, -fd.Canvas.Height / 2d);
                }
            }
            else
            {
                if (yflip)
                {
                    _canvas.Translate(0, Height);
                    _canvas.Scale(1, -1);
                }
                else { }
            }
            _canvas.DrawImage(fd.Canvas, 0, 0);
            if (showOffset)
            {
                _canvas.BeginPath();
                _canvas.MoveTo(OffsetX, 0);
                _canvas.LineTo(OffsetX, Height);
                _canvas.LineWidth = 1;
                _canvas.StrokeStyle = "#000000";
                _canvas.Stroke();

                _canvas.BeginPath();
                _canvas.MoveTo(0, OffsetY);
                _canvas.LineTo(Width, OffsetY);
                _canvas.LineWidth = 1;
                _canvas.StrokeStyle = "#000000";
                _canvas.Stroke();
            }

            _canvas.Restore();
        }
 private static void drawLoading(CanvasRenderingContext2D canvas)
 {
     canvas.FillStyle = "white";
     canvas.FillText("Loading...   " /*+ (this.inds.tc + this.inds.tp + this.inds.t) + " / " + (this.inds.total)*/, 95, 95);
     canvas.Restore();
     return;
 }
Exemple #4
0
        private static void start()
        {
            canvas = (CanvasElement)Document.GetElementById("canvas");
            context = (CanvasRenderingContext2D)canvas.GetContext(CanvasContextId.Render2D);

            Offset = new Vector2(0, 0);

            Vector2 draggingPos = null;
            canvas.OnMousedown = @event =>
            {
                int mouseX = ((dynamic)@event).pageX;
                int mouseY = ((dynamic)@event).pageY;
                draggingPos = new Vector2(mouseX, mouseY);
            };
            canvas.OnMouseup = @event =>
            {
                /*
                                if (draggingPos == null) return;

                                int mouseX = ((dynamic)@event).pageX;
                                int mouseY = ((dynamic)@event).pageY;

                                draggingPos = new Vector2(draggingPos.X - mouseX, draggingPos.Y - mouseY);

                                Offset = new Vector2(Offset.X + draggingPos.X, Offset.Y + draggingPos.Y);
                                draw();


                */
                draggingPos = null;
            };
            Document.OnMousemove = @event =>
            {
                if (draggingPos == null) return;

                int mouseX = ((dynamic)@event).pageX;
                int mouseY = ((dynamic)@event).pageY;

                Offset = new Vector2(Offset.X + (draggingPos.X - mouseX) * 6, Offset.Y + (draggingPos.Y - mouseY) * 6);

                draggingPos = new Vector2(mouseX, mouseY);
                Draw();
            };



            canvas.Width = Document.Body.ClientWidth - 100;
            canvas.Height = Document.Body.ClientHeight - 100;
            context.Save();
            context.Font = "50px Arial";
            context.FillText("Loading...", canvas.Width / 2, canvas.Height / 2);
            context.Restore();


            Window.OnKeydown = @event =>
            {
                if (((dynamic)@event).keyCode == 17)
                {
                    drawLines = !drawLines;
                }
                Draw();
            };


        
             


            Window.SetTimeout(() =>
            {
                Console.WriteLine("Started");
                Console.Profile();

                Stopwatch sw = new Stopwatch();
                sw.Start();
                tree = new RTree<Player>();
                players = new List<Player>();
                for (int j = 0; j < numberOfPlayers; j++)
                {
                    var player = new Player(nextId());
                    player.X = rand.Next(0, gameSize);
                    player.Y = rand.Next(0, gameSize);
                    players.Add(player);
                    tree.Add(new Rectangle(player.X, player.Y), player);
                }

                buildClusters(viewRadius);

                sw.Stop();
                Console.ProfileEnd();
                Console.WriteLine(string.Format("Time {0}", sw.ElapsedMilliseconds));
                Console.WriteLine("Done");
                Draw();
            });
        }
        public void Draw(CanvasRenderingContext2D canvas, int x, int y, bool showHeightMap)
        {
            if (Dead || ObjectData.Falsey()) return;

            if (ObjectData.PieceLayouts.Count == 0) {
                canvas.DrawImage(ObjectManager.broken,
                                 ( x - ObjectManager.broken.Width / 2 ),
                                 ( y - ObjectManager.broken.Height / 2 ),
                                 ObjectManager.broken.Width,
                                 ObjectManager.broken.Height);
                return;
            }

            MainPieceLayout().Draw(canvas, x, y, ObjectData, this, showHeightMap);
            if (ConsoleLog != null) {
                var gr = GetRect();
                canvas.Save();
                canvas.FillStyle = "rgba(228,228,12,0.4)";
                var wd = 1;
                canvas.FillRect(gr.X - X + x - ( gr.Width / 2 ) - wd,
                                gr.Y - Y + y - ( gr.Height / 2 ) - wd,
                                gr.Width - ( gr.X - X ) + wd * 2,
                                gr.Height - ( gr.Y - Y ) + wd * 2);
                canvas.Restore();
            }
        }
Exemple #6
0
        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;
        }
        public void Draw(CanvasRenderingContext2D canv)
        {
            canv.Save();
            var size = 0;
            canv.StrokeStyle = canv.FillStyle = "white";
            canv.LineWidth = 3;

            canv.Me().dashedRect(Element.TotalX - size,
                                 Element.TotalY - size,
                                 Element.Width + size * 2,
                                 Element.Height + size * 2,
                                 new int[] {2, 2});

            //canv.strokeRect(this.element.totalX() - size, this.element.totalY() - size, this.element.width + size * 2, this.element.height + size * 2);

            var x = Element.TotalX;
            var y = Element.TotalY;
            var w = Element.Width;
            var h = Element.Height;

            foreach (var j in points) {
                canv.FillRect(x + ( w * j.X / 100 ) - j.Size / 2, y + ( h * j.Y / 100 ) - j.Size / 2, j.Size, j.Size);
            }

            canv.Restore();
        }
Exemple #8
0
        public override void Draw(CanvasRenderingContext2D canv)
        {
            if (!Visible) return;

            canv.Save();

            canv.FillStyle = BackColor;

            var width = VisibleItems * ( ItemWidth + JWidth ) - 2;

            canv.FillStyle = BackColor;
            canv.LineWidth = 1;
            canv.StrokeStyle = "#333";
            Help.RoundRect(canv, TotalX, TotalY, VisibleItems * ( ItemWidth + JWidth ) + 2, ItemHeight + ScrollWidth + 6, 3, true, true);

            canv.FillStyle = "grey";
            canv.LineWidth = 1;
            canv.StrokeStyle = "#444";
            canv.FillRect(TotalX + 2, TotalY + ItemHeight + 6, VisibleItems * ( ItemWidth + JWidth ), ScrollWidth);

            canv.FillStyle = "FFDDFF";
            canv.LineWidth = 1;
            canv.StrokeStyle = "#FFDDFF";
            ScrollPosition = width * ScrollOffset / ( Controls.Count - VisibleItems );

            canv.FillRect(TotalX + ( ScrollPosition ) + 2, TotalY + ItemHeight + 6, 5, ScrollWidth - 2);

            var curX = 3;
            for (var i = ScrollOffset; i < Math.Min(Controls.Count, ScrollOffset + VisibleItems); i++) {
                Controls[i].Parent = this;
                Controls[i].X = curX;
                Controls[i].Y = 2;
                Controls[i].Height = ItemHeight;
                Controls[i].Width = ItemWidth;

                curX += ItemWidth + JWidth;
                Controls[i].Draw(canv);
            }

            canv.Restore();
            base.Draw(canv);
        }
        public void DrawUI(CanvasRenderingContext2D canvas, bool showImages, int selectedPieceIndex, LevelObject levelObject)
        {
            canvas.Save();

            if (!showImages)
            {
                canvas.StrokeStyle = "#000000";
                canvas.LineWidth = 2;


                canvas.BeginPath();
                canvas.MoveTo(-1000, 0);
                canvas.LineTo(1000, 0);
                canvas.ClosePath();
                canvas.Stroke();

                canvas.BeginPath();
                canvas.MoveTo(0, -1000);
                canvas.LineTo(0, 1000);
                canvas.ClosePath();
                canvas.Stroke();
                for (var i = 1; i < Pieces.Count; i++)
                {
                    var j = Pieces[i];

                    canvas.BeginPath();
                    canvas.MoveTo(j.X, j.Y);
                    canvas.LineTo(Pieces[i - 1].X, Pieces[i - 1].Y);
                    canvas.Stroke();
                }
            }

            foreach (var levelObjectPieceLayoutPiece in Pieces)
            {
                if (showImages)
                {
                    LevelObjectPiece piece = levelObject.Pieces[levelObjectPieceLayoutPiece.PieceIndex];
                    var asset = levelObject.Assets[piece.AssetIndex];
                    if (asset.Frames.Count > 0)
                    {
                        var frm = asset.Frames[0];
                        frm.DrawUI(canvas,
                                   new Point(levelObjectPieceLayoutPiece.X - frm.OffsetX, levelObjectPieceLayoutPiece.Y - frm.OffsetY),
                                   false,
                                   false,
                                   false,
                                   false,
                                   piece.Xflip,
                                   piece.Yflip);
                    }
                }
                else
                {
                    CanvasGradient drawRadial;

                    drawRadial = SonicManager.Instance.mainCanvas.Context.CreateRadialGradient(0, 0, 0, 10, 10, 50);
                    drawRadial.AddColorStop(0, "white");
                    if (selectedPieceIndex == levelObjectPieceLayoutPiece.PieceIndex)
                        drawRadial.AddColorStop(1, "yellow");
                    else
                        drawRadial.AddColorStop(1, "red");

                    canvas.FillStyle = drawRadial;
                    canvas.BeginPath();
                    canvas.Arc(levelObjectPieceLayoutPiece.X, levelObjectPieceLayoutPiece.Y, 10, 0, Math.PI * 2, true);
                    canvas.ClosePath();
                    canvas.Fill();
                }

            }
            canvas.Restore();
        }
Exemple #10
0
        public void Draw(CanvasRenderingContext2D canvas)
        {
            dragger.Tick();
            canvas.Save();

            foreach (var are in canvasDepths) {
                are.Draw(canvas);
            }

            if (true /*DEBUGs*/) {
                for (var i = 0; i < messages.Count; i++) {
                    canvas.FillText(messages[i], 10, 25 + i * 30);
                }
            }

            canvas.Restore();
        }
        public void DrawAnimationDebug(CanvasRenderingContext2D canvas, Point position, ChunkLayer layer, TileChunkDebugDrawOptions debugDrawOptions )
        {
            if (debugDrawOptions == null) return;
            canvas.Save();
            canvas.FillStyle = "White";
            canvas.TextBaseline = TextBaseline.Top;
            {
                int yOffset = layer == ChunkLayer.Low ? 0 : 64;
                if (debugDrawOptions.ShowBaseData)
                {
                    canvas.FillText("Base", position.X + 0, position.Y + yOffset);
                }

                if (debugDrawOptions.ShowPaletteAnimationData)
                {
                    if (HasPixelAnimations())
                    {
                        var paletteAnimationCanvases = PaletteAnimationCanvasesCache[layer];
                        foreach (var paletteAnimationIndex in GetAllPaletteAnimationIndexes())
                        {
                            var paletteAnimationCanvasFrames = paletteAnimationCanvases[paletteAnimationIndex];
                            if (paletteAnimationCanvasFrames == null) continue;

                            var currentFrame = SonicManager.Instance.TilePaletteAnimationManager.GetCurrentFrame(paletteAnimationIndex);

                            canvas.FillText("Palette " + paletteAnimationIndex + "-" + currentFrame.FrameIndex, position.X + 25, position.Y + yOffset + (paletteAnimationIndex*13));
                        }
                    }
                }
                if (debugDrawOptions.ShowTileAnimationData)
                {
                    if (HasTileAnimations())
                    {
                        var tileAnimationCanvases = TileAnimationCanvasesCache[layer];
                        foreach (var tileAnimationIndex in GetAllTileAnimationIndexes())
                        {
                            var tileAnimationCanvasFrames = tileAnimationCanvases[tileAnimationIndex];
                            if (tileAnimationCanvasFrames == null) continue;

                            var currentFrame = SonicManager.Instance.TileAnimationManager.GetCurrentFrame(tileAnimationIndex);
                            canvas.FillText("Tile " + tileAnimationIndex + "-" + currentFrame.FrameIndex, position.X + 75, position.Y + yOffset + (tileAnimationIndex*13));
                        }
                    }
                }
            }
            if (debugDrawOptions.OutlineChunk)
            {
                canvas.StrokeStyle = "black";
                canvas.StrokeRect(position.X, position.Y, 128, 128);
            }

            if (debugDrawOptions.OutlineTiles)
            {
                canvas.StrokeStyle = "green";
                for (int x = 0; x < TileSideLength; x++)
                {
                    for (int y = 0; y < TileSideLength; y++)
                    {
                        canvas.StrokeRect(position.X + (x * TileSquareSize), position.Y + (y * TileSquareSize), TileSquareSize, TileSquareSize);
                    }
                }
            }
            if (debugDrawOptions.OutlineTilePieces)
            {
                canvas.StrokeStyle = "purple";
                for (int x = 0; x < TilePieceSideLength; x++)
                {
                    for (int y = 0; y < TilePieceSideLength; y++)
                    {
                        canvas.StrokeRect(position.X + (x * TilePiecesSquareSize), position.Y + (y * TilePiecesSquareSize), TilePiecesSquareSize, TilePiecesSquareSize);
                    }
                }
            }
            if (debugDrawOptions.OutlineTile != null)
            {
                /*
                                canvas.StrokeStyle = "yellow";
                                for (int x = 0; x < TileSideLength; x++)
                                {
                                    for (int y = 0; y < TileSideLength; y++)
                                    {
                                        var tilePieceInfo = this.GetTilePiece(x, y);
                                        if (tilePieceInfo == null) continue;
                                        var tilePiece = tilePieceInfo.GetTilePiece();
                                        if (tilePiece == null) continue;

                        

                                        if (tilePiece == debugDrawOptions.OutlineTilePiece)
                                        {
                                            canvas.StrokeRect(position.X + (x * TileSquareSize), position.Y + (y * TileSquareSize), TileSquareSize, TileSquareSize);
                                        }
                                    }
                                }
                */
            }
            
            if (debugDrawOptions.OutlineTilePiece != null)
            {
                canvas.StrokeStyle = "yellow";
                for (int x = 0; x < TilePieceSideLength; x++)
                {
                    for (int y = 0; y < TilePieceSideLength; y++)
                    {
                        var tilePieceInfo = this.GetTilePieceInfo(x, y,false);
                        if (tilePieceInfo == null) continue;
                        var tilePiece = tilePieceInfo.GetTilePiece();
                        if (tilePiece == null) continue;
                        if (tilePiece.Index == debugDrawOptions.OutlineTilePiece.Block)
                        {
                            canvas.StrokeRect(position.X + (x * TilePiecesSquareSize), position.Y + (y * TilePiecesSquareSize), TilePiecesSquareSize, TilePiecesSquareSize);
                        }
                    }
                }
            }
            canvas.Restore();
        }
Exemple #12
0
        public override void Draw(CanvasRenderingContext2D canv)
        {
            if (!Visible) return;
            canv.Save();
            if (!Focused) {
                CursorPosition = -1;
                DragPosition = -1;
            }
            DrawTicks++;
            can = canv;

            canv.StrokeStyle = ButtonBorderGrad;
            canv.FillStyle = Clicking ? Button1Grad : Button2Grad;
            canv.LineWidth = 2;
            Help.RoundRect(canv, TotalX, TotalY, Width, Height, 2, true, true);
            if (canv.Font != Font)
                canv.Font = Font;

            if (DragPosition != -1) {
                canv.FillStyle = "#598AFF";

                var w1 = canv.MeasureText(Text.Substring(0, Math.Min(DragPosition, CursorPosition))).Width;
                var w2 = canv.MeasureText(Text.Substring(0, Math.Max(DragPosition, CursorPosition))).Width;
                canv.FillRect(TotalX + 8 + w1,
                              TotalY + 3,
                              w2 - w1,
                              ( Height - 7 ));
            }
            canv.FillStyle = "#000000";

            int hc;
            if (canv.Font.IndexOf("pt") != -1)
                hc = int.Parse(canv.Font.Substr(0, canv.Font.IndexOf("pt")));
            else
                hc = int.Parse(canv.Font.Substr(0, canv.Font.IndexOf("px")));
            canv.FillText(Text, TotalX + 8, TotalY + ( ( Height - hc ) / 2 ) + Height / 2);

            if (Focused && ( ( blinkTick++ % 35 ) == 0 ))
                blinked = !blinked;
            if (Focused && blinked) {
                canv.StrokeStyle = "#000000";
                var w = canv.MeasureText(Text.Substring(0, CursorPosition)).Width;
                canv.BeginPath();
                canv.MoveTo(TotalX + 8 + w, TotalY + 3);
                canv.LineTo(TotalX + 8 + w, TotalY + ( Height - 7 ));
                canv.LineWidth = 2;
                canv.Stroke();
            }
            canv.Restore();

            base.Draw(canv);
        }
Exemple #13
0
        public void DrawUI(CanvasRenderingContext2D canvas, Point pos)
        {
            canvas.Save();
            {
                if (canvas.Font != "13pt Arial bold")
                    canvas.Font = "13pt Arial bold";
                canvas.FillStyle = "White";
                canvas.FillText("Rings: " + Rings, pos.X + 90, pos.Y + 45);
                canvas.FillText("Angle: " + Angle.ToString(16), pos.X + 90, pos.Y + 75);
                canvas.FillText("Position: " + ( X ) + ", " + ( Y ), pos.X + 90, pos.Y + 105);
                canvas.FillText("Speed: g: " + Gsp.ToFixed(3) + " x:" + Xsp.ToFixed(3) + " y:" + Ysp.ToFixed(3), pos.X + 90, pos.Y + 135);
                canvas.FillText("Mode: " + Mode.ToString(), pos.X + 90, pos.Y + 165);
                canvas.FillText("Multiplier: " + Watcher.mult, pos.X + 90, pos.Y + 195);
//                canvas.FillText("RealScale: " + SonicManager.Instance.RealScale.String(), pos.X + 90, pos.Y + 225);
                if (InAir)
                    canvas.FillText("Air ", pos.X + 220, pos.Y + 45);
                if (HLock > 0)
                    canvas.FillText("HLock: " + HLock, pos.X + 90, pos.Y + 195);
            }
            canvas.Restore();
        }
Exemple #14
0
        public void Draw(CanvasRenderingContext2D canvas)
        {
            var fx = ( X );
            var fy = ( Y );

            if (Invulnerable()) return;
            var cur = SonicManager.Instance.SpriteCache.SonicSprites[SpriteState];
            if (cur == null) {}

            if (cur.Loaded()) {
                canvas.Save();
                var offset = GetOffsetFromImage();
                canvas.Translate(( fx - SonicManager.Instance.WindowLocation.X + offset.X ),
                                 ( ( fy - SonicManager.Instance.WindowLocation.Y + offset.Y ) ));
                if (SonicManager.Instance.ShowHeightMap) {
                    canvas.Save();
                    var mul = 6;
                    var xj = Xsp * mul;
                    var yj = Ysp * mul;
                    canvas.BeginPath();
                    canvas.MoveTo(0, 0);
                    canvas.LineTo(xj, yj);
                    canvas.FillStyle = "rgba(163,241,255,0.8)";
                    canvas.Arc(xj, yj, 5, 0, 2 * Math.PI, true);
                    canvas.ClosePath();

                    canvas.LineWidth = 6;
                    canvas.StrokeStyle = "white"; //6C6CFC
                    canvas.Stroke();
                    canvas.LineWidth = 3;
                    canvas.StrokeStyle = "#2448D8"; //6C6CFC
                    canvas.Fill();
                    canvas.Stroke();
                    canvas.Restore();
                }

                if (!Facing) {
                    //canvas.translate(cur.width, 0);
                    canvas.Scale(-1, 1);
                    if (!CurrentlyBall && !SpinDash)
                        canvas.Rotate(-Help.FixAngle(Angle));

                    canvas.DrawImage(cur, -cur.Width / 2, -cur.Height / 2);

                    if (SpinDash) {
                        canvas.DrawImage(
                                SonicManager.Instance.SpriteCache.SonicSprites[
                                        ( "spinsmoke" + ( SonicManager.Instance.DrawTickCount % 14 ) / 2 )],
                                ( -cur.Width / 2 ) - 25,
                                -cur.Height / 2 + ( offset.Y ) - 14,
                                cur.Width,
                                cur.Height);
                    }
                } else {
                    if (!CurrentlyBall && !SpinDash)
                        canvas.Rotate(Help.FixAngle(Angle));
                    canvas.DrawImage(cur, -cur.Width / 2, -cur.Height / 2);

                    if (SpinDash) {
                        canvas.DrawImage(
                                SonicManager.Instance.SpriteCache.SonicSprites[
                                        ( "spinsmoke" + ( SonicManager.Instance.DrawTickCount % 14 ) / 2 )],
                                ( -cur.Width / 2 ) - 25,
                                -cur.Height / 2 + ( offset.Y ) - 14,
                                cur.Width,
                                cur.Height);
                    }
                }

                /*
               canvas.moveTo(-10 * scale.x, 4 * scale.y);
               canvas.lineTo(10 * scale.x, 4 * scale.y);
               canvas.lineWidth = 3;
               canvas.strokeStyle = "#FFF";
               canvas.stroke();

               canvas.moveTo(-9 * scale.x, 0 * scale.y);
               canvas.lineTo(-9 * scale.x, 20 * scale.y);
               canvas.lineWidth = 3;
               canvas.strokeStyle = "#FFF";
               canvas.stroke();

               canvas.moveTo(9 * scale.x, 0 * scale.y);
               canvas.lineTo(9 * scale.x, 20 * scale.y);
               canvas.lineWidth = 3;
               canvas.strokeStyle = "#FFF";
               canvas.stroke();*/

                /*
                canvas.strokeStyle = "#FFF";
                canvas.lineWidth = 4;
                canvas.strokeRect(-cur.width / 2, -cur.height / 2, cur.width, cur.height);
                */
                canvas.Restore();
                if (SonicManager.Instance.ShowHeightMap)
                    SensorManager.Draw(canvas, this);
                for (var i = 0; i < HaltSmoke.Count; i++) {
                    var lo = HaltSmoke[i];
                    canvas.DrawImage(
                            SonicManager.Instance.SpriteCache.SonicSprites[
                                    ( "haltsmoke" + ( SonicManager.Instance.DrawTickCount % ( 4 * 6 ) ) / 6 )],
                            ( ( lo.X - SonicManager.Instance.WindowLocation.X - 25 ) ),
                            ( ( lo.Y + 12 - SonicManager.Instance.WindowLocation.Y + offset.Y ) ));
                    if (( ( SonicManager.Instance.DrawTickCount + 6 ) % ( 4 * 6 ) ) / 6 == 0)
                        HaltSmoke = HaltSmoke.Extract(i, 1);
                }
            }
        }
Exemple #15
0
        public override void Draw(CanvasRenderingContext2D canv)
        {
            base.Draw(canv);

            if (!Visible) return;
            if (Palette == null) return;

            canv.Save();

            canv.StrokeStyle = "#000";
            canv.LineWidth = 2;
            var pos = new Point(TotalX, TotalY);
            var f = (int)Math.Round(Palette.Length / 2.0);

            if (Wide) {
                for (var h = 0; h < 2; h++) {
                    for (var w = 0; w < f; w++) {
                        canv.FillStyle = Palette[w + h * f];
                        canv.FillRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y);
                        canv.StrokeRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y);
                    }
                }
                if (ShowCurrent) {
                    canv.FillStyle = Palette[SelectedIndex];
                    canv.FillRect(pos.X + f * Scale.X , pos.Y, Scale.X * 2, Scale.Y * 2);
                    canv.StrokeRect(pos.X + f * Scale.X , pos.Y, Scale.X * 2, Scale.Y * 2);
                }
            } else {
                for (var h = 0; h < f; h++) {
                    for (var w = 0; w < 2; w++) {
                        canv.FillStyle = Palette[w + h * 2];
                        canv.FillRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y);
                        canv.StrokeRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y);
                    }
                }
                if (ShowCurrent) {
                    canv.FillStyle = Palette[SelectedIndex];
                    canv.FillRect(pos.X, pos.Y + f * Scale.Y , Scale.X * 2, Scale.Y * 2);
                    canv.StrokeRect(pos.X, pos.Y + f * Scale.Y , Scale.X * 2, Scale.Y * 2);
                }
            }

            canv.Restore();
        }