}                                                                                                                                         //mxd

        #endregion

        #region ================== Constructor / Disposer

        // Constructor for settings from configuration
        internal ColorCollection(Configuration cfg)
        {
            // Initialize
            colors       = new PixelColor[NUM_COLORS];
            brightcolors = new PixelColor[NUM_COLORS];
            darkcolors   = new PixelColor[NUM_COLORS];

            // Read all colors from config
            for (int i = 0; i < NUM_COLORS; i++)
            {
                // Read color
                colors[i] = PixelColor.FromInt(cfg.ReadSetting("colors.color" + i.ToString(CultureInfo.InvariantCulture), 0));
            }

            //mxd. Set new colors (previously these were defined in GZBuilder.default.cfg)
            if (colors[BACKGROUND].ToInt() == 0)
            {
                colors[BACKGROUND] = PixelColor.FromInt(-16777216);
            }
            if (colors[VERTICES].ToInt() == 0)
            {
                colors[VERTICES] = PixelColor.FromInt(-11425537);
            }
            if (colors[LINEDEFS].ToInt() == 0)
            {
                colors[LINEDEFS] = PixelColor.FromInt(-1);
            }
            if (colors[MODELWIRECOLOR].ToInt() == 0)
            {
                colors[MODELWIRECOLOR] = PixelColor.FromInt(-4259937);
            }
            if (colors[INFOLINECOLOR].ToInt() == 0)
            {
                colors[INFOLINECOLOR] = PixelColor.FromInt(-3750145);
            }
            if (colors[HIGHLIGHT].ToInt() == 0)
            {
                colors[HIGHLIGHT] = PixelColor.FromInt(-21504);
            }
            if (colors[SELECTION].ToInt() == 0)
            {
                colors[SELECTION] = PixelColor.FromInt(-49152);
            }
            if (colors[INDICATION].ToInt() == 0)
            {
                colors[INDICATION] = PixelColor.FromInt(-128);
            }
            if (colors[GRID].ToInt() == 0)
            {
                colors[GRID] = PixelColor.FromInt(-12171706);
            }
            if (colors[GRID64].ToInt() == 0)
            {
                colors[GRID64] = PixelColor.FromInt(-13018769);
            }
            if (colors[CROSSHAIR3D].ToInt() == 0)
            {
                colors[CROSSHAIR3D] = PixelColor.FromInt(-16711681);                                              // Unused!
            }
            if (colors[HIGHLIGHT3D].ToInt() == 0)
            {
                colors[HIGHLIGHT3D] = PixelColor.FromInt(-24576);
            }
            if (colors[SELECTION3D].ToInt() == 0)
            {
                colors[SELECTION3D] = PixelColor.FromInt(-49152);
            }
            if (colors[SCRIPTBACKGROUND].ToInt() == 0)
            {
                colors[SCRIPTBACKGROUND] = PixelColor.FromInt(-1);
            }
            if (colors[LINENUMBERS].ToInt() == 0)
            {
                colors[LINENUMBERS] = PixelColor.FromInt(-13921873);
            }
            if (colors[PLAINTEXT].ToInt() == 0)
            {
                colors[PLAINTEXT] = PixelColor.FromInt(-16777216);
            }
            if (colors[COMMENTS].ToInt() == 0)
            {
                colors[COMMENTS] = PixelColor.FromInt(-16744448);
            }
            if (colors[KEYWORDS].ToInt() == 0)
            {
                colors[KEYWORDS] = PixelColor.FromInt(-16741493);
            }
            if (colors[LITERALS].ToInt() == 0)
            {
                colors[LITERALS] = PixelColor.FromInt(-16776999);
            }
            if (colors[CONSTANTS].ToInt() == 0)
            {
                colors[CONSTANTS] = PixelColor.FromInt(-8372160);
            }

            // Set new thing colors
            if (colors[THINGCOLOR00].ToInt() == 0)
            {
                colors[THINGCOLOR00] = PixelColor.FromColor(Color.DimGray);
            }
            if (colors[THINGCOLOR01].ToInt() == 0)
            {
                colors[THINGCOLOR01] = PixelColor.FromColor(Color.RoyalBlue);
            }
            if (colors[THINGCOLOR02].ToInt() == 0)
            {
                colors[THINGCOLOR02] = PixelColor.FromColor(Color.ForestGreen);
            }
            if (colors[THINGCOLOR03].ToInt() == 0)
            {
                colors[THINGCOLOR03] = PixelColor.FromColor(Color.LightSeaGreen);
            }
            if (colors[THINGCOLOR04].ToInt() == 0)
            {
                colors[THINGCOLOR04] = PixelColor.FromColor(Color.Firebrick);
            }
            if (colors[THINGCOLOR05].ToInt() == 0)
            {
                colors[THINGCOLOR05] = PixelColor.FromColor(Color.DarkViolet);
            }
            if (colors[THINGCOLOR06].ToInt() == 0)
            {
                colors[THINGCOLOR06] = PixelColor.FromColor(Color.DarkGoldenrod);
            }
            if (colors[THINGCOLOR07].ToInt() == 0)
            {
                colors[THINGCOLOR07] = PixelColor.FromColor(Color.Silver);
            }
            if (colors[THINGCOLOR08].ToInt() == 0)
            {
                colors[THINGCOLOR08] = PixelColor.FromColor(Color.Gray);
            }
            if (colors[THINGCOLOR09].ToInt() == 0)
            {
                colors[THINGCOLOR09] = PixelColor.FromColor(Color.DeepSkyBlue);
            }
            if (colors[THINGCOLOR10].ToInt() == 0)
            {
                colors[THINGCOLOR10] = PixelColor.FromColor(Color.LimeGreen);
            }
            if (colors[THINGCOLOR11].ToInt() == 0)
            {
                colors[THINGCOLOR11] = PixelColor.FromColor(Color.PaleTurquoise);
            }
            if (colors[THINGCOLOR12].ToInt() == 0)
            {
                colors[THINGCOLOR12] = PixelColor.FromColor(Color.Tomato);
            }
            if (colors[THINGCOLOR13].ToInt() == 0)
            {
                colors[THINGCOLOR13] = PixelColor.FromColor(Color.Violet);
            }
            if (colors[THINGCOLOR14].ToInt() == 0)
            {
                colors[THINGCOLOR14] = PixelColor.FromColor(Color.Yellow);
            }
            if (colors[THINGCOLOR15].ToInt() == 0)
            {
                colors[THINGCOLOR15] = PixelColor.FromColor(Color.WhiteSmoke);
            }
            if (colors[THINGCOLOR16].ToInt() == 0)
            {
                colors[THINGCOLOR16] = PixelColor.FromColor(Color.LightPink);
            }
            if (colors[THINGCOLOR17].ToInt() == 0)
            {
                colors[THINGCOLOR17] = PixelColor.FromColor(Color.DarkOrange);
            }
            if (colors[THINGCOLOR18].ToInt() == 0)
            {
                colors[THINGCOLOR18] = PixelColor.FromColor(Color.DarkKhaki);
            }
            if (colors[THINGCOLOR19].ToInt() == 0)
            {
                colors[THINGCOLOR19] = PixelColor.FromColor(Color.Goldenrod);
            }

            //mxd. Set the rest of new colors (previously these were also defined in GZBuilder.default.cfg)
            if (colors[THREEDFLOORCOLOR].ToInt() == 0)
            {
                colors[THREEDFLOORCOLOR] = PixelColor.FromInt(-65536);
            }
            if (colors[SCRIPTINDICATOR].ToInt() == 0)
            {
                colors[SCRIPTINDICATOR] = PixelColor.FromInt(-16711936);
            }
            if (colors[SCRIPTBRACEHIGHLIGHT].ToInt() == 0)
            {
                colors[SCRIPTBRACEHIGHLIGHT] = PixelColor.FromInt(-16711681);
            }
            if (colors[SCRIPTBADBRACEHIGHLIGHT].ToInt() == 0)
            {
                colors[SCRIPTBADBRACEHIGHLIGHT] = PixelColor.FromInt(-65536);
            }
            if (colors[SCRIPTWHITESPACE].ToInt() == 0)
            {
                colors[SCRIPTWHITESPACE] = PixelColor.FromInt(-8355712);
            }
            if (colors[SCRIPTSELECTIONFORE].ToInt() == 0)
            {
                colors[SCRIPTSELECTIONFORE] = PixelColor.FromInt(-1);
            }
            if (colors[SCRIPTSELECTIONBACK].ToInt() == 0)
            {
                colors[SCRIPTSELECTIONBACK] = PixelColor.FromInt(-13395457);
            }
            if (colors[STRINGS].ToInt() == 0)
            {
                colors[STRINGS] = PixelColor.FromInt(-8388608);
            }
            if (colors[INCLUDES].ToInt() == 0)
            {
                colors[INCLUDES] = PixelColor.FromInt(-9868951);
            }
            if (colors[SCRIPTFOLDFORE].ToInt() == 0)
            {
                colors[SCRIPTFOLDFORE] = PixelColor.FromColor(SystemColors.ControlDark);
            }
            if (colors[SCRIPTFOLDBACK].ToInt() == 0)
            {
                colors[SCRIPTFOLDBACK] = PixelColor.FromColor(SystemColors.ControlLightLight);
            }
            if (colors[PROPERTIES].ToInt() == 0)
            {
                colors[PROPERTIES] = PixelColor.FromInt(-16752191);
            }

            // Create assist colors
            CreateAssistColors();

            // Create color correction table
            CreateCorrectionTable();

            // We have no destructor
            GC.SuppressFinalize(this);
        }
 //mxd
 public bool Equals(PixelColor other)
 {
     return(r == other.r && g == other.g && b == other.b && a == other.a);
 }
Exemple #3
0
        //mxd
        public void DrawLine3DFloor(int x1, int y1, int x2, int y2, ref PixelColor c, PixelColor c2)
        {
            Line2D line   = new Line2D(x1, y1, x2, y2);
            float  length = line.GetLength();

            if (length < DASH_INTERVAL * 2)
            {
                DrawLineSolid(x1, y1, x2, y2, ref c2);
            }
            else
            {
                float d1 = DASH_INTERVAL / length;
                float d2 = 1.0f - d1;


                Vector2D p1 = line.GetCoordinatesAt(d1);
                Vector2D p2 = line.GetCoordinatesAt(d2);

                DrawLineSolid(x1, y1, (int)p1.x, (int)p1.y, ref c2);
                DrawLineSolid((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y, ref c);
                DrawLineSolid((int)p2.x, (int)p2.y, x2, y2, ref c2);
            }
        }
Exemple #4
0
        // This draws a line normally
        // See: http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
        public void DrawLineSolid(int x1, int y1, int x2, int y2, ref PixelColor c, uint mask = 0xffffffff)
        {
            y1 = TransformY(y1);
            y2 = TransformY(y2);

            // Check if the line is outside the screen for sure.
            // This is quickly done by checking in which area both points are. When this
            // is above, below, right or left of the screen, then skip drawing the line.
            if (((x1 < 0) && (x2 < 0)) ||
                ((x1 > visiblewidth) && (x2 > visiblewidth)) ||
                ((y1 < 0) && (y2 < 0)) ||
                ((y1 > visibleheight) && (y2 > visibleheight)))
            {
                return;
            }

            // Distance of the line
            int dx = x2 - x1;
            int dy = y2 - y1;

            // Positive (absolute) distance
            int dxabs = Math.Abs(dx);
            int dyabs = Math.Abs(dy);

            // Half distance
            int x = dyabs >> 1;
            int y = dxabs >> 1;

            // Direction
            int sdx = Math.Sign(dx);
            int sdy = Math.Sign(dy);

            // Start position
            int px = x1;
            int py = y1;

            // When the line is completely inside screen,
            // then do an unchecked draw, because all of its pixels are
            // guaranteed to be within the memory range
            if ((x1 >= 0) && (x2 >= 0) && (x1 < visiblewidth) && (x2 < visiblewidth) &&
                (y1 >= 0) && (y2 >= 0) && (y1 < visibleheight) && (y2 < visibleheight))
            {
                // Draw first pixel
                pixels[py * width + px] = c;

                // Check if the line is more horizontal than vertical
                if (dxabs >= dyabs)
                {
                    for (int i = 0; i < dxabs; i++)
                    {
                        y += dyabs;
                        if (y >= dxabs)
                        {
                            y  -= dxabs;
                            py += sdy;
                        }
                        px += sdx;

                        // Draw pixel
                        if ((mask & (1 << (i & 0x7))) != 0)
                        {
                            pixels[py * width + px] = c;
                        }
                    }
                }
                // Else the line is more vertical than horizontal
                else
                {
                    for (int i = 0; i < dyabs; i++)
                    {
                        x += dxabs;
                        if (x >= dyabs)
                        {
                            x  -= dyabs;
                            px += sdx;
                        }
                        py += sdy;

                        // Draw pixel
                        if ((mask & (1 << (i & 0x7))) != 0)
                        {
                            pixels[py * width + px] = c;
                        }
                    }
                }
            }
            else
            {
                // Draw first pixel
                if ((px >= 0) && (px < visiblewidth) && (py >= 0) && (py < visibleheight))
                {
                    pixels[py * width + px] = c;
                }

                // Check if the line is more horizontal than vertical
                if (dxabs >= dyabs)
                {
                    for (int i = 0; i < dxabs; i++)
                    {
                        y += dyabs;
                        if (y >= dxabs)
                        {
                            y  -= dxabs;
                            py += sdy;
                        }
                        px += sdx;

                        // Draw pixel
                        if ((mask & (1 << (i & 0x7))) != 0)
                        {
                            if ((px >= 0) && (px < visiblewidth) && (py >= 0) && (py < visibleheight))
                            {
                                pixels[py * width + px] = c;
                            }
                        }
                    }
                }
                // Else the line is more vertical than horizontal
                else
                {
                    for (int i = 0; i < dyabs; i++)
                    {
                        x += dxabs;
                        if (x >= dyabs)
                        {
                            x  -= dyabs;
                            px += sdx;
                        }
                        py += sdy;

                        // Draw pixel
                        if ((mask & (1 << (i & 0x7))) != 0)
                        {
                            if ((px >= 0) && (px < visiblewidth) && (py >= 0) && (py < visibleheight))
                            {
                                pixels[py * width + px] = c;
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        // This draws a pixel normally
        public void DrawVertexSolid(int x, int y, int size, ref PixelColor c, ref PixelColor l, ref PixelColor d)
        {
            y = TransformY(y);

            int x1 = x - size;
            int x2 = x + size;
            int y1 = y - size;
            int y2 = y + size;

            // Do unchecked?
            if ((x1 >= 0) && (x2 < visiblewidth) && (y1 >= 0) && (y2 < visibleheight))
            {
                // Filled square
                for (int yp = y1; yp <= y2; yp++)
                {
                    for (int xp = x1; xp <= x2; xp++)
                    {
                        pixels[yp * width + xp] = c;
                    }
                }

                // Vertical edges
                for (int yp = y1 + 1; yp <= y2 - 1; yp++)
                {
                    pixels[yp * width + x1] = l;
                    pixels[yp * width + x2] = d;
                }

                // Horizontal edges
                for (int xp = x1 + 1; xp <= x2 - 1; xp++)
                {
                    pixels[y1 * width + xp] = l;
                    pixels[y2 * width + xp] = d;
                }

                // Corners
                pixels[y2 * width + x2] = d;
                pixels[y1 * width + x1] = l;
            }

            /*
             *          else
             *          {
             *                  // Filled square
             *                  for(yp = y - size; yp <= y + size; yp++)
             *                          for(xp = x - size; xp <= x + size; xp++)
             *                                  DrawPixelSolid(xp, yp, c);
             *
             *                  // Vertical edges
             *                  for(yp = y - size + 1; yp <= y + size - 1; yp++)
             *                  {
             *                          DrawPixelSolid(x - size, yp, l);
             *                          DrawPixelSolid(x + size, yp, d);
             *                  }
             *
             *                  // Horizontal edges
             *                  for(xp = x - size + 1; xp <= x + size - 1; xp++)
             *                  {
             *                          DrawPixelSolid(xp, y - size, l);
             *                          DrawPixelSolid(xp, y + size, d);
             *                  }
             *
             *                  // Corners
             *                  DrawPixelSolid(x + size, y + size, d);
             *                  DrawPixelSolid(x - size, y - size, l);
             *          }
             */
        }
Exemple #6
0
        //mxd
        private static Bitmap CreateLabelImage(string text, Font font, PixelColor color, PixelColor backcolor, bool drawbg, RectangleF textrect, RectangleF bgrect, Size texturesize, PointF textorigin)
        {
            Bitmap result = new Bitmap(texturesize.Width, texturesize.Height);

            using (Graphics g = Graphics.FromImage(result))
            {
                g.SmoothingMode      = SmoothingMode.HighQuality;
                g.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
                g.CompositingQuality = CompositingQuality.HighQuality;

                // Draw text
                // Draw text with BG
                if (drawbg)
                {
                    GraphicsPath p            = new GraphicsPath();
                    float        radius       = textorigin.X;
                    const float  outlinewidth = 1;

                    RectangleF pathrect = bgrect;
                    pathrect.Width  -= 1;
                    pathrect.Height -= 1;

                    // Left line
                    p.AddLine(pathrect.Left, pathrect.Bottom - radius + outlinewidth, pathrect.Left, pathrect.Top + radius);
                    p.AddArc(pathrect.Left, pathrect.Top, radius, radius, 180, 90);

                    // Top line
                    p.AddLine(pathrect.Left + radius, pathrect.Top, pathrect.Right - radius, pathrect.Top);
                    p.AddArc(pathrect.Right - radius, pathrect.Top, radius, radius, 270, 90);

                    // Right line
                    p.AddLine(pathrect.Right, pathrect.Top + radius, pathrect.Right, pathrect.Bottom - radius);
                    p.AddArc(pathrect.Right - radius, pathrect.Bottom - radius, radius, radius, 0, 90);

                    // Bottom line
                    p.AddLine(pathrect.Left + radius, pathrect.Bottom, pathrect.Left + radius, pathrect.Bottom);
                    p.AddArc(pathrect.Left, pathrect.Bottom - radius, radius, radius, 90, 90);

                    // Fill'n'draw bg
                    brush.Color = color.ToColor();

                    g.FillPath(brush, p);

                    pen.Color = backcolor.ToColor();

                    g.DrawPath(pen, p);

                    // Draw text
                    textrect.Inflate(4, 2);
                    brush.Color = backcolor.ToColor();

                    g.DrawString(text, font, brush, textrect, strFormat);
                }
                // Draw plain text
                else
                {
                    RectangleF plainbgrect = textrect;
                    if (text.Length > 1)
                    {
                        plainbgrect.Inflate(6, 2);
                    }

                    RectangleF plaintextrect = textrect;
                    plaintextrect.Inflate(6, 4);

                    brush.Color = backcolor.ToColor();
                    g.FillRectangle(brush, plainbgrect);

                    brush.Color = color.ToColor();
                    g.DrawString(text, font, brush, plaintextrect, strFormat);
                }
            }

            return(result);
        }
        // Constructor for settings from configuration
        internal ColorCollection(Configuration cfg)
        {
            // Initialize
            colors       = new PixelColor[NUM_COLORS];
            brightcolors = new PixelColor[NUM_COLORS];
            darkcolors   = new PixelColor[NUM_COLORS];

            // Read all colors from config
            for (int i = 0; i < NUM_COLORS; i++)
            {
                // Read color
                colors[i] = PixelColor.FromInt(cfg.ReadSetting("colors.color" + i.ToString(CultureInfo.InvariantCulture), 0));
            }

            // Set new colors
            if (colors[THINGCOLOR00].ToInt() == 0)
            {
                colors[THINGCOLOR00] = PixelColor.FromColor(Color.DimGray);
            }
            if (colors[THINGCOLOR01].ToInt() == 0)
            {
                colors[THINGCOLOR01] = PixelColor.FromColor(Color.RoyalBlue);
            }
            if (colors[THINGCOLOR02].ToInt() == 0)
            {
                colors[THINGCOLOR02] = PixelColor.FromColor(Color.ForestGreen);
            }
            if (colors[THINGCOLOR03].ToInt() == 0)
            {
                colors[THINGCOLOR03] = PixelColor.FromColor(Color.LightSeaGreen);
            }
            if (colors[THINGCOLOR04].ToInt() == 0)
            {
                colors[THINGCOLOR04] = PixelColor.FromColor(Color.Firebrick);
            }
            if (colors[THINGCOLOR05].ToInt() == 0)
            {
                colors[THINGCOLOR05] = PixelColor.FromColor(Color.DarkViolet);
            }
            if (colors[THINGCOLOR06].ToInt() == 0)
            {
                colors[THINGCOLOR06] = PixelColor.FromColor(Color.DarkGoldenrod);
            }
            if (colors[THINGCOLOR07].ToInt() == 0)
            {
                colors[THINGCOLOR07] = PixelColor.FromColor(Color.Silver);
            }
            if (colors[THINGCOLOR08].ToInt() == 0)
            {
                colors[THINGCOLOR08] = PixelColor.FromColor(Color.Gray);
            }
            if (colors[THINGCOLOR09].ToInt() == 0)
            {
                colors[THINGCOLOR09] = PixelColor.FromColor(Color.DeepSkyBlue);
            }
            if (colors[THINGCOLOR10].ToInt() == 0)
            {
                colors[THINGCOLOR10] = PixelColor.FromColor(Color.LimeGreen);
            }
            if (colors[THINGCOLOR11].ToInt() == 0)
            {
                colors[THINGCOLOR11] = PixelColor.FromColor(Color.PaleTurquoise);
            }
            if (colors[THINGCOLOR12].ToInt() == 0)
            {
                colors[THINGCOLOR12] = PixelColor.FromColor(Color.Tomato);
            }
            if (colors[THINGCOLOR13].ToInt() == 0)
            {
                colors[THINGCOLOR13] = PixelColor.FromColor(Color.Violet);
            }
            if (colors[THINGCOLOR14].ToInt() == 0)
            {
                colors[THINGCOLOR14] = PixelColor.FromColor(Color.Yellow);
            }
            if (colors[THINGCOLOR15].ToInt() == 0)
            {
                colors[THINGCOLOR15] = PixelColor.FromColor(Color.WhiteSmoke);
            }
            if (colors[THINGCOLOR16].ToInt() == 0)
            {
                colors[THINGCOLOR16] = PixelColor.FromColor(Color.LightPink);
            }
            if (colors[THINGCOLOR17].ToInt() == 0)
            {
                colors[THINGCOLOR17] = PixelColor.FromColor(Color.DarkOrange);
            }
            if (colors[THINGCOLOR18].ToInt() == 0)
            {
                colors[THINGCOLOR18] = PixelColor.FromColor(Color.DarkKhaki);
            }
            if (colors[THINGCOLOR19].ToInt() == 0)
            {
                colors[THINGCOLOR19] = PixelColor.FromColor(Color.Goldenrod);
            }
            if (colors[PORTALS].ToInt() == 0)
            {
                colors[PORTALS]   = PixelColor.FromColor(Color.Magenta);
                colors[PORTALS].a = 128;
            }

            // Create assist colors
            CreateAssistColors();

            // Create color correction table
            CreateCorrectionTable();

            // We have no destructor
            GC.SuppressFinalize(this);
        }