当前位置: 首页>>代码示例>>C#>>正文


C# Surface.Draw方法代码示例

本文整理汇总了C#中SdlDotNet.Graphics.Surface.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.Draw方法的具体用法?C# Surface.Draw怎么用?C# Surface.Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SdlDotNet.Graphics.Surface的用法示例。


在下文中一共展示了Surface.Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawRect

        /// <summary>
        /// 
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="location"></param>
        /// <param name="size"></param>
        /// <param name="color"></param>
        public static void DrawRect(Surface surface, Point location, Size size, Color color)
        {
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }
            int x;
            int y;

            //Draw top line...
            for (x = location.X; x < location.X + size.Width; x++)
            {
                surface.Draw(new Point(x, location.Y), color);
            }

            //Draw bottom line...
            for (x = location.X; x < location.X + size.Width; x++)
            {
                surface.Draw(new Point(x, location.Y + size.Height), color);
            }

            //Draw left line...
            for (y = location.Y; y < location.Y + size.Height; y++)
            {
                surface.Draw(new Point(location.X, y), color);
            }

            //Draw right line... 
            for (y = location.Y; y < location.Y + size.Height; y++)
            {
                surface.Draw(new Point(location.X + size.Width, y), color);
            }
        }
开发者ID:erin100280,项目名称:Zelda.NET,代码行数:40,代码来源:Utilities.cs

示例2: Render

        public static Surface Render(PlayerUnit Unit)
        {
            Surface Buffer = new Surface(PUNIT_WIDTH_PX, PUNIT_WIDTH_PX);
            Color Bg = Color.WhiteSmoke;

            switch (Unit.Class)
            {
                case UnitClasses.Archer: Bg = Color.Orange;
                    break;
                case UnitClasses.Mage: Bg = Color.Blue;
                    break;
                case UnitClasses.Paladin: Bg = Color.DeepPink;
                    break;
                case UnitClasses.Soldier: Bg = Color.Brown;
                    break;
                case UnitClasses.Thieft: Bg = Color.Yellow;
                    break;

            }

            Rectangle UnitRect = new Rectangle(new Point(0,0), new Size(Buffer.Width, Buffer.Height));
            Box Border = new Box(new Point(0, 0), new Size(Buffer.Width - 1, Buffer.Height - 1));
            Buffer.Fill(UnitRect, Bg);
            Buffer.Draw(Border, Color.WhiteSmoke, true);
            Buffer.AlphaBlending = true;
            Buffer.Alpha = 230;
            return Buffer;
        }
开发者ID:jordsti,项目名称:towerdefenserpg,代码行数:28,代码来源:PlayerUnitRenderer.cs

示例3: Cycle

        public override void Cycle()
        {
            Events.Poll();

            Surface screenBitmap = new Surface(Video.Screen.Width, Video.Screen.Height);

            var fontBuffer = new byte[0x2000];
            var displayBuffer = new byte[0xfa0];
            Color[] data = new Color[screenBitmap.Width * screenBitmap.Height];

            Memory.BlockRead(0xa0000, fontBuffer, fontBuffer.Length);
            Memory.BlockRead(0xb8000, displayBuffer, displayBuffer.Length);

            for (var i = 0; i < displayBuffer.Length; i += 2)
            {
                int currChar = displayBuffer[i];
                int fontOffset = currChar * 32;
                byte attribute = displayBuffer[i + 1];
                int y = i / 160 * 16;

                Color foreColour = vgaDevice.GetColour(attribute & 0xf);
                Color backColour = vgaDevice.GetColour((attribute >> 4) & 0xf);

                for (var f = fontOffset; f < fontOffset + 16; f++)
                {
                    int x = ((i % 160) / 2) * 8;

                    for (var j = 7; j >= 0; j--)
                    {
                        if (((fontBuffer[f] >> j) & 0x1) != 0)
                            screenBitmap.Draw(new Point(x, y), foreColour);
                        else
                            screenBitmap.Draw(new Point(x, y), backColour);
                        x++;
                    }
                    y++;
                }
            }
            screen.Blit(screenBitmap);
            screen.Update();
        }
开发者ID:cryogen,项目名称:VM86CS,代码行数:41,代码来源:SDLUI.cs

示例4: DrawWindow

 public void DrawWindow(SdlDotNet.Graphics.Primitives.Box box, Surface dest)
 {
     dest.Draw(box, bgColor, false, true);
     for (int i = Border; i < box.Width - Border; i += Border) {
         dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition1), new Rectangle(2 * Border, 0, Border, Border));
         dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition2 - Border + 1), new Rectangle(2 * Border, Border, Border, Border));
     }
     for (int i = Border; i < box.Height - Border; i += Border) {
         dest.Blit(surface, new Point(box.XPosition1, box.YPosition1 + i), new Rectangle(3 * Border, 0, Border, Border));
         dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1 + i), new Rectangle(3 * Border, Border, Border, Border));
     }
     dest.Blit(surface, new Point(box.XPosition1, box.YPosition1), new Rectangle(0, 0, Border, Border));
     dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1), new Rectangle(Border, 0, Border, Border));
     dest.Blit(surface, new Point(box.XPosition1, box.YPosition2 - Border + 1), new Rectangle(0, Border, Border, Border));
     dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition2 - Border + 1), new Rectangle(Border, Border, Border, Border));
 }
开发者ID:hgabor,项目名称:kfirpgcreator,代码行数:16,代码来源:Dialogs.cs

示例5: Draw

 public void Draw(Surface sfcGameWindow, float x, float y, int alpha=255, bool fill=false)
 {
     if (sfc != null) {
         sfcGameWindow.Blit (sfc, new Point ((int)x, (int)y));
     } else {
         box = new Box (new Point ((int)x, (int)y), new Size (width, height));
         int r = colour.R;
         int g = colour.G;
         int b = colour.B;
         Color colour2 = Color.FromArgb (alpha, r, g, b);
         if (colour == Color.Transparent) {
             colour2 = colour;
         }
         sfcGameWindow.Draw (box, colour2, true, fill);
     }
 }
开发者ID:m0a0t0,项目名称:Extremely-Simple-C--Platformer,代码行数:16,代码来源:Graphic.cs

示例6: DrawCenteredWindow

 //TODO: Check for border size and width/height
 public void DrawCenteredWindow(int width, int height, Surface dest)
 {
     SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(new Point((game.Width - width) / 2, (game.Height - height) / 2), new Size(width, height));
     dest.Draw(box, bgColor, false, true);
     for (int i = Border; i < width - Border; i += Border) {
         dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition1), new Rectangle(2 * Border, 0, Border, Border));
         dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition2 - Border + 1), new Rectangle(2 * Border, Border, Border, Border));
     }
     for (int i = Border; i < height - Border; i += Border) {
         dest.Blit(surface, new Point(box.XPosition1, box.YPosition1 + i), new Rectangle(3 * Border, 0, Border, Border));
         dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1 + i), new Rectangle(3 * Border, Border, Border, Border));
     }
     dest.Blit(surface, new Point(box.XPosition1, box.YPosition1), new Rectangle(0, 0, Border, Border));
     dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1), new Rectangle(Border, 0, Border, Border));
     dest.Blit(surface, new Point(box.XPosition1, box.YPosition2 - Border + 1), new Rectangle(0, Border, Border, Border));
     dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition2 - Border + 1), new Rectangle(Border, Border, Border, Border));
 }
开发者ID:hgabor,项目名称:kfirpgcreator,代码行数:18,代码来源:Dialogs.cs

示例7: GetSurface

 public static Surface GetSurface(byte[] imgBytes, Size boxSize)
 {
     Surface boxSurf = new Surface(boxSize);
     boxSurf.Fill(Color.White);  //Fill background to white color
     //Get and resize image
     if (imgBytes != null)
     {
         Surface imgSurf = new Surface(imgBytes);
         double scale = Ratio.CalculateScale(imgSurf.Size,
                                             new Size(boxSize.Width, boxSize.Height),
                                             Ratio.RatioType.FitImage); //Calculate ratio
         Surface scaledSurf = imgSurf.CreateScaledSurface(scale, true);
         imgSurf.Dispose();
         Point pt = new Point((boxSize.Width - scaledSurf.Width) / 2,      //Left point
                              (boxSize.Height - scaledSurf.Height) / 2);   //Top point
         boxSurf.Blit(scaledSurf, pt);
         scaledSurf.Dispose();  //Clear imgSurf memory
     }
     //Draw border
     for(int i = 0; i < BORDER; i++)
         boxSurf.Draw(new Box(new Point(i, i), new Point(boxSize.Width - i - 1, boxSize.Height - i - 1)), Color.Gray);
     return boxSurf;
 }
开发者ID:amirsalah,项目名称:moonview,代码行数:23,代码来源:ImageBox.cs

示例8: Initialize

        public void Initialize(Rectangle mapRectangle, Rectangle showRectangle, Surface map)
        {
            double xScaleFactor = Convert.ToDouble(panel.Width) / Convert.ToDouble(mapRectangle.Width);
            double yScaleFactor = Convert.ToDouble(panel.Height) / Convert.ToDouble(mapRectangle.Height);

            if (xScaleFactor < yScaleFactor) { scaleFactor = xScaleFactor; }
            else { scaleFactor = yScaleFactor; }

            short mapX = (short)(mapRectangle.X * scaleFactor);
            short mapY = (short)(mapRectangle.Y * scaleFactor);
            short mapW = (short)(mapRectangle.Width * scaleFactor);
            short mapH = (short)(mapRectangle.Height * scaleFactor);

            short x = (short)(showRectangle.X * scaleFactor);
            short y = (short)(showRectangle.Y * scaleFactor);
            short w = (short)(showRectangle.Width * scaleFactor);
            short h = (short)(showRectangle.Height * scaleFactor);

            if (mapW > surfaceControl.Width) { mapW = (short)panel.Width; }
            if (mapH > surfaceControl.Height) { mapH = (short)panel.Height; }

            mapViewport = new Box(new Point(x, y), new Point(x + w - 1, y + h - 1));

            mapSurface = map;

            surface = new Surface(mapW, mapH);
            surface = map.CreateScaledSurface(scaleFactor, true);
            surface.Draw(mapViewport, Color.Red);
            Point pos = new Point((panel.Width / 2) - (mapW / 2), (panel.Height / 2) - (mapH / 2));
            surfaceControl.Width = mapW;
            surfaceControl.Height = mapH;
            surfaceControl.Location = pos;
            this.surfaceControl.Blit(surface);

            this.initialized = true;
        }
开发者ID:walle,项目名称:myleveleditor,代码行数:36,代码来源:InfoForm.cs

示例9: Render

        public override Surface Render()
        {
            Surface Buffer = new Surface(Width, Height);
            int i = 0;
            foreach(MenuItem Item in MenuItems)
            {
                if (Item.Focus)
                {
                    Buffer.Blit(Item.RenderHighlight(), new Point(0, i * Item.Height));
                }
                else
                {
                    Buffer.Blit(Item.Render(), new Point(0, i * Item.Height));
                }
                i++;
            }

            Line Top = new Line(new Point(0, 0), new Point(Width-1, 0));
            Line Bottom = new Line(new Point(0, Height-1), new Point(Width - 1, Height -1));

            Buffer.Draw(Top, Color.Black);
            Buffer.Draw(Bottom, Color.Black);

            return Buffer;
        }
开发者ID:jordsti,项目名称:towerdefenserpg,代码行数:25,代码来源:Menu.cs

示例10: Render

        /// <summary>
        /// Draws the particle on the destination surface.
        /// </summary>
        /// <param name="destination">The surface to draw the particle on.</param>
        public override void Render(Surface destination)
        {
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }
            if (this.Life != -1)
            {
                float alpha;
                if (this.Life >= this.LifeFull)
                    alpha = 255;
                else if (this.Life <= 0)
                    alpha = 0;
                else
                    alpha = ((float)this.Life / this.LifeFull) * 255F;

                if (m_Filled)
                {
                    destination.Draw(
                        new Box(
                        (short)this.X, (short)this.Y,
                        (short)this.Right, (short)this.Bottom),
                        Color.FromArgb((int)alpha, this.Color), false, true);
                }
                else
                {
                    destination.Draw(
                        new Box(
                        (short)this.X, (short)this.Y,
                        (short)this.Right, (short)this.Bottom),
                        Color.FromArgb((int)alpha, this.Color), false, true);
                }
            }
            else
            {
                if (m_Filled)
                {
                    destination.Draw(
                        new Box(
                        (short)this.X, (short)this.Y,
                        (short)this.Right, (short)this.Bottom),
                        this.Color, false, true);
                }
                else
                {
                    destination.Draw(
                        new Box(
                        (short)this.X, (short)this.Y,
                        (short)this.Right, (short)this.Bottom),
                        this.Color, false, true);
                }
            }
        }
开发者ID:Blizz9,项目名称:FanCut,代码行数:57,代码来源:ParticleRectangle.cs

示例11: drawLines

 private void drawLines(Surface s, List<Point> points, Color c)
 {
     Point prev = Point.Empty;
     foreach (Point p in points)
     {
         if (prev != Point.Empty)
         {
             s.Draw(new Line(prev, p), c);
         }
         prev = p;
     }
 }
开发者ID:davinx,项目名称:PitchPitch,代码行数:12,代码来源:SceneOption.cs

示例12: renderKeyboard

        protected virtual void renderKeyboard(Surface s)
        {
            if (_keyboardSurface == null)
            {
                _keyboardSurface = new Surface(_keyRect.Size);
                foreach (KeyValuePair<Rectangle, string> kv in _whiteKeys)
                {
                    Box box = new Box(kv.Key.Location, kv.Key.Size);
                    _keyboardSurface.Draw(box, _backColor, true, true);
                    _keyboardSurface.Draw(box, _foreColor, true, false);
                }
                foreach (KeyValuePair<Rectangle, string> kv in _blackKeys)
                {
                    Box box = new Box(kv.Key.Location, kv.Key.Size);
                    _keyboardSurface.Draw(box, _foreColor, true, true);
                }
            }
            s.Blit(_keyboardSurface, _keyRect.Location);

            bool black = false;
            Rectangle cr = Rectangle.Empty;
            foreach (KeyValuePair<Rectangle, string> kv in _blackKeys)
            {
                if (kv.Key.Top <= _parent.Player.Y - _view.Y && 
                    _parent.Player.Y - _view.Y <= kv.Key.Bottom)
                {
                    cr = new Rectangle(kv.Key.Location, kv.Key.Size);
                    black = true;
                    break;
                }
            }
            if (!black)
            {
                foreach (KeyValuePair<Rectangle, string> kv in _whiteKeys)
                {
                    if (kv.Key.Top <= _parent.Player.Y - _view.Y &&
                        _parent.Player.Y - _view.Y <= kv.Key.Bottom)
                    {
                        cr = new Rectangle(kv.Key.Location, kv.Key.Size);
                        break;
                    }
                }
            }
            if (!cr.IsEmpty)
            {
                cr.Offset(_keyRect.Location);
                Circle cir = new Circle(new Point(cr.Right - 22, (int)(cr.Y + cr.Height / 2.0)), 10);
                s.Draw(cir, _strongColor, true, true);
                s.Draw(cir, _strongColor, true, false);
            }
        }
开发者ID:davinx,项目名称:PitchPitch,代码行数:51,代码来源:SceneGameStage.cs

示例13: Render

        public override Surface Render()
        {
            Surface Buffer = new Surface(Width, Height);

            Box line = new Box(new Point(0, 0), new Size(Width - 1, Height - 1));

            Buffer.Transparent = true;
            Buffer.TransparentColor = Color.Magenta;

            Buffer.Fill(Color.Magenta);

            Buffer.Draw(line, Color.Snow);

            for (int i=0; i<Items.Count; i++)
            {
                Surface ibff;

                if (SelectedIndex == i)
                {
                    ibff = Items[i].RenderHighlight();
                    Buffer.Blit(ibff, Items[i].GetRect());
                }
                else
                {
                    ibff = Items[i].Render();
                    Buffer.Blit(ibff, Items[i].GetRect());
                }
            }

            return Buffer;
        }
开发者ID:jordsti,项目名称:towerdefenserpg,代码行数:31,代码来源:NewGameWindow.cs

示例14: SetAlert

        public virtual void SetAlert(bool on, string message)
        {
            _onAlert = on;
            if (_onAlert && string.IsNullOrEmpty(message)) _onAlert = false;
            if (_alertSurface != null) _alertSurface.Dispose();
            if (!_onAlert) _alertSurface = null;

            if (_onAlert)
            {
                message += "\n\n" + Properties.Resources.Str_AlertTail;
                string[] lines = message.Split('\n');
                Size[] sizes = Array.ConvertAll<string, Size>(lines, (l) => { return ResourceManager.SmallPFont.SizeText(l); });

                int maxWidth = 0; int height = 0;
                foreach (Size s in sizes)
                {
                    if (maxWidth < s.Width) maxWidth = s.Width;
                    height += (int)(s.Height * Constants.LineHeight);
                }

                _alertSurface = new Surface(maxWidth + Constants.WindowPadding * 2, height + Constants.WindowPadding * 2);
                SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(
                    Point.Empty, new Size(maxWidth + Constants.WindowPadding * 2 - 1, height + Constants.WindowPadding * 2 - 1));

                _alertSurface.Lock();
                _alertSurface.Draw(box, Constants.Color_AlertBackground, false, true);
                _alertSurface.Draw(box, Constants.Color_AlertForeground, false, false);
                _alertSurface.Unlock();

                int y = Constants.WindowPadding; int idx = 0;
                foreach (string l in lines)
                {
                    using (Surface ts = ResourceManager.SmallPFont.Render(l, Constants.Color_AlertForeground))
                    {
                        if (idx == lines.Length - 1)
                        {
                            _alertSurface.Blit(ts, new Point((int)(_alertSurface.Width / 2.0 - ts.Width / 2.0), y));
                        }
                        else
                        {
                            _alertSurface.Blit(ts, new Point(Constants.WindowPadding, y));
                        }
                        y += (int)(ts.Height * Constants.LineHeight);
                    }
                    idx++;
                }
                _alertSurface.Update();
            }
        }
开发者ID:davinx,项目名称:PitchPitch,代码行数:49,代码来源:Scene.cs

示例15: UpdateBackground

 private void UpdateBackground()
 {
     mBackground = new SdlDotNet.Graphics.Surface(base.Size);
     base.Buffer.Fill(mBackColor);
     if (mBackColor.A != 0) {
         mBackground.Fill(mBackColor);
     } else {
         mBackground.Transparent = true;
         mBackground.TransparentColor = Color.Transparent;
         mBackground.Fill(Color.Transparent);
     }
     mCheckedBoxBounds = new Rectangle(new Point(2, 2), new Size(this.Height - 4, this.Height - 4));
     Gfx.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(mCheckedBoxBounds.Location, mCheckedBoxBounds.Size);
     mBackground.Draw(box, Color.Black);
     if (mChecked) {
         Gfx.Surface filled = new SdlDotNet.Graphics.Surface(box.Size);
         filled.Fill(Color.Black);
         mBackground.Blit(filled, box.Location);
         filled.Close();
         filled.Dispose();
     }
     if (mText != "") {
         Gfx.Font font = new Gfx.Font(IO.IO.CreateOSPath("Fonts\\PMU.ttf"), this.Height);
         mBackground.Blit(font.Render(mText, mForeColor, mAntiAlias), new Point(20, -4));
         font.Close();
     }
     base.Buffer.Blit(mBackground, new Point(0, 0));
 }
开发者ID:ChaotixBluix,项目名称:PMU-Client,代码行数:28,代码来源:Checkbox.cs


注:本文中的SdlDotNet.Graphics.Surface.Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。