本文整理汇总了C#中System.Drawing.Color类的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于System.Drawing命名空间,在下文中一共展示了Color类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: PrintWay
private void PrintWay(List<Location> loc, Color color, RadarForm form)
{
if (loc != null)
{
PointF[] points;
Point tempP;
Location ld;
if (loc.Count != 0)
{
points = new PointF[loc.Count + 1];
int i = 0;
foreach (Location lo in loc)
{
form.PrintCircle(color, form.OffsetY(lo.Y, ObjectManager.MyPlayer.Location.Y),
form.OffsetX(lo.X, ObjectManager.MyPlayer.Location.X), "");
tempP = new Point(form.OffsetY(lo.Y, ObjectManager.MyPlayer.Location.Y),
form.OffsetX(lo.X, ObjectManager.MyPlayer.Location.X));
points[i] = tempP;
i++;
}
ld = loc[0];
tempP = new Point(form.OffsetY(ld.Y, ObjectManager.MyPlayer.Location.Y),
form.OffsetX(ld.X, ObjectManager.MyPlayer.Location.X));
points[i] = tempP;
form.ScreenDc.DrawLines(new Pen(_colorWaypoints), points);
}
}
}
开发者ID:civicacid,项目名称:myevo,代码行数:28,代码来源:DrawWaypoints.cs
示例17: Create
/// <summary>
/// Create a new <see cref="Bitmap"/> instance using an array of <see cref="Color"/> pixels and the image width and height.
/// </summary>
/// <param name="colors"><see cref="Color"/> array containing the color of each pixel in the image.</param>
/// <param name="width">The width of the image.</param>
/// <param name="height">The height of the image.</param>
/// <returns>A new <see cref="Bitmap"/> instance created using the data provided.</returns>
public static Bitmap Create(Color[] colors, int width, int height)
{
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
BitmapData bitmapData = bitmap.LockBits
(
new Rectangle(0, 0, width, height),
ImageLockMode.ReadWrite,
bitmap.PixelFormat
);
unsafe
{
byte* p = (byte*)bitmapData.Scan0;
Parallel.For(0, height, y =>
{
for (int x = 0; x < width; x++)
{
int offset = (x * 4) + y * bitmapData.Stride;
Color color = colors[x + y * width];
p[offset] = color.B;
p[offset + 1] = color.G;
p[offset + 2] = color.R;
p[offset + 3] = color.A;
}
});
}
bitmap.UnlockBits(bitmapData);
return bitmap;
}
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:38,代码来源:BitmapHelper.cs
示例18: GetRemappedColor
public Color GetRemappedColor(Color original, int index)
{
return Color.FromArgb(original.A,
(int)Exts.Clamp((int)(scale * original.R + offset), 0, 255),
(int)Exts.Clamp((int)(scale * original.G + offset), 0, 255),
(int)Exts.Clamp((int)(scale * original.B + offset), 0, 255));
}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:7,代码来源:PaletteFromScaledPalette.cs
示例19: DrawZone
public static void DrawZone(Graphics g, Color color, int x, int y)
{
if (pen.Color != color)
pen = new Pen(color, 2.0f);
g.DrawRectangle(pen, new Rectangle(Display.ZoneCoordToPixel(x), Display.ZoneCoordToPixel(y), (int)Display.ZoneSize, (int)Display.ZoneSize));
}
开发者ID:SnakeSolidNL,项目名称:tools,代码行数:7,代码来源:Drawing.cs
示例20: ConvertDoubleArrayToBitmap
public static Bitmap ConvertDoubleArrayToBitmap(this int[][] doubleArray, Color defaultColor)
{
int width = doubleArray.GetLength(0);
int height = doubleArray[0].GetLength(0);
Bitmap bitmapReturn = new Bitmap(width, height);
Color pixelColor;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
pixelColor = defaultColor;
if (doubleArray[i][j] >= 0 && doubleArray[i][j] < 256)
pixelColor = Color.FromArgb(doubleArray[i][j], doubleArray[i][j], doubleArray[i][j]);
else if (doubleArray[i][j] >= 256 && doubleArray[i][j] < 512)
pixelColor = Color.FromArgb(0, 0, doubleArray[i][j] % 255);
else if (doubleArray[i][j] >= 512 && doubleArray[i][j] < 768)
pixelColor = Color.FromArgb(0, doubleArray[i][j] % 255, 0);
else if (doubleArray[i][j] >= 768 && doubleArray[i][j] < 1024)
pixelColor = Color.FromArgb(doubleArray[i][j] % 255, 0, 0);
bitmapReturn.SetPixel(i, j, pixelColor);
}
}
return bitmapReturn;
}
开发者ID:Amichai,项目名称:Prax,代码行数:26,代码来源:Utilities.cs
注:本文中的System.Drawing.Color类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论