Ejemplo 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);
                }
            }
Ejemplo n.º 2
0
        public void LCDLibTests(string argument, UpdateType updateSource)
        {
            switch (argument)
            {
            case "DrawCircle":
                int      ranX = random.Next(0, 174);
                int      ranY = random.Next(0, 174);
                Vector2I pos  = new Vector2I(ranX, ranY);

                var circle = new FillCircle(pos, random.Next(1, 50), Color.White);

                drawingLib.AddElement(circle);
                break;

            case "DrawLine":
                int ranX0 = random.Next(0, 174);
                int ranY0 = random.Next(0, 174);

                int ranX1 = random.Next(0, 174);
                int ranY1 = random.Next(0, 174);

                Vector2I pointOne = new Vector2I(ranX0, ranY0);
                Vector2I pointTwo = new Vector2I(ranX1, ranY1);

                var line = new Line(pointOne, pointTwo, Color.White);
                drawingLib.AddElement(line);
                break;

            case "DrawEllipse":
                int ranEX0 = random.Next(0, 174);
                int ranEY0 = random.Next(0, 174);

                int ranEX1 = random.Next(0, 174);
                int ranEY1 = random.Next(0, 174);

                Vector2I pointEOne = new Vector2I(ranEX0, ranEY0);
                Vector2I pointETwo = new Vector2I(ranEX1, ranEY1);

                var elipse = new FillEllipse(pointEOne, pointETwo, Color.White);
                drawingLib.AddElement(elipse);
                break;

            case "DrawRect":
                int ranRX0 = random.Next(0, 174);
                int ranRY0 = random.Next(0, 174);

                int ranRX1 = random.Next(0, 174);
                int ranRY1 = random.Next(0, 174);

                Vector2I pointROne = new Vector2I(ranRX0, ranRY0);
                Vector2I pointRTwo = new Vector2I(ranRX1, ranRY1);

                var rectangle = new FillRectangle(pointROne, pointRTwo, Color.White);
                drawingLib.AddElement(rectangle);
                break;

            case "DrawPolygon":
                var positions = new List <Vector2I>();

                for (int i = 0; i < random.Next(3, 16); i++)
                {
                    positions.Add(VectorUtils.GenerateRandomVector2I(random));
                }

                var polygon = new FillPolygon(positions, Color.White);
                drawingLib.AddElement(polygon);
                break;

            case "DrawTriangle":
                positions = new List <Vector2I>();

                positions.Add(new Vector2I(100, 1));
                positions.Add(new Vector2I(100, 100));
                positions.Add(new Vector2I(200, 150));

                polygon = new FillPolygon(positions, Color.White);
                drawingLib.AddElement(polygon);

                break;

            case "DrawCharacter":
                int      ranCX0  = random.Next(0, 174);
                int      ranCY0  = random.Next(0, 174);
                Vector2I posChar = new Vector2I(ranCX0, ranCY0);

                var character = new ResizableCharacter(posChar, 'E', Color.White, 1);
                drawingLib.AddElement(character);
                break;

            case "HelloWorld":
                int      ranTX0 = random.Next(0, 174);
                int      ranTY0 = random.Next(0, 174);
                Vector2I posT   = new Vector2I(ranTX0, ranTY0);

                text = new Text(posT, "0123456789", Color.White, 1, true);
                drawingLib.AddElement(text);
                break;

            case "UpdateText":
                if (text != null)
                {
                    text.UpdateValue("Hello World!");
                }
                break;

            case "Clear":
                drawingLib.Clear();
                break;
            }

            drawingLib.RunRenderer();
            Echo($"Tasks Left in Queue: {drawingLib.RenderQueueSize}");
        }