예제 #1
0
        public static void DrawLine(Vector3 from, Vector3 to, int width, System.Drawing.Color color)
        {
            var wts1 = Drawing.WorldToScreen(from);
            var wts2 = Drawing.WorldToScreen(to);

            Drawing.DrawLine(wts1[0], wts1[1], wts2[0], wts2[1], width, color);
        }
예제 #2
0
        // Checks whether a bitmap contains entirely the specified RGB value.
        public static bool IsRgbEntirely(Color expectedRgb, Bitmap bitmap)
        {
            using (var bitmapData = new PixelAccessor(bitmap, ImageLockMode.ReadOnly))
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        System.Drawing.Color color = bitmapData[x, y];

                        if (color.A == 0)
                        {
                            continue;
                        }

                        if ((color.R != expectedRgb.R) ||
                            (color.G != expectedRgb.G) ||
                            (color.B != expectedRgb.B))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
 public static void DrawCircle(this Vector3 position, float range, System.Drawing.Color color, bool checkValue)
 {
     if (checkValue)
     {
         Render.Circle.DrawCircle(position, range, color);
     }
 }
예제 #4
0
        public static void drawDmg(float dmg, System.Drawing.Color color)
        {
            var hpPosNow   = getHpPosAfterDmg(0);
            var hpPosAfter = getHpPosAfterDmg(dmg);

            fillHPBar(hpPosNow, hpPosAfter, color);
        }
예제 #5
0
        /// <summary>
        /// Save an element on a temporary list and override its color
        /// </summary>
        public static void AddToSelection(ElementId ReferenceElem, List <Element> completeList)
        {
            foreach (Element elem in completeList)
            {
                selectedElements.Add(elem);
            }
            selectedElements.Add(tools.doc.GetElement(ReferenceElem));

            OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();

            System.Drawing.Color colorSelect = MainForm.ColorSelected;
            byte r = colorSelect.R;
            byte b = colorSelect.B;
            byte g = colorSelect.G;

            //overrideGraphicSettings.SetProjectionFillColor(new Autodesk.Revit.DB.Color(r, g, b));
            overrideGraphicSettings.SetProjectionLineColor(new Autodesk.Revit.DB.Color(r, g, b));
            foreach (Element x in tools.selectedElements)
            {
                tools.doc.ActiveView.SetElementOverrides(x.Id, overrideGraphicSettings);
            }

            #if REVIT2020
            OverrideElemtColor.Graphics20192020(doc, ref overrideGraphicSettings, r, g, b);
            #elif REVIT2019
            OverrideElemtColor.Graphics20172020(doc, ref overrideGraphicSettings, r, g, b);
            #endif


            foreach (Element x in selectedElements)
            {
                //Override color of element
                doc.ActiveView.SetElementOverrides(x.Id, overrideGraphicSettings);
            }
        }
예제 #6
0
        public static void DrawCircleOnMinimap(Vector3 center,
                                               float radius,
                                               System.Drawing.Color color,
                                               int thickness = 5,
                                               int quality   = 30)
        {
            var pointList = new List <Vector3>();

            for (var i = 0; i < quality; i++)
            {
                var angle = i * Math.PI * 2 / quality;
                pointList.Add(
                    new Vector3(
                        center.X + radius * (float)Math.Cos(angle), center.Y + radius * (float)Math.Sin(angle),
                        center.Z));
            }

            for (var i = 0; i < pointList.Count; i++)
            {
                var a = pointList[i];
                var b = pointList[i == pointList.Count - 1 ? 0 : i + 1];

                var aonScreen = Drawing.WorldToMinimap(a);
                var bonScreen = Drawing.WorldToMinimap(b);

                Drawing.DrawLine(aonScreen.X, aonScreen.Y, bonScreen.X, bonScreen.Y, thickness, color);
            }
        }
예제 #7
0
        public static void drawLine(Vector3 pos1, Vector3 pos2, int bold, System.Drawing.Color color)
        {
            var wts1 = Drawing.WorldToScreen(pos1);
            var wts2 = Drawing.WorldToScreen(pos2);

            Drawing.DrawLine(wts1[0], wts1[1], wts2[0], wts2[1], bold, color);
        }
예제 #8
0
        // Drawing against a transparent black background blends
        // the 'alpha' pixels against black, leaving a black outline.
        // Interpolate between black and white
        // based on it's intensity to covert this 'outline' to
        // it's grayscale equivalent.
        public static void ConvertToGrey(Bitmap bitmap)
        {
            var transBlack = Color.Transparent;

            using (var bitmapData = new PixelAccessor(bitmap, ImageLockMode.ReadWrite))
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        System.Drawing.Color color = bitmapData[x, y];

                        if (color.ColorsEqual(transBlack))
                        {
                            continue;
                        }

                        var alpha = color.A / (255.0f);
                        var col   = Color.Lerp(Color.Transparent, Color.White, alpha);
                        color             = System.Drawing.Color.FromArgb(color.A, col.R, col.G, col.B);
                        bitmapData [x, y] = color;
                    }
                }
            }
        }
예제 #9
0
        public void drawDmg(float dmg, System.Drawing.Color color)
        {
            var hpPosNow   = getHpPosAfterDmg(0);
            var hpPosAfter = getHpPosAfterDmg(dmg);

            fillHPBar(hpPosNow, hpPosAfter, color);
            //fillHPBar((int)(hpPosNow.X - startPosition.X), (int)(hpPosAfter.X- startPosition.X), color);
        }
예제 #10
0
        private void ColorToStringButton_OnClick(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = Color.FromName("#00110000");

            string colorString = System.Drawing.ColorTranslator.ToHtml(color);

            MessageBox.Show(colorString);
        }
예제 #11
0
 public ListedHO(int duration, System.Drawing.Color objColor, int range, Vector3 position, float createdAt, Obj_AI_Base wardObj = null)
 {
     Duration  = duration;
     ObjColor  = objColor;
     Range     = range;
     Position  = position;
     CreatedAt = createdAt;
     WardObj   = wardObj;
 }
예제 #12
0
        private void fillHPBar(int to, int from, System.Drawing.Color color)
        {
            Vector2 sPos = startPosition;

            for (int i = from; i < to; i++)
            {
                Drawing.DrawLine(sPos.X + i, sPos.Y, sPos.X + i, sPos.Y + 9, 1, color);
            }
        }
        public static System.Drawing.Color GetCompatibleColor(System.Drawing.KnownColor color)
        {
            System.Drawing.Color drColor = GetCompatibleColorInternal(color);

            iTextSharp.text.BaseColor tsColor = new iTextSharp.text.BaseColor(drColor.R, drColor.G, drColor.B);


            return(GetCompatibleColorInternal(System.Drawing.Color.FromArgb(tsColor.R, tsColor.G, tsColor.B)));
        }
예제 #14
0
        public static void DrawTriangleOKTW(float radius, Vector3 position, System.Drawing.Color color, float bold = 1)
        {
            var     positionV2 = Drawing.WorldToScreen(position);
            Vector2 a          = new Vector2(positionV2.X + radius, positionV2.Y + radius / 2);
            Vector2 b          = new Vector2(positionV2.X - radius, positionV2.Y + radius / 2);
            Vector2 c          = new Vector2(positionV2.X, positionV2.Y - radius);

            Drawing.DrawLine(a[0], a[1], b[0], b[1], bold, color);
            Drawing.DrawLine(b[0], b[1], c[0], c[1], bold, color);
            Drawing.DrawLine(c[0], c[1], a[0], a[1], bold, color);
        }
예제 #15
0
        public static Notification ShowNotification(string message, System.Drawing.Color color, int duration = -1, bool dispose = true)
        {
            var notif = new Notification(message).SetTextColor(color);

            Notifications.AddNotification(notif);
            if (dispose)
            {
                Utility.DelayAction.Add(duration, () => notif.Dispose());
            }
            return(notif);
        }
예제 #16
0
        private static void fillHPBar(Vector2 from, Vector2 to, System.Drawing.Color color)
        {
            dxLine.Begin();

            dxLine.Draw(new[]
            {
                new Vector2((int)from.X, (int)from.Y + 4f),
                new Vector2((int)to.X, (int)to.Y + 4f)
            }, new ColorBGRA(255, 255, 00, 90));
            dxLine.End();
        }
예제 #17
0
        public static Bitmap GenerateTile(Bitmap baseBitmap, System.Drawing.Color color)
        {
            Bitmap bmp = new Bitmap(baseBitmap.Width, baseBitmap.Height);

            using (Graphics gfx = Graphics.FromImage(bmp))
                using (SolidBrush brush = new SolidBrush(color))
                {
                    gfx.FillRectangle(brush, 0, 0, baseBitmap.Width, baseBitmap.Height);
                }
            return(bmp);
        }
예제 #18
0
 private void UpdateScore(Control control, String text, System.Drawing.Color color)
 {
     if (control.InvokeRequired)
     {
         this.Invoke(new Action(() => UpdateScore(control, text, color)));
     }
     else
     {
         control.Text      = text;
         control.BackColor = color;
     }
 }
예제 #19
0
        /// <summary>
        /// Save an element on a temporary list and override its color
        /// </summary>
        public static void AddToSelection(Element ReferenceElem, List <string> ListElemntsStrings, List <Element> completeList, bool checkBox)
        {
            Category        category      = ReferenceElem.Category;
            BuiltInCategory enumCategory  = (BuiltInCategory)category.Id.IntegerValue;
            BuiltInCategory builtCategory = (BuiltInCategory)Enum.Parse(typeof(BuiltInCategory), ReferenceElem.Category.Id.ToString());

            if (checkBox == true)
            {
                foreach (Element elem in completeList)
                {
                    Category        cat     = elem.Category;
                    BuiltInCategory enumCat = (BuiltInCategory)cat.Id.IntegerValue;

                    if (enumCat.ToString() == "OST_FabricationDuctwork" &&
                        getNumber(elem) == "" && elem.get_Parameter(BuiltInParameter.FABRICATION_PART_DEPTH_IN) != null)
                    {
                        if (filterParam(ReferenceElem, elem, BuiltInParameter.ELEM_FAMILY_PARAM,
                                        BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, BuiltInParameter.FABRICATION_PART_DEPTH_IN,
                                        BuiltInParameter.FABRICATION_PART_WIDTH_IN, BuiltInParameter.FABRICATION_SERVICE_PARAM,
                                        BuiltInParameter.FABRICATION_PART_LENGTH))
                        {
                            selectedElements.Add(elem);
                        }
                    }
                }
                if (!selectedElements.Contains(ReferenceElem) && tools.getNumber(ReferenceElem) == "")
                {
                    selectedElements.Add(ReferenceElem);
                }
            }
            else
            {
                if (getNumber(ReferenceElem) == "")
                {
                    selectedElements.Add(ReferenceElem);
                }
            }


            OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();

            System.Drawing.Color colorSelect = MainForm.ColorSelected;
            byte r = colorSelect.R;
            byte b = colorSelect.B;
            byte g = colorSelect.G;

            overrideGraphicSettings.SetProjectionFillColor(new Autodesk.Revit.DB.Color(r, g, b));
            overrideGraphicSettings.SetProjectionLineColor(new Autodesk.Revit.DB.Color(r, g, b));
            foreach (Element x in tools.selectedElements)
            {
                tools.doc.ActiveView.SetElementOverrides(x.Id, overrideGraphicSettings);
            }
        }
예제 #20
0
        public static byte[] GetBuffer(IButtonPressAction action)
        {
            Image  image = action.Icon;
            string title = action.Title;

            if (image == null)
            {
                byte[] buf = new byte[8017 * 2];
                Array.Clear(buf, 0, buf.Length);
                Header1.CopyTo(buf, 0);
                Header2.CopyTo(buf, 8017);
                return(buf);
            }

            Bitmap     bmp   = ResizeImage(image, 72, 72);
            RectangleF rectf = new RectangleF(5, 50, 62, 15);

            if (!string.IsNullOrEmpty(title) && action.ShowTitleLabel)
            {
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.SmoothingMode     = SmoothingMode.AntiAlias;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                    g.DrawString(title, new Font(action.Titlefont.Family?.Source, (float)action.Titlefont.Size),
                                 new SolidBrush(Color.FromArgb(action.Titlefont.Color.Brush.Color.R, action.Titlefont.Color.Brush.Color.G, action.Titlefont.Color.Brush.Color.B)), rectf);

                    g.Flush();
                }
            }



            List <byte> imageBuf = new List <byte>(72 * 72 * 3);

            for (int i = 0; i < 72 * 72; i++)
            {
                System.Drawing.Color color = bmp.GetPixel(i / 72, i % 72);

                imageBuf.Add(color.B);
                imageBuf.Add(color.G);
                imageBuf.Add(color.R);
            }

            List <byte> bytes = Header1.Concat(imageBuf.Take(8017 - Header1.Length)).Concat(Header2).Concat(imageBuf.Skip(8017 - Header1.Length)).ToList();

            while (bytes.Count() < 8017 * 2)
            {
                bytes.Add(0);
            }
            return(bytes.ToArray());
        }
예제 #21
0
 //public Form2(System.Drawing.Color color)
 public Form2(string data, System.Drawing.Color colorResult)
 {
     InitializeComponent();
     hScrollBar1.Tag      = numericUpDown1;
     hScrollBar2.Tag      = numericUpDown2;
     hScrollBar3.Tag      = numericUpDown3;
     numericUpDown1.Tag   = hScrollBar1;
     numericUpDown2.Tag   = hScrollBar2;
     numericUpDown3.Tag   = hScrollBar3;
     numericUpDown1.Value = color.R;
     numericUpDown2.Value = color.G;
     numericUpDown3.Value = color.B;
 }
예제 #22
0
        public ColorRange()
        {
            InPortData.Add(new PortData("start", "The start color.", typeof(Value.Container)));
            InPortData.Add(new PortData("end", "The end color.", typeof(Value.Container)));
            InPortData.Add(new PortData("value", "The value between 0 and 1 of the selected color.", typeof(Value.Number)));

            OutPortData.Add(new PortData("color", "The selected color.", typeof(Value.Container)));

            RegisterAllPorts();

            _start = System.Drawing.Color.Blue;
            _end   = System.Drawing.Color.Red;
        }
예제 #23
0
        private void fillHPBar(Vector2 from, Vector2 to, System.Drawing.Color color)
        {
            dxLine.Begin();

            dxLine.Draw(new[]
            {
                new Vector2((int)from.X, (int)from.Y + 4f),
                new Vector2((int)to.X, (int)to.Y + 4f)
            }, new ColorBGRA(255, 255, 00, 90));
            // Vector2 sPos = startPosition;
            //Drawing.DrawLine((int)from.X, (int)from.Y + 9f, (int)to.X, (int)to.Y + 9f, 9f, color);

            dxLine.End();
        }
예제 #24
0
 // Converts the alpha channel into a greyscale premultiplied texture.
 public static void ConvertAlphaToGrey(Bitmap bitmap)
 {
     using (var bitmapData = new PixelAccessor(bitmap, ImageLockMode.ReadWrite))
     {
         for (int y = 0; y < bitmap.Height; y++)
         {
             for (int x = 0; x < bitmap.Width; x++)
             {
                 System.Drawing.Color color = bitmapData[x, y];
                 bitmapData[x, y] = System.Drawing.Color.FromArgb(color.A, color.A, color.A, color.A);
             }
         }
     }
 }
예제 #25
0
        private System.Drawing.Color ValidateColorForElement(ElementNode e, System.Drawing.Color defaultColor)
        {
            var colors = ColorProperty.ColorModule.getValidColorsForElementNode(e, false);

            if (colors.Any())
            {
                if (!colors.Contains(defaultColor))
                {
                    return(colors.First());
                }
            }

            return(defaultColor);
        }
        static public void FixCorners(ref Bitmap bmp, System.Drawing.KnownColor knownColor)
        {
            System.Drawing.Color color = GetCompatibleColor(knownColor);

            // Draw in 15-pixel colors in each of the borders
            int width  = bmp.Width;
            int height = bmp.Height;

            System.Drawing.Color cornColor = color;

            int cornerSize = 7;

            for (int x = 0; x <= cornerSize; x++)
            {
                for (int y = cornerSize; y >= 0; y--)
                {
                    // Top-Left
                    bmp.SetPixel(x, y, cornColor);

                    // Top-right
                    bmp.SetPixel(width - 1 - x, y, cornColor);

                    // Bottom-Left
                    bmp.SetPixel(x, height - 1 - y, cornColor);

                    // Bottom-Right
                    bmp.SetPixel(width - 1 - x, height - 1 - y, cornColor);
                }
            }

            int forceBorderSize = 2;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (
                        // Top
                        ((y < forceBorderSize)) ||
                        ((x < forceBorderSize)) ||
                        ((x > width - 1 - forceBorderSize)) ||
                        ((y > height - 1 - forceBorderSize)))
                    {
                        bmp.SetPixel(x, y, cornColor);
                    }
                }
            }
        }
예제 #27
0
        public static void Draw2DCircle(Vector2 position, float radius, System.Drawing.Color color, float width = 2F,
                                        int quality = -1)
        {
            if (quality == -1)
            {
                quality = (int)(radius / 7 + 11);
            }
            Vector2[] points = new Vector2[quality + 1];
            Vector2   rad    = new Vector2(0, radius);

            for (int i = 0; i <= quality; i++)
            {
                points[i] = (position + rad).RotateAroundPoint(position, PI2 * i / quality);
            }
            Line.DrawLine(color, width, points);
        }
예제 #28
0
        /// <summary>
        /// Add a filled rectangle
        /// </summary>
        /// <returns></returns>
        internal void AddFillRect(float x, float y, float width, float height, System.Drawing.Color c)
        {
            // Get the fill color
            double red   = c.R;
            double green = c.G;
            double blue  = c.B;

            red   = Math.Round((red / 255), 3);
            green = Math.Round((green / 255), 3);
            blue  = Math.Round((blue / 255), 3);

            elements.AppendFormat(NumberFormatInfo.InvariantInfo,
                                  "\r\nq\t{0} {1} {2} RG\t{0} {1} {2} rg\t{3} {4} {5} {6} re\tf\tQ\t",
                                  red, green, blue,                              // color
                                  x, pSize.yHeight - y - height, width, height); // positioning
        }
예제 #29
0
        public void Sphere()
        {
            System.Drawing.Image image1 = new Bitmap("R0010015.JPG");
            Bitmap imgBitmap            = new Bitmap(image1);

            Bitmap output = new Bitmap(imgBitmap.Width, imgBitmap.Height);

            for (int i = 0; i < imgBitmap.Width; i++)
            {
                for (int j = 0; j < imgBitmap.Height; j++)
                {
                    // map the angles from image coordinates
                    double theta = MapCoordinate(0.0, imgBitmap.Width - 1,
                                                 theta1, theta0, i);
                    double phi = MapCoordinate(0.0, imgBitmap.Height - 1, phi0,
                                               phi1, j);
                    // find the cartesian coordinates
                    double x = radius * Math.Sin(phi) * Math.Cos(theta);
                    double y = radius * Math.Sin(phi) * Math.Sin(theta);
                    double z = radius * Math.Cos(phi);
                    // apply rotation around X and Y axis to reposition the sphere
                    RotX(90, ref y, ref z);
                    RotY(0, ref x, ref z);
                    // plot only positive points
                    if (z > 0)
                    {
                        System.Drawing.Color color = imgBitmap.GetPixel(i, j);
                        System.Drawing.Brush brs   = new SolidBrush(color);
                        int ix = (int)x + 100;
                        int iy = (int)y + 100;


                        var kekColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);

                        output.SetPixel(ix, iy, color);

                        //SetPixel(kekColor, ix, iy);

                        brs.Dispose();
                    }
                }
            }

            _vm.SetImage(ToBitmapImage(output));
        }
예제 #30
0
        // Converts greyscale luminosity to alpha data.
        public static void ConvertGreyToAlpha(Bitmap bitmap)
        {
            using (var bitmapData = new PixelAccessor(bitmap, ImageLockMode.ReadWrite))
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        System.Drawing.Color color = bitmapData[x, y];

                        // Average the red, green and blue values to compute brightness.
                        int alpha = (color.R + color.G + color.B) / 3;

                        bitmapData[x, y] = System.Drawing.Color.FromArgb(alpha, 255, 255, 255);
                    }
                }
            }
        }
예제 #31
0
 public ListedHO(int duration, System.Drawing.Color objColor, int range, Vector3 position, float createdAt, Obj_AI_Base wardObj = null)
 {
     Duration = duration;
     ObjColor = objColor;
     Range = range;
     Position = position;
     CreatedAt = createdAt;
     WardObj = wardObj;
 }
예제 #32
0
        public ColorRange()
        {
            InPortData.Add(new PortData("start", "The start color.", typeof(Value.Container)));
            InPortData.Add(new PortData("end", "The end color.", typeof(Value.Container)));
            InPortData.Add(new PortData("value", "The value between 0 and 1 of the selected color.", typeof(Value.Number)));

            OutPortData.Add(new PortData("color", "The selected color.", typeof(Value.Container)));

            RegisterAllPorts();

            ArgumentLacing = LacingStrategy.Longest;

            _start = System.Drawing.Color.Blue;
            _end = System.Drawing.Color.Red;
        }
예제 #33
0
 public JungleBuffs(int number, string buffName, System.Drawing.Color color)
 {
     Number = number;
     BuffName = buffName;
     Color = color;
 }
예제 #34
0
        public override Value Evaluate(FSharpList<Value> args)
        {
            _start = (System.Drawing.Color)((Value.Container)args[0]).Item;
            _end = (System.Drawing.Color)((Value.Container)args[1]).Item;
            var value = ((Value.Number)args[2]).Item;

            if (value > 1.0 || value < 0.0)
                throw new Exception("Please enter a value between 0.0 and 1.0");

            OnRequestChangeColorRange(this, EventArgs.Empty);

            var selRed = (int)(_start.R + (_end.R - _start.R)*value);
            var selGreen = (int)(_start.G + (_end.G - _start.G)*value);
            var selBlue = (int)(_start.B + (_end.B - _start.B)*value);

            var returnColor = System.Drawing.Color.FromArgb(selRed, selGreen, selBlue);
            return Value.NewContainer(returnColor);
        }
예제 #35
0
 public PassiveBuffs(string championName, string buffName, System.Drawing.Color color)
 {
     ChampionName = championName;
     BuffName = buffName;
     Color = color;
 }