コード例 #1
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
 // draw vertical line
 public static void DrawLineY(int x, int y, int h, VGAColor color)
 {
     for (int i = 0; i < h; i++)
     {
         DrawPixel(x, y + i, color);
     }
 }
コード例 #2
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
        // draw point-to-point line
        public static void DrawLine(int x0, int y0, int x1, int y1, VGAColor color)
        {
            // calculate
            int xx = x0, yy = y0;
            var dx  = Math.Abs(x1 - x0);
            var dy  = Math.Abs(y1 - y0);
            var sx  = (x0 < x1) ? 1 : -1;
            var sy  = (y0 < y1) ? 1 : -1;
            var err = dx - dy;

            while (true)
            {
                // draw pixel
                DrawPixel(xx, yy, color);

                // increment
                if ((x0 == x1) && (y0 == y1))
                {
                    break;
                }
                var e2 = 2 * err;
                if (e2 > -dy)
                {
                    err -= dy; xx += (int)sx;
                }
                if (e2 < dx)
                {
                    err += dx; yy += (int)sy;
                }
            }
        }
コード例 #3
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
        // draw string with background color
        public static void DrawString(int x, int y, string text, VGAColor fg, VGAColor bg, VGAFont font)
        {
            // determine font size
            fontHeight = 8;
            if (font == VGAFont.Font8x8)
            {
                fontHeight = 8;
            }
            else if (font == VGAFont.Font8x16)
            {
                fontHeight = 16;
            }

            int xx = x, yy = y;

            for (int i = 0; i < text.Length; i++)
            {
                // new line
                if (text[i] == '\n')
                {
                    xx = x; yy += fontHeight;
                }
                // character
                else
                {
                    DrawChar(xx, yy, text[i], fg, bg, font); xx += 8;
                }
            }
        }
コード例 #4
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
 // draw horizontal line
 public static void DrawLineX(int x, int y, int w, VGAColor color)
 {
     for (int i = 0; i < w; i++)
     {
         DrawPixel(x + i, y, color);
     }
 }
コード例 #5
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
 // draw filled rectangle
 public static void DrawFilledRect(int x, int y, int w, int h, VGAColor color)
 {
     for (int i = 0; i < h; i++)
     {
         for (int j = 0; j < w; j++)
         {
             DrawPixel(x + j, y + i, color);
         }
     }
 }
コード例 #6
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
 // draw custom image format with transparency key
 public static void DrawImage(int x, int y, VGAColor transKey, VGAImage image)
 {
     for (int yy = 0; yy < image.Height; yy++)
     {
         for (int xx = 0; xx < image.Width; xx++)
         {
             if (image.Data[xx + (yy * image.Width)] != (byte)transKey)
             {
                 DrawPixel(x + xx, y + yy, (VGAColor)image.Data[xx + (yy * image.Width)]);
             }
         }
     }
 }
コード例 #7
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
        // draw character with background color
        public static void DrawChar(int x, int y, char c, VGAColor fg, VGAColor bg, VGAFont font)
        {
            // determine font size
            fontHeight = 8;
            if (font == VGAFont.Font8x8)
            {
                fontHeight = 8;
            }
            else if (font == VGAFont.Font8x16)
            {
                fontHeight = 16;
            }
            int p = fontHeight * (byte)c;

            // vertical
            for (int cy = 0; cy < fontHeight; cy++)
            {
                // horizontal
                for (byte cx = 0; cx < 8; cx++)
                {
                    // 8x8
                    if (font == VGAFont.Font8x8)
                    {
                        // convert to position and draw
                        if (VGAFontData.ConvertByteToBitAddress(VGAFontData.Font8x8_Data[p + cy], cx + 1))
                        {
                            DrawPixel(x + (8 - cx), y + cy, fg);
                        }
                        else
                        {
                            DrawPixel(x + (8 - cx), y + cy, bg);
                        }
                    }
                    // 8x16
                    else if (font == VGAFont.Font8x16)
                    {
                        // convert to position and draw
                        if (VGAFontData.ConvertByteToBitAddress(VGAFontData.Font8x16_Data[p + cy], cx + 1))
                        {
                            DrawPixel(x + (8 - cx), y + cy, fg);
                        }
                        else
                        {
                            DrawPixel(x + (8 - cx), y + cy, bg);
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: CGM.cs プロジェクト: TheRealEli310/Cosix
 public Window(int x, int y, VGAColor bg)
 {
     (X, Y, BackColor) = (x, y, bg);
 }
コード例 #9
0
 // convert colors to attribute
 public static byte ToAttribute(VGAColor fg, VGAColor bg)
 {
     return((byte)((byte)fg | (byte)bg << 4));
 }
コード例 #10
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
 // draw pixel
 public static void DrawPixel(int x, int y, VGAColor color)
 {
     vga.DrawPixel((ushort)x, (ushort)y, (byte)color);
 }
コード例 #11
0
ファイル: VGAGraphics.cs プロジェクト: napalmtorch/CosmosVGA
 // clear the screen
 public static void Clear(VGAColor color)
 {
     vga.Clear((byte)color);
 }