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


C# Surface.Blit方法代码示例

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


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

示例1: CreateSurface

        protected override Surface CreateSurface()
        {
            if (calc_width) {
                Surface textSurf = GuiUtil.ComposeText (Text, Font, Palette, -1, -1,
                                    Sensitive ? 4 : 24);
                Width = (ushort)textSurf.Width;
                Height = (ushort)textSurf.Height;

                return textSurf;
            }
            else {
                /* this is wrong */
                Surface surf = new Surface (Width, Height);

                Surface textSurf = GuiUtil.ComposeText (Text, Font, Palette, Width, Height,
                                    Sensitive ? 4 : 24);

                int x = 0;
                if (Type == ElementType.LabelRightAlign)
                    x += Width - textSurf.Width;
                else if (Type == ElementType.LabelCenterAlign)
                    x += (Width - textSurf.Width) / 2;

                surf.Blit (textSurf, new Point (x, 0));

                surf.TransparentColor = Color.Black /* XXX */;
                return surf;
            }
        }
开发者ID:directhex,项目名称:scsharp,代码行数:29,代码来源:LabelElement.cs

示例2: CreateDropdownSurface

        void CreateDropdownSurface()
        {
            dropdownSurface = new Surface (Width, items.Count * Font.LineSize);

            int y = 0;
            for (int i = 0; i < items.Count; i ++) {
                Surface item_surface = GuiUtil.ComposeText (items[i], Font, Palette,
                                        i == selected_item ? 4 : 24);

                item_surface.TransparentColor = Color.Black;

                dropdownSurface.Blit (item_surface, new Point (0, y));
                y += item_surface.Height;
            }
        }
开发者ID:directhex,项目名称:scsharp,代码行数:15,代码来源:ComboBoxElement.cs

示例3: CreateSurface

        protected override Surface CreateSurface()
        {
            Surface surf = new Surface (Width, Height);

            surf.TransparentColor = Color.Black; /* XXX */

            text_surf = null;
            CalculateTextPosition ();

            surf.Blit (text_surf, new Point (text_x, text_y));

            return surf;
        }
开发者ID:directhex,项目名称:scsharp,代码行数:13,代码来源:ButtonElement.cs

示例4: CreateSurface

        protected override Surface CreateSurface()
        {
            Surface surf = new Surface (Width, Height);

            /* XXX draw the arrow (and border) */

            if (cursor != -1) {
                Surface item_surface = GuiUtil.ComposeText (items[cursor], Font, Palette, 4);

                item_surface.TransparentColor = Color.Black;
                surf.Blit (item_surface, new Point (0, 0));
            }

            return surf;
        }
开发者ID:directhex,项目名称:scsharp,代码行数:15,代码来源:ComboBoxElement.cs

示例5: ComposeText

        public static Surface ComposeText(string text, Fnt font, byte[] palette, int width, int height,
						   int offset)
        {
            if (font == null)
                Console.WriteLine ("aiiiieeee");

            int i;
            /* create a run of text, for now ignoring any control codes in the string */
            StringBuilder run = new StringBuilder ();
            for (i = 0; i < text.Length; i ++)
                if (text[i] == 0x0a /* allow newlines */||
                    !Char.IsControl (text[i]))
                    run.Append (text[i]);

            string rs = run.ToString ();
            byte[] r = Encoding.ASCII.GetBytes (rs);

            int x, y;
            int text_height, text_width;

            /* measure the text first, optionally wrapping at width */
            text_width = text_height = 0;
            x = y = 0;

            for (i = 0; i < r.Length; i ++) {
                int glyph_width = 0;

                if (r[i] != 0x0a) /* newline */ {
                    if (r[i] == 0x20) /* space */
                        glyph_width = font.SpaceSize;
                    else {
                        Glyph g = font[r[i]-1];

                        glyph_width = g.Width + g.XOffset;
                    }
                }

                if (r[i] == 0x0a ||
                    (width != -1 && x + glyph_width > width)) {
                    if (x > text_width)
                        text_width = x;
                    x = 0;
                    text_height += font.LineSize;
                }

                x += glyph_width;
            }

            if (x > text_width)
                text_width = x;
            text_height += font.LineSize;

            Surface surf = new Surface (text_width, text_height);
            surf.TransparentColor = Color.Black;

            /* the draw it */
            x = y = 0;
            for (i = 0; i < r.Length; i ++) {
                int glyph_width = 0;
                Glyph g = null;

                if (r[i] != 0x0a) /* newline */ {
                    if (r[i] == 0x20)  /* space */{
                        glyph_width = font.SpaceSize;
                    }
                    else {
                        g = font[r[i]-1];
                        glyph_width = g.Width + g.XOffset;

                        Surface gs = RenderGlyph (font, g, palette, offset);
                        surf.Blit (gs, new Point (x, y + g.YOffset));
                    }
                }

                if (r[i] == 0x0a ||
                    x + glyph_width > text_width) {
                    x = 0;
                    y += font.LineSize;
                }

                x += glyph_width;
            }

            return surf;
        }
开发者ID:directhex,项目名称:scsharp,代码行数:85,代码来源:GuiUtil.cs

示例6: TileRow

        void TileRow(Surface surf, Grp grp, byte[] pal, int l, int c, int r, int y)
        {
            Surface lsurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (l),
                                     grp.Width, grp.Height,
                                     pal,
                                     41, 0);

            Surface csurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (c),
                                     grp.Width, grp.Height,
                                     pal,
                                     41, 0);

            Surface rsurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (r),
                                     grp.Width, grp.Height,
                                     pal,
                                     41, 0);

            surf.Blit (lsurf, new Point (0,y));
            for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
                surf.Blit (csurf, new Point (x, y));
            surf.Blit (rsurf, new Point (surf.Width - grp.Width,y));
        }
开发者ID:directhex,项目名称:scsharp,代码行数:22,代码来源:DialogBoxElement.cs

示例7: CreateSurface

        protected override Surface CreateSurface()
        {
            if (player == null || player.Surface == null)
                return null;

            Surface surf;

            surf = new Surface (player.Surface);

            if (scale
                && (player.Width != Width
                || player.Height != Height)) {
                double horiz_zoom = (double)Width / player.Width;
                double vert_zoom = (double)Height / player.Height;
                double zoom;

                if (horiz_zoom < vert_zoom)
                    zoom = horiz_zoom;
                else
                    zoom = vert_zoom;

                surf.Scale (zoom);
            }

            if (dim != 0) {
                Surface dim_surf = new Surface (surf.Size);
                dim_surf.Alpha = dim;
                dim_surf.AlphaBlending = true;
                dim_surf.Blit (surf);
                surf.Dispose ();
                surf = dim_surf;
            }

            return surf;
        }
开发者ID:directhex,项目名称:scsharp,代码行数:35,代码来源:MovieElement.cs

示例8: CreateSurface

        protected override Surface CreateSurface()
        {
            Surface surf = new Surface (Width, Height);

            int y = 0;
            for (int i = first_visible; i < first_visible + num_visible; i ++) {
                if (i >= items.Count)
                    break;
                Surface item_surface = GuiUtil.ComposeText (items[i], Font, Palette,
                                        (!selectable ||
                                         (!selecting && cursor == i) ||
                                         (selecting && selectionIndex == i)) ? 4 : 24);

                surf.Blit (item_surface, new Point (0, y));
                y += item_surface.Height;
            }

            surf.TransparentColor = Color.Black; /* XXX */

            return surf;
        }
开发者ID:directhex,项目名称:scsharp,代码行数:21,代码来源:ListBoxElement.cs


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