Exemplo n.º 1
0
            public IEnumerator <bool> Generate()
            {
                charSizeStepX = FontLibrary.CHARWIDTH * size + 1;

                int sizeX = (text.Length * charSizeStepX) + 2;
                int sizeY = (FontLibrary.CHARHEIGHT * size + 1) + 1;

                leftCenter = new Vector2I(FontLibrary.CHARWIDTH / 2 + 1, (FontLibrary.CHARHEIGHT * size) / 2 + 1);

                canvas = new Canvas(sizeX, sizeY);

                if (alignTopLeft)
                {
                    position = new Vector2I(basePosition.X + sizeX / 2, basePosition.Y + sizeY / 2);
                }
                else
                {
                    position = basePosition;
                }

                char pixel = MonospaceUtils.GetColorChar(color);

                canvas.Clear();

                for (int x = 0; x < text.Length; x++)
                {
                    yield return(true);

                    var charPos = leftCenter;
                    charPos.X += x * charSizeStepX;

                    var character = new ResizableCharacter(charPos, text[x], Color.White, size);
                    canvas.MergeCanvas(character.Draw(), character.Position);
                }
            }
            private void Generate()
            {
                char pixel = MonospaceUtils.GetColorChar(color);

                canvas.Clear();

                canvas.PaintBitMap(characterbitMap, color, center.X, center.Y);
            }
Exemplo n.º 3
0
            public void SetBackGround(Color color)
            {
                char pixel = MonospaceUtils.GetColorChar(color);

                canvas.Clear();

                for (int y = 0; y < sizeY; y++)
                {
                    canvas.Append(pixel, sizeX);
                    canvas.Append('\n');
                }
            }
Exemplo n.º 4
0
            public void Generate()
            {
                canvas.Clear();

                int x0 = localStart.X;
                int y0 = localStart.Y;

                int  x1    = localStart.X + size.X;
                int  y1    = localStart.Y + size.Y;
                char pixel = MonospaceUtils.GetColorChar(color);

                int  a = Math.Abs(x1 - x0), b = Math.Abs(y1 - y0), b1 = b & 1; /* values of diameter */
                long dx = 4 * (1 - a) * b * b, dy = 4 * (b1 + 1) * a * a;      /* error increment */
                long err = dx + dy + b1 * a * a, e2;                           /* error of 1.step */

                if (x0 > x1)
                {
                    x0 = x1; x1 += a;
                }                                  /* if called with swapped points */
                if (y0 > y1)
                {
                    y0 = y1;                     /* .. exchange them */
                }
                y0 += (b + 1) / 2; y1 = y0 - b1; /* starting pixel */
                a  *= 8 * a; b1 = 8 * b * b;

                do
                {
                    canvas.PaintPixel(pixel, x1, y0); /*   I. Quadrant */
                    canvas.PaintPixel(pixel, x0, y0); /*  II. Quadrant */
                    canvas.PaintPixel(pixel, x0, y1); /* III. Quadrant */
                    canvas.PaintPixel(pixel, x1, y1); /*  IV. Quadrant */

                    e2 = 2 * err;
                    if (e2 <= dy)
                    {
                        y0++; y1--; err += dy += a;
                    }                                              /* y step */
                    if (e2 >= dx || 2 * err > dy)
                    {
                        x0++; x1--; err += dx += b1;
                    }                                                              /* x step */
                } while (x0 <= x1);

                while (y0 - y1 < b)
                {                                         /* too early stop of flat ellipses a=1 */
                    canvas.PaintPixel(pixel, x0 - 1, y0); /* -> finish tip of ellipse */
                    canvas.PaintPixel(pixel, x1 + 1, y0++);
                    canvas.PaintPixel(pixel, 0 - 1, y1);
                    canvas.PaintPixel(pixel, x1 + 1, y1--);
                }
            }
            public IEnumerator <bool> Generate()
            {
                char pixel     = MonospaceUtils.GetColorChar(color);
                int  truecount = 0;

                for (int y = 0; y < size.Y; y++)
                {
                    for (int x = 0; x < size.X; x++)
                    {
                        if (PointInPolygon(x, y))
                        {
                            canvas.PaintPixel(pixel, x, y);
                            truecount++;
                        }
                    }
                    yield return(true);
                }
            }
Exemplo n.º 6
0
            public IEnumerator <bool> SetBackGround(Color color, int maxPerRun)
            {
                char pixel   = MonospaceUtils.GetColorChar(color);
                int  counter = 0;

                canvas.Clear();

                for (int x = 0; x < sizeX; x++)
                {
                    if (counter++ >= maxPerRun)
                    {
                        counter = 0;
                        yield return(true);
                    }

                    canvas.Append(pixel, sizeX);
                    canvas.Append('\n');
                }
            }
Exemplo n.º 7
0
            public void Generate()
            {
                canvas.Clear();

                int x0 = localStart.X;
                int y0 = localStart.Y;

                int x1 = localStart.X + size.X;
                int y1 = localStart.Y + size.Y;

                char pixel = MonospaceUtils.GetColorChar(color);

                int dx = Math.Abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
                int dy = -Math.Abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
                int err = dx + dy, e2; /* error value e_xy */



                while (true)
                {  /* loop */
                    canvas.PaintPixel(pixel, x0, y0);
                    if (x0 == x1 && y0 == y1)
                    {
                        break;
                    }
                    e2 = 2 * err;
                    if (e2 >= dy)
                    {
                        err += dy; x0 += sx;
                    }                                      /* e_xy+e_x > 0 */
                    if (e2 <= dx)
                    {
                        err += dx; y0 += sy;
                    }                                      /* e_xy+e_y < 0 */
                }

                Vector3D from = new Vector3D(x0, y0, 0);
                Vector3D to   = new Vector3D(x1, y1, 0);

                line = new LineD(from, to);
            }
            public IEnumerator <bool> Generate()
            {
                canvas.Clear();

                char pixel = MonospaceUtils.GetColorChar(color);

                canvas.Clear();

                int x   = radius - 1;
                int y   = 0;
                int dx  = 1;
                int dy  = 1;
                int err = dx - (radius << 1);

                while (x >= y)
                {
                    MonospaceUtils.PlotLine(center.X - x, center.Y + y, center.X + x, center.Y + y, canvas, pixel);
                    MonospaceUtils.PlotLine(center.X - y, center.Y + x, center.X + y, center.Y + x, canvas, pixel);
                    MonospaceUtils.PlotLine(center.X - x, center.Y - y, center.X + x, center.Y - y, canvas, pixel);
                    MonospaceUtils.PlotLine(center.X - y, center.Y - x, center.X + y, center.Y - x, canvas, pixel);


                    if (err <= 0)
                    {
                        y++;
                        err += dy;
                        dy  += 2;
                    }

                    if (err > 0)
                    {
                        x--;
                        dx  += 2;
                        err += dx - (radius << 1);
                    }

                    yield return(true);
                }
            }
Exemplo n.º 9
0
            private void Generate()
            {
                char pixel = MonospaceUtils.GetColorChar(color);

                canvas.Clear();

                int x   = radius - 1;
                int y   = 0;
                int dx  = 1;
                int dy  = 1;
                int err = dx - (radius << 1);

                while (x >= y)
                {
                    canvas.PaintPixel(pixel, center.X + x, center.Y + y);
                    canvas.PaintPixel(pixel, center.X + y, center.Y + x);
                    canvas.PaintPixel(pixel, center.X - y, center.Y + x);
                    canvas.PaintPixel(pixel, center.X - x, center.Y + y);
                    canvas.PaintPixel(pixel, center.X - x, center.Y - y);
                    canvas.PaintPixel(pixel, center.X - y, center.Y - x);
                    canvas.PaintPixel(pixel, center.X + y, center.Y - x);
                    canvas.PaintPixel(pixel, center.X + x, center.Y - y);

                    if (err <= 0)
                    {
                        y++;
                        err += dy;
                        dy  += 2;
                    }

                    if (err > 0)
                    {
                        x--;
                        dx  += 2;
                        err += dx - (radius << 1);
                    }
                }
            }
Exemplo n.º 10
0
            public void PaintBitMap(bool[,] bitmap, Color color, int posX, int posY)
            {
                char pixel = MonospaceUtils.GetColorChar(color);

                PaintBitMap(bitmap, pixel, posX, posY);
            }
Exemplo n.º 11
0
            public void PaintPixel(Color color, int posX, int posY)
            {
                char pixel = MonospaceUtils.GetColorChar(color);

                PaintPixel(pixel, posX, posY);
            }