コード例 #1
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            var canvas = new FormCanvas(Width, Height);

            var g = new Graphics(canvas);

            g.Clear(Colors.White);


            // var img = Image.FromBytes(File.ReadAllBytes("Myvar Logo Solid plain.ppm"), "ppm").ResizeImage(128, 128);
            // g.DrawImage(10, 10, img);


            var terminus = new SdfFont(File.ReadAllText("Terminus.fnt"),
                                       Image.FromBytes(File.ReadAllBytes("Terminus.ppm"), "ppm"));

            // g.DrawString(10, 10, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 14f, terminus, Colors.Black);
            // g.DrawString(10, 25, "abcdefghijklmnopqrstuvwxyz", 14f, terminus, Colors.Black);
            //  g.DrawString(10, 44, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 30f, terminus, Colors.Black);
            //   g.DrawString(10, 74, "abcdefghijklmnopqrstuvwxyz", 30f, terminus, Colors.Black);
            int x = 10;
            int y = 10;

            var s = "Hi";

            e.Graphics.Clear(System.Drawing.Color.White);
            for (int i = 1; i < 158; i++)
            {
                g.DrawString(x, y, s, i, terminus, Colors.Black);

                var size = g.MeasureString(s, i, terminus);

                y += size.Height + 2;

                if (y + 50 > Height)
                {
                    y  = 10;
                    x += size.Width;
                }


                e.Graphics.DrawImageUnscaled(canvas.Bitmap, 0, 0);
                e.Graphics.Flush();
                Update();
            }


            //g.DrawString(10, 100, "Hello World", 10f, terminus, Colors.Black);

            e.Graphics.Clear(System.Drawing.Color.White);
            e.Graphics.DrawImageUnscaled(canvas.Bitmap, 0, 0);
        }
コード例 #2
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            var canvas = new FormCanvas(Width, Height);

            var g = new Graphics(canvas);

            g.Clear(Colors.DarkCyan);

            //test code

            //FontTest(g);


            //g.IncludeClip(50, 50, 100, 100);

            g.FillRectangle(10, 20, 50, 50, Colors.Green);

            g.DrawLine(20, 30, 70, 60, Colors.Blue);
            g.DrawEllipse(40, 40, 20, 40, Colors.DarkKhaki);
            g.DrawRectangle(10, 10, 100, 100, Colors.BlanchedAlmond);

            g.FillEllipse(100, 100, 20, 40, Colors.DarkSeaGreen);

            g.DrawPath(new Point[]
            {
                new Point(200, 220),
                new Point(250, 210),
                new Point(300, 260),
            }, Colors.Aqua);


            g.FillPolygon(new Point[]
            {
                new Point(300, 300),
                new Point(350, 300),
                new Point(350, 350),
            }, Colors.Beige);


            g.DrawPolygon(new Point[]
            {
                new Point(300, 300),
                new Point(350, 300),
                new Point(350, 350),
            }, Colors.Red);

            g.FillPolygon(new Point[]
            {
                new Point(400, 300),
                new Point(450, 300),
                new Point(450, 450),
                new Point(500, 450),
            }, Colors.Beige);

            g.FillRectangle(25, 35, 100, 100, new Color(Colors.Red, 128));
            g.Clear(Colors.DarkCyan);

            FontTest.Draw(g);


            e.Graphics.Clear(System.Drawing.Color.White);
            e.Graphics.DrawImageUnscaled(canvas.Bitmap, 0, 0);
        }