Exemple #1
0
        public override void Render(Canvas2D canvas)
        {
            base.Render(canvas);


            if (CurrentSpriteSheet != null)
            {
                using (canvas <= Camera.Transformation)
                {
                    Rect boundingRect = Rect.FromBox(CurrentSpriteSheet.BoundingRect.LeftTop.Floored,
                                                     new Vector2(CurrentSpriteSheet.BoundingRect.Width,
                                                                 CurrentSpriteSheet.BoundingRect.Height));
                    canvas.DrawRect(boundingRect, new LineStyle(2f, LineStroke.Solid), ColorU.Red);

                    canvas.DrawSprite(Vector2.Zero, 0f, CurrentSpriteSheet.Texture.ToSprite(), ColorU.White);


                    foreach (SpriteSheetFrame frame in CurrentSpriteSheet.Frames)
                    {
                        ColorU color;


                        if (frame.Highlighted && !frame.Selected)
                        {
                            color = Configuration.HoverFrameRectColor;
                        }
                        else if (frame.Selected)
                        {
                            color = Configuration.SelectedFrameRectColor;
                        }
                        else
                        {
                            color = Configuration.FrameRectColor;
                        }

                        Rect frameBoundingRect = frame.RelativeBoundingRect;
                        canvas.DrawRect(frameBoundingRect, new LineStyle(2f, LineStroke.Solid), color);
                    }

                    _stateHandler.Draw(canvas);


                    //if (GridEnabled && Camera.Zoom > 4f)
                    //{
                    //    Point start = Camera.ScreenToWorld(Vector2.Zero).ToPoint();

                    //    for (int i = start.X; i < RenderRegion.Width; i++)
                    //    {
                    //        canvas.DrawLine(i, start.Y, i, RenderRegion.Height, ColorU.Gray.MultiplyAlpha(0.5f));
                    //    }
                    //    for (int i = start.Y; i < RenderRegion.Height; i++)
                    //    {
                    //        canvas.DrawLine(start.X, i, RenderRegion.Width, i, ColorU.Gray.MultiplyAlpha(0.5f));
                    //    }
                    //}
                }
            }

            guiManager.DrawControls(canvas);
        }
Exemple #2
0
 public override void OnDraw(Canvas2D canvas)
 {
     if (SelectRect.Width > 0 && SelectRect.Height > 0)
     {
         canvas.DrawRect(SelectRect, new LineStyle(2f, LineStroke.Dashed), ColorU.Orange);
     }
 }
Exemple #3
0
        public override void Render(Canvas2D canvas)
        {
            base.Render(canvas);

            if (CurrentAnimation != null && CurrentAnimation.Frames.Count > 0)
            {
                canvas.DrawText(Font, Vector2.Zero,
                                string.Format("Frame: {0}/{1} | Offset: {2};{3} | Origin:{4};{5}",
                                              CurrentAnimation.CurrentFrameIndex + 1, CurrentAnimation.Frames.Count,
                                              CurrentAnimation.CurrentFrame.OffSetX,
                                              CurrentAnimation.CurrentFrame.OffSetY,
                                              (int)CurrentAnimation.CurrentFrame.OriginX,
                                              (int)CurrentAnimation.CurrentFrame.OriginY), ColorU.White);
                using (canvas <= Camera.Transformation)
                {
                    CurrentAnimation.Draw(canvas);
                    if (_drawFrameDebug && CurrentAnimation.Frames.Count > 0)
                    {
                        Frame curFrame = CurrentAnimation.CurrentFrame;
                        canvas.DrawRect(
                            Rect.FromBox(curFrame.OffSetX - curFrame.SpriteFrame.Width / 2f,
                                         curFrame.OffSetY - curFrame.SpriteFrame.Height / 2, curFrame.SpriteFrame.Width,
                                         curFrame.SpriteFrame.Height), ColorU.Red);
                        canvas.DrawLine(-5, 0, 5, 0, _originMarkLineStyle, ColorU.GreenYellow);
                        canvas.DrawLine(0, -5, 0, 5, _originMarkLineStyle, ColorU.GreenYellow);
                    }
                }
            }

            guiManager.DrawControls(canvas);
        }
Exemple #4
0
            public void Draw(Canvas2D canvas, SpriteFont font)
            {
                var drawRect = new Rect(new PointF(X, Y), Size);

                ColorU color;

                if (Highlighted && !Selected)
                {
                    color = ColorU.Red;
                }
                else if (Selected)
                {
                    color = ColorU.Yellow;
                }
                else
                {
                    color = ColorU.WhiteSmoke;
                }

                //-------------------EXTERNAL-BORDER------------------------------------------------------------
                canvas.DrawRect(drawRect.Left - LineStyleExternalRect.Width,
                                drawRect.Top - LineStyleExternalRect.Width,
                                drawRect.Width + LineStyleExternalRect.Width * 2,
                                drawRect.Height + LineStyleExternalRect.Width * 2,
                                LineStyleExternalRect,
                                color);

                //------------------INTERNAL-BORDER-------------------------------------------------------------
                canvas.DrawRect(drawRect, LineStyleInternalRect, ColorU.Black);

                //------------------BACKGROUND------------------------------------------------------------------
                canvas.DrawFilledRect(drawRect, ColorU.Black.MultiplyAlpha(0.5f));


                var frameLabelRect = new Rect(new PointF(drawRect.Left,
                                                         drawRect.Top + drawRect.Height + LineStyleExternalRect.Width +
                                                         LineStyleInternalRect.Width), new SizeF(drawRect.Width, 20f));

                //------------------LABEL------------------------------------------------------------------------
                canvas.DrawFilledRect(frameLabelRect, ColorU.Black.MultiplyAlpha(0.5f));


                //------------------SPRITE-----------------------------------------------------------------------
                if (Frame != null)
                {
                    //using (canvas[0] <= new SamplerState(Configuration.TextureFilterMode, ColorU.White))
                    //{
                    canvas.DrawText(font, new Vector2(frameLabelRect.Left + 5f, frameLabelRect.Top),
                                    string.Format("{0}", Frame.Num), ColorU.AliceBlue);
                    canvas.DrawText(font, new Vector2(frameLabelRect.Left + 30f, frameLabelRect.Top),
                                    string.Format("FrameRate: {0}", 1f / Frame.FrameDuration), ColorU.Red);
                    if (!Dragged)
                    {
                        canvas.DrawSprite(drawRect.CenterX, drawRect.CenterY, Frame.SpriteFrame.Width * Scale.X,
                                          Frame.SpriteFrame.Height * Scale.Y, Frame.SpriteFrame.Sprite, ColorU.White);
                    }
                    else
                    {
                        canvas.DrawSprite(FrameDrawPos.X, FrameDrawPos.Y, Frame.SpriteFrame.Width * Scale.X,
                                          Frame.SpriteFrame.Height * Scale.Y, Frame.SpriteFrame.Sprite,
                                          ColorU.White);
                    }

                    //}
                }
            }
Exemple #5
0
 public override void OnDraw(Canvas2D canvas)
 {
     canvas.DrawRect(_frameRect, new LineStyle(2f, LineStroke.Solid), ColorU.Red);
 }
Exemple #6
0
 public override void OnDraw(Canvas2D canvas)
 {
     canvas.DrawRect(SelectRect, new LineStyle(2f, LineStroke.Dashed), ColorU.Blue);
 }