Example #1
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);
        }
Example #2
0
        public override void DrawForeground(Canvas2D canvas)
        {
            canvas.DrawText(GameFont.Default, new Vector2(20, 20), "Hello", Color.Yellow);

            using (canvas <= new Translation(250, 100) <= new Rotation(delta))
            {

                canvas.DrawLine(new Vector2(0, 0), new Vector2(100, 0), new LineStyle(2, LineStroke.Smooth), Color.Blue);
            }

            using (canvas <= new Translation(500, 100) <= new Rotation(delta))
            {
                canvas.DrawFilledRect(new Rect(-100, -100, 100, 100), Color.Yellow);
                //canvas.DrawRect(new Rect(0, 0, 100, 100), new LineStyle(1), Color.Yellow);

            }
        }
Example #3
0
        public override void Draw(Canvas2D canvas)
        {
            canvas.DrawFrame(AbsoluteBoundingRect, Frames[State], FrameBorder,
                             true, Color);

            if (_drawOverlay)
            {
                canvas.DrawSprite(AbsoluteBoundingRect, Overlay, ColorU.White);
            }

            var textSize = Canvas2D.MeasureText(Font, Text);

            Vector2 textDrawPos = new Vector2(AbsoluteBoundingRect.CenterX - textSize.X / 2,
                                              AbsoluteBoundingRect.CenterY - textSize.Y / 2);

            canvas.DrawText(Font, textDrawPos.Floored, Text, TextColor);


            base.Draw(canvas);
        }
Example #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);
                    }

                    //}
                }
            }
Example #5
0
 public override void DrawWindowTitle(Canvas2D canvas, float x, float y, float w, float h, string title)
 {
     canvas.SetSolidFill(Color.White);
     canvas.DrawText(x + 12, y + 12, w - 12, h - 12, SD.SystemFonts.CaptionFont, title);
 }