コード例 #1
0
        /// <summary>
        /// Draws a bar for the Character's SP.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="percent">The percent of the SP being drawn.</param>
        /// <param name="index">The 0-based index of the bar being drawn.</param>
        /// <param name="color">The color to draw the bar.</param>
        protected virtual void DrawSPBar(ISpriteBatch sb, byte percent, byte index, Color color)
        {
            const float spBarWidth  = 40;
            const float spBarHeight = 4;
            const int   padding     = 5;

            var pos = DrawPosition + new Vector2((Size.X / 2f) - (spBarWidth / 2f), Size.Y + (spBarHeight * index) + padding).Round();

            var border = new Rectangle(pos.X, pos.Y, spBarWidth, spBarHeight);
            var bar    = border;

            bar.Width = (int)((spBarWidth * (percent / 100.0f))).Clamp(0.0f, spBarWidth);

            RenderRectangle.Draw(sb, border, new Color(0, 0, 0, 0), Color.Black);
            RenderRectangle.Draw(sb, bar, color);
        }
コード例 #2
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap)
        {
            base.HandleBeforeDrawMapGUI(spriteBatch, imap);

            var map = imap as EditorMap;

            if (map == null)
            {
                return;
            }

            var camera = map.Camera;

            if (camera == null)
            {
                return;
            }

            // Only draw for the map under the cursor
            if (map != _mouseOverMap)
            {
                return;
            }

            if (IsSelecting)
            {
                // Draw the selection area
                var a = camera.ToScreen(_selectionStart);
                var b = camera.ToScreen(_selectionEnd);

                if (a.QuickDistance(b) > _minSelectionAreaDrawSize)
                {
                    var rect = Rectangle.FromPoints(a, b);
                    RenderRectangle.Draw(spriteBatch, rect, _selectionAreaColorInner, _selectionAreaColorOuter);
                }
            }
            else
            {
                // Draw the tooltip
                var font = ToolTipFont;
                if (_toolTipObject != null && _toolTip != null && font != null)
                {
                    spriteBatch.DrawStringShaded(font, _toolTip, _toolTipPos, Color.White, Color.Black);
                }
            }
        }
コード例 #3
0
ファイル: QuickBarForm.cs プロジェクト: wtfcolt/game
            /// <summary>
            /// Draws the quick bar item.
            /// </summary>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="position">The position to draw the item at. If null, the item will be
            /// drawn in the center of the quick bar slot.</param>
            /// <param name="color">The color.</param>
            void DrawQuickBarItem(ISpriteBatch spriteBatch, Vector2?position, Color color)
            {
                var isOnBar = (position == null);

                // Draw the item in the quick bar
                switch (QuickBarItemType)
                {
                case QuickBarItemType.Inventory:
                    var item = QuickBarForm._gps.UserInfo.Inventory[(InventorySlot)QuickBarItemValue];
                    if (item == null)
                    {
                        break;
                    }

                    if (position == null)
                    {
                        position = CenterOnSlot(item.Grh);
                    }

                    item.Draw(spriteBatch, position.Value, color);
                    break;

                case QuickBarItemType.Skill:
                    if (_skillInfo == null)
                    {
                        break;
                    }

                    if (position == null)
                    {
                        position = CenterOnSlot(_grh);
                    }

                    _grh.Draw(spriteBatch, position.Value);

                    if (isOnBar && CooldownManager.IsCoolingDown(_skillInfo.CooldownGroup, TickCount.Now))
                    {
                        RenderRectangle.Draw(spriteBatch, GetScreenArea(), new Color(0, 0, 0, 150));
                    }

                    break;
                }
            }
コード例 #4
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
            {
                return;
            }

            if (MapSpawns == null)
            {
                return;
            }

            foreach (var item in MapSpawns)
            {
                var rect = item.SpawnArea.ToRectangle(map);
                if (e.Camera.InView(rect))
                {
                    RenderRectangle.Draw(e.SpriteBatch, rect, _drawColor);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Draws the <see cref="Control"/>.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
        protected override void DrawControl(ISpriteBatch spriteBatch)
        {
            base.DrawControl(spriteBatch);

            // Draw the progress bar
            float elapsedTime  = TickCount.Now - _castStartTime;
            var   percent      = elapsedTime / _currentCastTime;
            var   startDrawPos = ScreenPosition + new Vector2(Border.LeftWidth, Border.TopHeight);
            var   drawWidth    = ClientSize.X * Math.Min(percent, 1);
            var   r            = new Rectangle(startDrawPos.X, startDrawPos.Y, drawWidth, ClientSize.Y);

            RenderRectangle.Draw(spriteBatch, r, new Color(255, 0, 0, 200));

            // Draw the name
            spriteBatch.DrawStringShaded(Font, Text, Position + _textOffset, ForeColor, Color.Black);

            // Stop drawing if we hit 100%
            if (percent >= 1.00f)
            {
                StopCasting();
            }
        }
コード例 #6
0
ファイル: Designer.Line.cs プロジェクト: OkashiKami/Odyssey
        void CreatePolyLine(IEnumerable <Vector2> points, float lineWidth, RenderRectangle callback)
        {
            Contract.Requires <ArgumentNullException>(points != null, "points");
            Vector2[] pointArray = points as Vector2[] ?? points.ToArray();
            if (pointArray.Length < 2)
            {
                throw new InvalidOperationException("At least two points are required");
            }

            for (int i = 0; i < pointArray.Length - 1; i++)
            {
                Vector2 p0xy = pointArray[i];
                Vector2 p1xy = pointArray[i + 1];
                Vector3 p0   = new Vector3(p0xy, 0);
                Vector3 p1   = new Vector3(p1xy, 0);
                float   d    = Vector3.Distance(p0, p1);

                float xDiff = p1.X - p0.X;
                float yDiff = p1.Y - p0.Y;
                float angle;

                if (MathHelper.IsCloseToZero(xDiff))
                {
                    angle = 0;
                }
                else
                {
                    angle = (float)Math.Atan2(yDiff, xDiff) - MathHelper.PiOverTwo;
                }

                Matrix previousTransform = Transform;
                Transform = Matrix.RotationYawPitchRoll(0, 0, angle) * Matrix.Translation(p0) * Transform;
                callback(new RectangleF(-lineWidth / 2, 0, lineWidth, d));
                Transform = previousTransform;
            }
        }
コード例 #7
0
        /// <summary>
        /// When overridden in the derived class, draws the graphics to the control.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        protected override void HandleDraw(TickCount currentTime)
        {
            base.HandleDraw(currentTime);

            if (DesignMode)
            {
                return;
            }

            if (_drawingManager.RenderWindow == null)
            {
                return;
            }

            if (Grh == null)
            {
                return;
            }

            Grh.Update(currentTime);

            m.Update(currentTime);

            _drawingManager.Update(currentTime);

            var sb = _drawingManager.BeginDrawWorld(_camera);

            if (sb == null)
            {
                return;
            }

            // Change the view
            var oldView = RenderWindow.GetView();

            _drawView.Reset(new FloatRect(Camera.Min.X, Camera.Min.Y, Camera.Size.X, Camera.Size.Y));
            RenderWindow.SetView(_drawView);

            try
            {
                try
                {
                    Grh.Draw(sb, Vector2.Zero, Color.White);
                }
                catch (LoadingFailedException)
                {
                    // A LoadingFailedException is generally fine here since it probably means the graphic file was invalid
                    // or does not exist
                }

                // Draw the walls
                if (Walls != null)
                {
                    foreach (var wall in Walls)
                    {
                        var rect = wall.ToRectangle();
                        RenderRectangle.Draw(sb, rect, _autoWallColor);
                    }
                }

                m.Draw(sb, Camera);
            }
            finally
            {
                _drawingManager.EndDrawWorld();

                // Restore the view
                RenderWindow.SetView(oldView);
            }
        }
コード例 #8
0
        /// <summary>
        /// When overridden in the derived class, draws the graphics to the control.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        protected override void HandleDraw(TickCount currentTime)
        {
            if (DesignMode)
            {
                base.HandleDraw(currentTime);
                return;
            }

            TransBoxManager.Update(currentTime);

            RenderWindow.Clear(Color.Black);

            // Update the cursor display for the transformation box. Only change the cursor if we are currently
            // under a transbox, or we have just stopped being under one. If we update it every frame, it screws with the
            // UI display for everything else (like when the cursor is over a textbox).
            var transBoxCursor = TransBoxManager.CurrentCursor;

            if (transBoxCursor == null)
            {
                if (_wasUnderTransBox)
                {
                    Cursor            = Cursors.Default;
                    _wasUnderTransBox = false;
                }
            }
            else
            {
                Cursor            = transBoxCursor;
                _wasUnderTransBox = true;
            }


            // TODO: Implement drawing logic
            // Do some actual work here

            _spriteBatch.Begin(BlendMode.Alpha, _camera);


            if (TilesetConfiguration != null)
            {
                int x = 0;
                int y = 0;

                for (int i = 0; i < TilesetConfiguration.GrhDatas.Count; i++)
                {
                    var grh  = TilesetConfiguration.GrhDatas[i];
                    Grh nGrh = new Grh(grh);

                    nGrh.Draw(_spriteBatch, new Vector2(y * EditorSettings.Default.GridSize.X, x * EditorSettings.Default.GridSize.Y));

                    y++;

                    if (y % TilesetConfiguration.Width == 0)
                    {
                        x++;
                        y = 0;
                    }
                }

                // Draw little selection box
                RenderRectangle.Draw(_spriteBatch, new Rectangle(grhX, grhY, EditorSettings.Default.GridSize.X, EditorSettings.Default.GridSize.Y), Color.TransparentWhite, Color.White, -3f);
            }


            _spriteBatch.End();

            int deltaTime;

            if (_lastUpdateTime == TickCount.MinValue)
            {
                deltaTime = 30;
            }
            else
            {
                deltaTime = Math.Max(5, (int)(currentTime - _lastUpdateTime));
            }

            _lastUpdateTime = currentTime;

            _camera.Min += _cameraVelocity * (deltaTime / 1000f);
        }
コード例 #9
0
 /// <summary>
 /// Draws the selection region a selected item.
 /// </summary>
 /// <param name="sb">The <see cref="ISpriteBatch"/>.</param>
 /// <param name="area">The area to draw the selection.</param>
 protected virtual void DrawSelectionRegion(ISpriteBatch sb, Rectangle area)
 {
     RenderRectangle.Draw(sb, area, new Color(100, 100, 255, 150));
 }
コード例 #10
0
    private void InvalidateTextRegion(RenderRectangle rect)
    {
        if (rect.Width != 0 || rect.Height != 0)
        {
            int x1 = 0;
            int y1 = 0;
            int x2 = 0;
            int y2 = 0;

            // upper y
            if (rect.Y < this.invalidated.Y)
            {
                y1 = rect.Y;
            }
            else
            {
                y1 = this.invalidated.Y;
            }

            // lower y
            if ((rect.Y + rect.Height) > (this.invalidated.Y + this.invalidated.Height))
            {
                y2 = rect.Y + rect.Height;
            }
            else
            {
                y2 = this.invalidated.Y + this.invalidated.Height;
            }

            // left x
            if (rect.X < this.invalidated.X)
            {
                x1 = rect.X;
            }
            else
            {
                x1 = this.invalidated.X;
            }

            // right x
            if ((rect.X + rect.Width) > (this.invalidated.X + this.invalidated.Width))
            {
                x2 = rect.X + rect.Width;
            }
            else
            {
                x2 = this.invalidated.X + this.invalidated.Width;
            }

            this.invalidated.X      = x1;
            this.invalidated.Y      = y1;
            this.invalidated.Width  = x2 - x2;
            this.invalidated.Height = y2 - y1;
        }
        else
        {
            this.invalidated.X      = rect.X;
            this.invalidated.Y      = rect.Y;
            this.invalidated.Width  = rect.Width;
            this.invalidated.Height = rect.Height;
        }
    }
コード例 #11
0
 public void UpdateTextRegion()
 {
     this.Interpreter.GraphicsDriver.Update(this.invalidated);
     this.invalidated = default(RenderRectangle);
 }
コード例 #12
0
        void IGraphicsDriver.Fill(RenderRectangle rect, byte color)
        {
            SDL_Rect sdlRect = new SDL_Rect((short)(rect.X * this.displayScaleX), (short)(rect.Y * this.displayScaleY), (short)(rect.Width * this.displayScaleX), (short)(rect.Height * this.displayScaleY));

            SDL_FillRect(this.surfacePtr, ref sdlRect, color);
        }
コード例 #13
0
        /// <summary>
        /// Initializes the members of the <see cref="Console"/>
        /// </summary>
        /// <param name="game">
        /// A <see cref="Game"/> this <see cref="Console"/> should be bound to.
        /// </param>
        /// <param name="font">
        /// A <see cref="SpriteFont"/> used to draw standard output <see cref="string"/>s.
        /// </param>
        /// <param name="textScale">
        /// A value indicating the scale of the drawn <see cref="string"/>s.
        /// </param>
        /// <param name="width">
        /// A value indicating the width to be subtracted of the <see cref="Game"/> width.
        /// </param>
        /// <param name="height">
        /// A value indicating the height to be subtracted of the <see cref="Game"/> height.
        /// </param>
        /// <param name="position">
        /// A <see cref="Rectangle"/> indicating the position of the <see cref="Console"/>.
        /// </param>
        /// <param name="backgroundColor">
        /// A <see cref="Color"/> used to draw the background.
        /// </param>
        /// <param name="alpha">
        /// A value indicating the alpha value of the <see cref="Console"/>.
        /// </param>
        /// <param name="outputColor">
        /// A <see cref="Color"/> used to draw standard input <see cref="string"/>s.
        /// </param>
        /// <param name="errorColor">
        /// A <see cref="Color"/> used to draw standard input <see cref="string"/>s.
        /// </param>
        /// <param name="inputColor">
        /// A <see cref="Color"/> used to draw standard input <see cref="string"/>s.
        /// </param>
        /// <param name="outputFont">
        /// A <see cref="SpriteFont"/> used to draw standard output <see cref="string"/>s.
        /// </param>
        /// <param name="errorFont">
        /// A <see cref="SpriteFont"/> used to draw error output <see cref="string"/>s.
        /// </param>
        /// <param name="inputFont">
        /// A <see cref="SpriteFont"/> used to draw standard input <see cref="string"/>s.
        /// </param>
        /// <param name="fadeColor">
        /// A <see cref="Color"/> to be used to fade the output <see cref="string"/>s.
        /// </param>
        private static void InitializeMembers(
            Game game,
            SpriteFont font,
            float textScale       = 0.5f,
            int width             = -1,
            int height            = -1,
            Rectangle position    = new Rectangle(),
            Color backgroundColor = new Color(),
            float alpha           = 0.5f,
            Color outputColor     = new Color(),
            Color errorColor      = new Color(),
            Color inputColor      = new Color(),
            SpriteFont outputFont = null,
            SpriteFont errorFont  = null,
            SpriteFont inputFont  = null,
            Color fadeColor       = new Color())
        {
            Console.outputWriter  = new OutputWriter(OutputType.Info);
            Console.errorWriter   = new OutputWriter(OutputType.Error);
            Console.inputReader   = new InputReader();
            Console.parent        = game;
            Console.textScale     = textScale;
            Console.alpha         = alpha;
            Console.outputStrings = new List <string>();
            Console.outputTypes   = new List <OutputType>();
            Console.renderOutput  = new List <RenderText>();
            Console.state         = ConsoleState.Nothing;
            Console.inputQuitted  = false;
            if (backgroundColor.Equals(new Color()))
            {
                Console.backgroundColor = Color.Black;
            }
            else
            {
                Console.backgroundColor = backgroundColor;
            }

            Console.rectangle = new RenderRectangle(new Rectangle(0, 0, 0, 0), Console.backgroundColor * Console.alpha, Console.parent.GraphicsDevice);
            if (outputColor.Equals(new Color()))
            {
                Console.outputColor = Color.White;
            }
            else
            {
                Console.outputColor = outputColor;
            }

            if (errorColor.Equals(new Color()))
            {
                Console.errorColor = Color.Red;
            }
            else
            {
                Console.errorColor = errorColor;
            }

            if (inputColor.Equals(new Color()))
            {
                Console.inputColor = Color.Cyan;
            }
            else
            {
                Console.inputColor = inputColor;
            }

            if (fadeColor.Equals(new Color()))
            {
                Console.FadeColor = Color.Transparent;
            }
            else
            {
                Console.FadeColor = fadeColor;
            }

            if (width < 0)
            {
                width = Console.parent.GraphicsDevice.Viewport.Width / 3;
            }

            if (height < 0)
            {
                height = (int)((Console.lineCount) * (font.LineSpacing * Console.textScale));
            }

            if (position.Equals(new Rectangle()))
            {
                Console.Position = new Rectangle(Console.parent.GraphicsDevice.Viewport.Width - width, Console.parent.GraphicsDevice.Viewport.Height - height, width, height);
            }

            if (outputFont == null)
            {
                Console.outputFont = font;
            }
            else
            {
                Console.outputFont = outputFont;
            }

            if (errorFont == null)
            {
                Console.errorFont = font;
            }
            else
            {
                Console.errorFont = errorFont;
            }

            if (inputFont == null)
            {
                Console.inputFont = font;
            }

            else
            {
                Console.inputFont = inputFont;
            }

            for (int i = 0; i < Console.lineCount; i++)
            {
                Console.renderOutput.Add(new RenderText(new Vector2(), " ", Console.outputColor, Console.outputFont, Console.textScale));
            }

            System.Console.SetOut(Console.outputWriter);
            System.Console.SetError(Console.errorWriter);
            System.Console.SetIn(Console.inputReader);
        }
コード例 #14
0
        protected ValueThickness MeasureImpl <TRenderSize>(IVisualElement container,
                                                           IMeasureContext measureContext,
                                                           TRenderSize availableSpace,
                                                           Orientations orientation,
                                                           List <IVisualElement> currentlyRendering,
                                                           out Double maxWidth,
                                                           out Double maxHeight,
                                                           out Double totalWidth,
                                                           out Double totalHeight)
            where TRenderSize : IRenderSize
        {
            var remainingSize = new RenderSize(availableSpace.Width,
                                               availableSpace.Height, availableSpace.Offset);
            var current = new RenderRectangle();

            totalHeight = 0.0;
            totalWidth  = 0.0;

            maxWidth  = 0.0;
            maxHeight = 0.0;

            foreach (var child in _visuals.GetAllChildren())
            {
                currentlyRendering.Add(child);


                current.Size = measureContext.MeasureElement(child, remainingSize);
                var offset = SetChildSize(child, current);
                if (!offset.IsEmpty)
                {
                    current.Width  += offset.Width;
                    current.Height += offset.Height;
                }

                switch (orientation)
                {
                case Orientations.Horizontal:
                    if (current.Height > maxHeight)
                    {
                        maxHeight = current.Height;
                    }

                    if (_isWrapContent && current.Width + totalWidth > availableSpace.Width &&
                        totalHeight + maxHeight < availableSpace.Height)
                    {
                        maxWidth     = Math.Max(maxWidth, totalWidth);
                        totalHeight += maxHeight;

                        current.X  = 0;
                        current.Y += maxHeight;
                        maxHeight  = totalWidth = 0;
                    }

                    current.X           += current.Width;
                    totalWidth          += current.Width;
                    remainingSize.Width -= current.Width;
                    break;

                case Orientations.Vertical:
                    if (current.Width > totalWidth)
                    {
                        totalWidth = current.Width;
                    }

                    if (_isWrapContent && current.Height + totalHeight > availableSpace.Height &&
                        totalWidth + maxWidth < availableSpace.Width)
                    {
                        maxHeight   = Math.Max(maxHeight, totalHeight);
                        totalWidth += maxWidth;

                        current.Y  = 0;
                        current.X += maxHeight;
                        maxWidth   = totalHeight = 0;
                    }

                    current.Y            += current.Height;
                    totalHeight          += current.Height;
                    remainingSize.Height -= current.Height;
                    break;
                }
            }

            var margin = container.Margin.GetValue(availableSpace);

            return(margin);
        }
コード例 #15
0
ファイル: Designer.Line.cs プロジェクト: OkashiKami/Odyssey
        public void FillPolyline(IEnumerable <Vector2> points, float lineWidth)
        {
            RenderRectangle callback = FillRectangle;

            CreatePolyLine(points, lineWidth, callback);
        }
コード例 #16
0
ファイル: Designer.Line.cs プロジェクト: OkashiKami/Odyssey
        public void DrawPolyline(IEnumerable <Vector2> points, float lineWidth, float strokeThickness)
        {
            RenderRectangle callback = (r) => DrawRectangle(r, strokeThickness);

            CreatePolyLine(points, lineWidth, callback);
        }
コード例 #17
0
        private void MakeDoc1(C1PrintDocument doc)
        {
            // create the title of document
            RenderParagraph rp = new RenderParagraph();

            rp.Content.AddText("You can get coordinates and sizes of individual characters in a text block using the ");
            rp.Content.AddText("GetCharRect()", Color.Blue);
            rp.Content.AddText(" method of RenderText and RenderParagraph classes.\r\n");
            rp.Content.AddText("In the following example each character has a red rectangle drawn around it.");
            rp.Style.Font           = new Font("Verdana", 15);
            rp.Style.Spacing.Bottom = "3mm";
            rp.Style.Borders.Bottom = LineDef.DefaultBold;
            rp.Style.TextAlignHorz  = AlignHorzEnum.Justify;
            doc.Body.Children.Add(rp);

            rp            = new RenderParagraph();
            rp.Style.Font = new Font("Arial", 36);
            rp.Content.Add(new ParagraphText("Normal text", TextPositionEnum.Normal));
            rp.Content.Add(new ParagraphText("Super script text\r\n", TextPositionEnum.Superscript));
            rp.Content.Add(new ParagraphText("Sub script text\r\n", TextPositionEnum.Subscript));
            rp.Content.Add(new ParagraphText("Normal text. ", TextPositionEnum.Normal));
            rp.Content.Add(new ParagraphText("Sub script. ", TextPositionEnum.Subscript));
            rp.Content.Add(new ParagraphText("Super script. ", TextPositionEnum.Superscript));
            rp.Content.Add(new ParagraphText("Normal text.\r\n"));
            rp.Content.Add(new ParagraphText("Normal text Normal text Normal text Normal text Normal text Normal text Normal text Normal text."));
            doc.Body.Children.Add(rp);

            // To use the GetCharRect method, we must first generate
            // the document so that character positions are calculated.
            // The generation will be later repeated with drawing
            // red rectangles around the individual characters.
            doc.Generate();

            int textLength = rp.TextLength;
            // Fragments contain info about the rendered objects:
            // get the first fragment of rp object
            RenderParagraphFragment rpf = (RenderParagraphFragment)rp.Fragments[0];

            // go over all characters in the text
            for (int i = 0; i < textLength; ++i)
            {
                // get the coordinates of character,
                // they will be returned in C1PrintDocument.ResolvedUnit units
                RectangleD charRect = rpf.GetCharRect(i);

                // make a rectangle around the char
                RenderRectangle r = new RenderRectangle();
                // specify all coordinates of rectangle
                r.X      = new Unit(rpf.Bounds.Left + charRect.Left, doc.ResolvedUnit);
                r.Y      = new Unit(rpf.Bounds.Top + charRect.Top, doc.ResolvedUnit);
                r.Width  = new Unit(charRect.Width, doc.ResolvedUnit);
                r.Height = new Unit(charRect.Height, doc.ResolvedUnit);
                // set shape (rectangle) coordinates, they are specified
                // relative to object
                r.Rectangle.X      = 0;
                r.Rectangle.Y      = 0;
                r.Rectangle.Width  = r.Width;
                r.Rectangle.Height = r.Height;
                r.Style.ShapeLine  = new LineDef("1pt", Color.Red);
                // add the rectangle to the object
                doc.Body.Children.Add(r);
            }
        }
コード例 #18
0
ファイル: EntityDrawer.cs プロジェクト: thepirateclub/netgore
 /// <summary>
 /// Draws a <see cref="Rectangle"/>.
 /// </summary>
 /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="rect">The <see cref="Rectangle"/> to draw.</param>
 /// <param name="color">Color to draw the CollisionBox.</param>
 static void Draw(ISpriteBatch sb, Rectangle rect, Color color)
 {
     RenderRectangle.Draw(sb, rect, color, _borderColor);
 }
コード例 #19
0
 void IGraphicsDriver.Update(RenderRectangle rect)
 {
     SDL_UpdateRect(this.surfacePtr, rect.X * this.displayScaleX, rect.Y * this.displayScaleY, rect.Width * this.displayScaleX, rect.Height * this.displayScaleY);
 }