public Turtle Print(Turtle printer, string input, int spacing = 1)
        {
            printer.ShowTurtle = false;
            int    width  = 64;
            int    height = 64;
            Bitmap image  = (Bitmap)Image.FromFile(input, true);

            for (int i = 0; i < image.Height; i++)
            {
                for (int j = 0; j < image.Width; j++)
                {
                    Color clr = image.GetPixel(j, i);
                    printer.SetColor(clr.R, clr.G, clr.B);
                    printer.Forward(1);
                }
                printer.CaptureScreenshot();
                printer.PenUp();
                printer.Rotate(90, false);
                printer.Forward(spacing);
                printer.Rotate(90, false);
                printer.Forward(image.Width);
                printer.Rotate(-180, false);
                printer.PenDown();
            }
            printer.ShowTurtle = true;
            return(printer);
        }
Exemple #2
0
 static Turtle TurleReturn(Turtle t, int lenght, double brushSize)
 {
     t.Rotate(90, false);
     t.Forward(brushSize);
     t.Rotate(90, false);
     t.Forward(lenght);
     t.Rotate(-180, false);
     return(t);
 }
Exemple #3
0
 void DrawSection(Turtle t, int p)
 {
     t.Forward(10);
     t.StoreTurtlePosition();
     t.Rotate(-45);
     t.Forward(p);
     t.RestoreTurtlePosition();
     t.Rotate(45);
     t.Forward(p);
     t.RestoreTurtlePosition(true);
 }
Exemple #4
0
 void rect(int x, int y, int line)
 {
     t.MoveTo(x, y);
     t.Rotate(-90, true);
     t.Forward(line);
     t.Rotate(-90);
     t.Forward(line);
     t.Rotate(-90);
     t.Forward(line);
     t.Rotate(-90);
     t.Forward(line);
 }
Exemple #5
0
        public Turtle Write(Turtle writer, string input, bool inv = false, double brushSize = 1, Font textFont = null, int width = 64, int height = 64)
        {
            if (input == string.Empty)
            {
                return(writer);
            }
            if (textFont == null)
            {
                textFont = new Font(SystemFonts.DefaultFont.FontFamily, 36, FontStyle.Regular);
            }
            char[]   chars = input.ToCharArray();
            string[] lines = new string[height];
            writer.SetBrushSize(brushSize);
            for (int ctr = 0; ctr < chars.Length; ctr++)
            {
                Bitmap image = CharToImage(chars[ctr], textFont, width, height);

                for (int h = 0; h < image.Height; h++)
                {
                    string line = string.Empty;
                    for (int w = 0; w < image.Width; w++)
                    {
                        Color color = image.GetPixel(w, h);
                        if ((color.A != 0) != inv)
                        {
                            line += '1';
                        }
                        else
                        {
                            line += '0';
                        }
                    }
                    lines[h] += line;
                }
            }
            foreach (string line in lines)
            {
                int    totalProceed = 0;
                int    temp         = 0;
                string lineCopy     = line;
                while (line.Length != totalProceed)
                {
                    writer   = penSet(lineCopy[0], writer);
                    temp     = LastIndexBeforeChange(lineCopy);
                    lineCopy = lineCopy.Substring(temp);
                    writer.Forward(temp);
                    totalProceed += temp;
                    //Console.WriteLine(totalProceed + "/" + line.Length);
                }
                writer.PenUp();
                writer = TurleReturn(writer, line.Length, brushSize);
            }
            return(writer);
        }
Exemple #6
0
        void DrawSection(Turtle t, int p)
        {
            for (int i = 0; i < 10; i++)
            {
                t.Forward(2);

                t.SetColor(90 + i * 15, 170, 200);
            }
            t.StoreTurtlePosition();
            t.Rotate(-45);
            for (int i = 0; i < p; i++)
            {
                t.Forward(1);
                t.SetColor(i + 100, 0, 0);
            }
            t.SetColor(90, 170, 200);
            t.RestoreTurtlePosition();
            t.Rotate(45);
            t.Forward(p);
            t.RestoreTurtlePosition(true);
        }
Exemple #7
0
 void Fwd()
 {
     t.Forward(10);
 }