当前位置: 首页>>代码示例>>C#>>正文


C# Drawing.Color类代码示例

本文整理汇总了C#中System.Drawing.Color的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Color类属于System.Drawing命名空间,在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: averageColor

 private static Color averageColor(Color one, Color two, Color three, Color four)
 {
     int r = (one.R + two.R + three.R + four.R) / 4;
     int g = (one.G + two.G + three.G + four.G) / 4;
     int b = (one.B + two.B + three.B + four.B) / 4;
     return Color.FromArgb(r, g, b);
 }
开发者ID:RT-Projects,项目名称:RT.Util,代码行数:7,代码来源:PlasmaFractal.cs

示例2: ScrollBarThumb

        public ScrollBarThumb(ScrollBarThumbDefaults type)
        {
            this._imageAttributes = new ImageAttributes();
            this._imageAttributes.ClearColorKey();
            this._gripImageAttributes = new ImageAttributes();
            this._gripImageAttributes.ClearColorKey();
            switch (type)
            {
                case ScrollBarThumbDefaults.Normal:
                    this._color = SystemColors.ScrollBar;
                    this._gripColor = SystemColors.ControlText;
                    break;

                case ScrollBarThumbDefaults.Highlight:
                    this._color = SystemColors.ControlText;
                    this._gripColor = SystemColors.HighlightText;
                    break;
            }
            this._borderStyle = ScrollBarBorderStyle.Solid;
            this._borderColor = SystemColors.ControlText;
            this._gradientColor = new Resco.Controls.ScrollBar.GradientColor(FillDirection.Horizontal);
            this._gradientColor.PropertyChanged += new EventHandler(this.GradientColor_PropertyChanged);
            this._image = null;
            this._imageLayout = ScrollBarThumbImageLayout.Stretch;
            this._imageTransparentColor = System.Drawing.Color.Transparent;
            this._gripStyle = ScrollBarThumbGripStyle.Lines;
            this._gripImage = null;
            this._gripImageTransparentColor = System.Drawing.Color.Transparent;
            this._gripLines = 3;
        }
开发者ID:north0808,项目名称:haina,代码行数:30,代码来源:ScrollBarThumb.cs

示例3: CalculateGraphicsPathFromBitmap

        // From http://edu.cnzz.cn/show_3281.html
        public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            if (colorTransparent == Color.Empty)
                colorTransparent = bitmap.GetPixel(0, 0);

            for (int row = 0; row < bitmap.Height; row++)
            {
                int colOpaquePixel = 0;
                for (int col = 0; col < bitmap.Width; col++)
                {
                    if (bitmap.GetPixel(col, row) != colorTransparent)
                    {
                        colOpaquePixel = col;
                        int colNext = col;
                        for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
                            if (bitmap.GetPixel(colNext, row) == colorTransparent)
                                break;

                        graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1));
                        col = colNext;
                    }
                }
            }
            return graphicsPath;
        }
开发者ID:samarjeet27,项目名称:ynoteclassic,代码行数:27,代码来源:DrawHelper.cs

示例4: HSLColor

 public HSLColor(Color color)
 {
     RGB = color;
     H = (byte)((color.GetHue() / 360.0f) * 255);
     S = (byte)(color.GetSaturation() * 255);
     L = (byte)(color.GetBrightness() * 255);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:7,代码来源:HSLColor.cs

示例5: CustomBitmapRenderer

 public CustomBitmapRenderer()
 {
    BackgroundGradientColor = Color.Aqua;
    Background = Color.GreenYellow;
    ForegroundGradientColor = Color.RoyalBlue;
    Foreground = Color.MidnightBlue;
 }
开发者ID:arumata,项目名称:zxingnet,代码行数:7,代码来源:CustomBitmapRenderer.cs

示例6: SeparatorWidget

        public SeparatorWidget(string separator = "|", Color? backgroundColor = null, Color? foregroundColor = null)
        {
            this.separator = separator;

            this.backgroundColor = backgroundColor ?? Color.White;
            this.foregroundColor = foregroundColor ?? Color.Black;
        }
开发者ID:ryguasu,项目名称:windawesome,代码行数:7,代码来源:SeparatorWidget.cs

示例7: OptionsWindow_Load

        private void OptionsWindow_Load(object sender, System.EventArgs e)
        {
            hourColor = Properties.Settings.Default.HourColor;
            minuteColor = Properties.Settings.Default.MinuteColor;
            secondColor = Properties.Settings.Default.SecondColor;
            backColor = Properties.Settings.Default.BackColor;
            brushWeight = Properties.Settings.Default.Weight;
            spacing = Properties.Settings.Default.Spacing;
            _24HourFormat = Settings.Default.TimeFormat;

            btnSecondColor.BackColor = secondColor;
            btnHourColor.BackColor = hourColor;
            btnMinuteColor.BackColor = minuteColor;
            btnBackColor.BackColor = backColor;

            txtBrushWeight.Text = brushWeight.ToString();
            txtSpacing.Text = spacing.ToString();

            btnMinuteColor.Text = minuteColor.Name;
            btnHourColor.Text = hourColor.Name;
            btnSecondColor.Text = secondColor.Name;
            btnBackColor.Text = backColor.Name;

            chk24Hour.Checked = _24HourFormat;
        }
开发者ID:qubbit,项目名称:polaris,代码行数:25,代码来源:OptionsWindow.cs

示例8: ConvertImage

        public static void ConvertImage(Bitmap image, Graphics g, Color ForeColor, Color BackColor, bool isActive)
        {
            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                ColorMap[] colorMap = new ColorMap[2];
                colorMap[0] = new ColorMap();
                colorMap[0].OldColor = Color.FromArgb(0, 0, 0);
                colorMap[0].NewColor = ForeColor;

                colorMap[1] = new ColorMap();
                colorMap[1].OldColor = image.GetPixel(0, 0);
                colorMap[1].NewColor = isActive ? BackColor : Color.Transparent;

                imageAttributes.SetRemapTable(colorMap);

                g.DrawImage(
                   image,
                   new Rectangle(0, 0, image.Width, image.Height),
                   0, 0,
                   image.Width,
                   image.Height,
                   GraphicsUnit.Pixel,
                   imageAttributes);
            }
        }
开发者ID:armano2,项目名称:dockpanelsuite,代码行数:25,代码来源:DrawImageHelper.cs

示例9: AreEqual

 public static void AreEqual(Color expected, Color actual)
 {
   Assert.AreEqual(expected.R, actual.R, "R is not equal");
   Assert.AreEqual(expected.G, actual.G, "G is not equal");
   Assert.AreEqual(expected.B, actual.B, "B is not equal");
   Assert.AreEqual(expected.A, actual.A, "A is not equal");
 }
开发者ID:levesque,项目名称:Magick.NET,代码行数:7,代码来源:ColorAssert.cs

示例10: Write

 public void Write(uint x, uint y, Color colour)
 {
     Pen p = new Pen(colour);
       lock (image) {
     image.SetPixel((int)x, (int)(Height - y - 1), colour);
       }
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:7,代码来源:JpegOutput.cs

示例11: Pixel

		public Pixel( Color c )
		{
			B = c.B;
			G = c.G;
			R = c.R;
			A = c.A;
		}
开发者ID:attila3453,项目名称:alsing,代码行数:7,代码来源:SourceImage.cs

示例12: DrawItem

        // For Ownder Drawn TreeViews
        public static void DrawItem(this DrawTreeNodeEventArgs e, Color channelColor, TreeView treeView, bool useCheckmark)
        {
            if (treeView == null) {
                e.DrawDefault = true;
                return;
            }

            if (e.Bounds.Left < 0 || e.Bounds.Top < 0) {
                return;
            }

            var fillRect = new Rectangle(e.Node.Bounds.X, e.Node.Bounds.Y, treeView.Width - e.Node.Bounds.Left, e.Node.Bounds.Height);
            GenericBrush.Color = channelColor;

            bool selected;
            var view = treeView as MultiSelectTreeview;
            if (view != null) {
                selected = view.SelectedNodes.Contains(e.Node);
            }
            else {
                selected = (e.State & TreeNodeStates.Selected) != 0;
            }

            var rectBrush = selected && !useCheckmark ? SystemBrushes.Highlight : GenericBrush;
            e.Graphics.FillRectangle(rectBrush, fillRect);
            var stringBrush = selected && !useCheckmark ? SystemBrushes.HighlightText : channelColor.GetTextColor();
            e.Graphics.DrawString(e.Node.Text, treeView.Font, stringBrush, e.Bounds.Left, e.Bounds.Top);

            if (selected && useCheckmark) {
                e.Graphics.DrawString(Checkmark, treeView.Font, channelColor.GetTextColor(), fillRect.Right - 40, e.Bounds.Top);
            }
        }
开发者ID:jmcadams,项目名称:vplus,代码行数:33,代码来源:OwnerDrawnUtils.cs

示例13: DrawTextCentered

        public static void DrawTextCentered(this Font font,
			string text,
			Obj_AI_Base target,
			Color color,
			bool outline = false)
        {
            var measure = GetMeasured(font, text);
            var position = Drawing.WorldToScreen(target.Position);
            if (outline)
            {
                font.DrawText(
                    null, text, (int)(position.X + 1 - measure.Width * 0.5f),
                    (int)(position.Y + 1 - measure.Height * 0.5f), XDColor.Black);
                font.DrawText(
                    null, text, (int)(position.X - 1 - measure.Width * 0.5f),
                    (int)(position.Y - 1 - measure.Height * 0.5f), XDColor.Black);
                font.DrawText(
                    null, text, (int)(position.X + 1 - measure.Width * 0.5f),
                    (int)(position.Y - measure.Height * 0.5f), XDColor.Black);
                font.DrawText(
                    null, text, (int)(position.X - 1 - measure.Width * 0.5f),
                    (int)(position.Y - measure.Height * 0.5f), XDColor.Black);
            }
            font.DrawText(
                null, text, (int)(position.X - measure.Width * 0.5f), (int)(position.Y - measure.Height * 0.5f), new XDColor(color.R, color.G, color.B, color.A));
        }
开发者ID:VivianGit,项目名称:LeagueSharp,代码行数:26,代码来源:FontExtensions.cs

示例14: GetColor

		public static Color GetColor(float alpha, Color baseColor)
		{
            if (alpha >= 1) return baseColor;
            else if (alpha < 0) return Color.Transparent;

			return Color.FromArgb((int)(alpha * 255), baseColor);
		}
开发者ID:netgrim,项目名称:MapKit,代码行数:7,代码来源:Util.cs

示例15: Move

 public new void Move(float Dx, float Dy, float Dlg, float Dlv, Color BackColor, Graphics G)
 {
     RePain(Dlg, Dlv, BackColor, BorderWidth, 1, G);
     Xn += Dx;
     Yn += Dy;
     RePain(Dlg, Dlv, false, 1, G);
 }
开发者ID:EvgenyKarataev,项目名称:GraphicEditor,代码行数:7,代码来源:Pie.cs


注:本文中的System.Drawing.Color类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。