예제 #1
0
        public static void DrawAnnouncement(Bitmap B, AnnouncementDetails AD)
        {
            Graphics G  = Graphics.FromImage(B);
            Bitmap   B2 = new Bitmap(B.Width, B.Height);
            Graphics G2 = Graphics.FromImage(B2);

            G2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            G2.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            G.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.High;
            G.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            G.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;
            G2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;


            G.Clear(Color.Black);

            if (AD.Background != null)
            {
                RectangleF From = new RectangleF(0, 0, AD.Background.Width, AD.Background.Height);
                RectangleF To   = new RectangleF(0, 0, B.Width, B.Height);

                if (From.Width > To.Width || From.Height > To.Height)
                {
                    double fromas = From.Width / From.Height;
                    double toas   = To.Width / To.Height;
                    double scale  = 1;
                    if (fromas < toas)
                    {
                        scale  = From.Width / To.Width;
                        From.Y = From.Height / 2 - (float)(To.Height * scale) / 2;

                        From.Height = (float)(To.Height * scale);
                    }
                    else
                    {
                        scale      = From.Height / To.Height;
                        From.X     = From.Width / 2 - (float)(To.Width * scale) / 2;
                        From.Width = (float)(To.Width * scale);
                    }



                    Console.WriteLine("{0}", scale);
                }
                G.DrawImage(AD.Background, To, From, GraphicsUnit.Pixel);
            }

            for (int i = 0; i < 5; i++)
            {
                DrawTo(AD, G2, 10 + i * 5, true);
            }

            TINRSArtWorkRenderer ArtRender   = new TINRSArtWorkRenderer();
            Settings             TheSettings = new Settings();

            TheSettings.InvertSource = false;
            TheSettings.DegreesOff   = 14;
            //TheSettings.MaxSubDiv;


            ArtRender.BuildTree(B2, TheSettings);
            ArtRender.BuildStuff(B2, TheSettings);
            ArtRender.DrawTiling(TheSettings, B2, G, Color.Yellow, Color.Black, 1.2f, false);
            DrawTo(AD, G, 2, false);
        }
예제 #2
0
        public static void DrawIcon(int w, int h, Graphics G, string Label, float huerange = -1)
        {
            Bitmap               Output      = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics             g           = Graphics.FromImage(Output);
            TINRSArtWorkRenderer Rend        = new TINRSArtWorkRenderer();
            Settings             TheSettings = Rend.GetHashSettings(Label, huerange);



            TheSettings.InvertSource = true;
            //TheSettings.MaxSubDiv = 4;

            Bitmap   TileGfx = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics G3      = Graphics.FromImage(TileGfx);

            G3.Clear(Color.Transparent);
            float D  = 2;
            float x1 = D / 2;
            float x2 = w - x1;
            float y1 = D / 2;
            float y2 = h - x1;


            Font F = new Font("Panton ExtraBold", h * 0.5f, FontStyle.Bold);

            F = GetAdjustedFont(g, Label, F, w * 0.9f, h * 0.9f, 3, false);
            var S  = g.MeasureString(Label, F);
            var S2 = g.MeasureString("WO", F);

            S.Height = S2.Height;

            float BaseScale = w / 128.0f;

            GraphicsPath GP = new GraphicsPath();

            GP.AddString(Label, new FontFamily("Panton ExtraBold"), 0, F.Size * 1.333333f, new PointF(w / 2 - S.Width / 2, h / 2 - S.Height / 2), new StringFormat());

            Bitmap   M  = new Bitmap(w, h);
            Graphics G2 = Graphics.FromImage(M);

            G2.Clear(Color.White);
            G2.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            G2.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.High;
            G2.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;
            G2.SmoothingMode      = SmoothingMode.AntiAlias;

            RenderIconBackdrop(G2, Color.Black, TheSettings, x1, x2, y1, y2, 2, Rend);
            G2.DrawPath(new Pen(Color.Black, 5), GP);


            //            G2.DrawString(Letter.Text, F, new SolidBrush(Color.White), w / 2 - S.Width / 2, h / 2 - S.Height / 2);
            G2.DrawPath(new Pen(Color.White, Math.Max(2.0f, 6 * BaseScale)), GP);
            G2.FillPath(new SolidBrush(Color.White), GP);

            g.DrawPath(new Pen(TheSettings.BackGroundColor, 5), GP);

            Rend.BuildTree(M, TheSettings);
            Rend.BuildStuff(M, TheSettings);

            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.High;
            g.SmoothingMode      = SmoothingMode.AntiAlias;
            g.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;
            float BaseScale2 = 1.0f;

            // g.FillPath(new SolidBrush(Color.Teal), GP);
            TheSettings = Rend.GetHashSettings(Label, huerange);

            RenderIconBackdrop(g, TheSettings.BackGroundColor, TheSettings, x1, x2, y1, y2, 0, Rend);
            Rend.DrawTiling(TheSettings, M, G3, Color.FromArgb(40, Color.Black), Color.Black, Math.Max(3, 4.5f * BaseScale2), false);
            Rend.DrawTiling(TheSettings, M, G3, TheSettings.BackgroundHighlight, Color.Black, Math.Max(1.4f, 3 * BaseScale2), false);
            Rend.DrawTiling(TheSettings, M, G3, Color.FromArgb(100, 255, 255, 0), Color.Black, Math.Max(1.0f, 1.4f * BaseScale2), false);

            for (var i = 0; i < h; i++)
            {
                for (var j = 0; j < w; j++)
                {
                    var C = Output.GetPixel(j, i);
                    if (C.A > 0)
                    {
                        var TP = TileGfx.GetPixel(j, i);
                        var C2 = GerberLibrary.MathHelpers.Interpolate(C, TileGfx.GetPixel(j, i), TP.A / 255.0f);
                        Output.SetPixel(j, i, Color.FromArgb(C.A, C2));
                    }
                }
            }

            g.DrawPath(new Pen(Color.FromArgb(60, Color.Black), 3), GP);
            g.FillPath(new SolidBrush(Color.FromArgb(255, 255, 255)), GP);


            G.DrawImage(Output, 0, 0);
        }
예제 #3
0
        private static void RenderIconBackdrop(Graphics g, Color C, Settings TheSettings, float x1, float x2, float y1, float y2, int offset, TINRSArtWorkRenderer R)
        {
            R.TD.Create(TheSettings.TileType);
            var M = R.TD.NormalizeSize();
            var T = R.TD.DivisionSet[0];

            float w = x2 - x1;
            float h = y2 - y1;

            for (float s = 0.3f; s < .5; s += 0.05f)
            {
                List <PointF> P = new List <PointF>();
                P.Add(new PointF((T.A.x - M.x) * w * s + w / 2, (T.A.y - M.y) * h * s + h / 2));
                P.Add(new PointF((T.B.x - M.x) * w * s + w / 2, (T.B.y - M.y) * h * s + h / 2));
                P.Add(new PointF((T.C.x - M.x) * w * s + w / 2, (T.C.y - M.y) * h * s + h / 2));

                float ox           = (float)TheSettings.Rand.NextDouble() * w / 4;
                float oy           = (float)TheSettings.Rand.NextDouble() * h / 4;
                float baserotation = 360.0f * (float)TheSettings.Rand.NextDouble();
                for (int i = 0; i < 5; i++)
                {
                    Matrix Mm = new Matrix();
                    Mm.RotateAt(360.0f * baserotation + (360.0f * i) / 5.0f, new PointF(w / 2, h / 2));
                    Mm.Translate(ox, oy);
                    var Pa = P.ToArray();
                    Mm.TransformPoints(Pa);
                    //g.FillPolygon(new SolidBrush(C), Pa);

                    Matrix Mm2 = new Matrix();
                    Mm2.RotateAt(360.0f * baserotation - (360.0f * i) / 5.0f, new PointF(w / 2, h / 2));
                    Mm2.Translate(ox, oy);
                    //Mm2.Scale(-1, 1);
                    var Pa2 = P.ToArray();
                    Mm2.TransformPoints(Pa2);
                    g.FillPolygon(new SolidBrush(C), Pa2);
                }
            }

            //            g.FillEllipse(new SolidBrush(C), new RectangleF(x1 + 7, y1 + 7 , x2 - x1, y2 - y1));
        }
예제 #4
0
        private static void RenderIconBackdrop(Graphics g, Color C, Settings TheSettings, float x1, float x2, float y1, float y2, int offset, TINRSArtWorkRenderer R)
        {
            R.TD.Create(TheSettings.TileType);
            var M = R.TD.NormalizeSize();
            var T = R.TD.DivisionSet[0];

            float w = x2 - x1;
            float h = y2 - y1;

            for (float s = 0.6f; s < 2.0; s += 0.5f)
            {
                List <PointF> P = new List <PointF>();
                P.Add(new PointF((T.A.x - M.x) * w * s + w / 2, (T.A.y - M.y) * h * s + h / 2));
                P.Add(new PointF((T.B.x - M.x) * w * s + w / 2, (T.B.y - M.y) * h * s + h / 2));
                P.Add(new PointF((T.C.x - M.x) * w * s + w / 2, (T.C.y - M.y) * h * s + h / 2));

                Matrix Mm = new Matrix();
                Mm.RotateAt(360.0f * (float)TheSettings.Rand.NextDouble(), new PointF(w / 2, h / 2));
                var Pa = P.ToArray();
                Mm.TransformPoints(Pa);
                g.FillPolygon(new SolidBrush(C), Pa);
            }

            //            g.FillEllipse(new SolidBrush(C), new RectangleF(x1 + 7, y1 + 7 , x2 - x1, y2 - y1));
        }