本文整理汇总了C#中Color.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Color.Clone方法的具体用法?C# Color.Clone怎么用?C# Color.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.Clone方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetKeysAround
private static void SetKeysAround(uint rowStart, uint colStart)
{
var colors = new Color[6][];
var colorsColumns = new Color[22];
for (var i = 0; i < colorsColumns.Length; i++)
{
colorsColumns[i] = Color.Black;
}
for (var i = 0; i < colors.Length; i++)
{
colors[i] = (Color[]) colorsColumns.Clone();
}
var indexList = new List<Tuple<int, int>>
{
Tuple.Create(-1, -1),
Tuple.Create(-1, 0),
Tuple.Create(-1, +1),
Tuple.Create(0, -1),
Tuple.Create(0, 0),
Tuple.Create(0, +1),
Tuple.Create(+1, -1),
Tuple.Create(+1, 0),
Tuple.Create(+1, +1)
};
foreach (var tuple in indexList)
{
if (((2 + tuple.Item1) > 0 && (2 + tuple.Item1) < maxRows)
&& ((keyIndex + tuple.Item2) > 0 && (keyIndex + tuple.Item2) < maxCols))
{
float brightnessModifier = (tuple.Item1 == 0 && tuple.Item2 == 0) ? 0f : 0.85f;
colors[2 + tuple.Item1][keyIndex + tuple.Item2] = new Color((1f - brightnessModifier), 0f, 0f);
}
}
Keyboard.Instance.Set(new CustomGrid(colors));
if (keyIndex >= maxCols)
{
keyIndex = 0;
}
else
{
keyIndex++;
}
}
示例2: OnGUI
//.........这里部分代码省略.........
EditorGUI.EndProperty();
addRow(ref position, rowHeight);
addRow(ref position, rowHeight);
EditorGUI.LabelField(position, "Sprite Shattering Properties", EditorStyles.boldLabel);
addRow(ref position, rowHeight);
property.Next(false);
EditorGUI.BeginProperty(position, label, property);
property.vector2Value = EditorGUI.Vector2Field(position, new GUIContent("Explode From", "The position from which to apply the explosion force when " +
"exploding the shattered pieces of the sprite. The X co-ordinate should be 0 for the left edge of the sprite and 1 for the right edge, and " +
"the Y co-ordinate should be 0 for bottom of the sprite and 1 for the top, although the values can be outside this range. For example to " +
"make the sprite explode up from the bottom, co-ordinates of (0.5, 0) could be used."), property.vector2Value);
EditorGUI.EndProperty();
addRow(ref position, rowHeight);
property.Next(false);
EditorGUI.BeginProperty(position, label, property);
property.vector2Value = EditorGUI.Vector2Field(position, new GUIContent("Explosion Force", "The force to apply in the X and Y direction when " +
"exploding the shattered pieces of the sprite. A force of zero will make the sprite just collapse in its current position"),
property.vector2Value);
EditorGUI.EndProperty();
addRow(ref position, rowHeight);
//Display a preview texture with the cuts made. First display a "Preview" header.
addRow(ref position, rowHeight);
EditorGUI.LabelField(position, "Preview", EditorStyles.boldLabel);
addRow(ref position, rowHeight);
if (!textureImporter.isReadable) {
position.height *= 2;
EditorGUI.HelpBox(position, "Texture \"Read/Write\" flag not set!", MessageType.Error);
}
else {
int textureWidth = (int) spriteRenderer.sprite.rect.width;
int textureHeight = (int) spriteRenderer.sprite.rect.height;
//Calculate the texture width and height from the window width.
int previewTextureWidth = (int) (position.width * 0.75f);
int previewTextureHeight = (int) (((float) textureHeight / (float) textureWidth) * position.width * 0.75f);
Color[] sourcePixels = spriteRenderer.sprite.texture.GetPixels((int) spriteRenderer.sprite.rect.xMin, (int) spriteRenderer.sprite.rect.yMin,
(int) spriteRenderer.sprite.rect.width, (int) spriteRenderer.sprite.rect.height);
//If the preview texture is at least two pixels wide...
if (previewTextureWidth > 1) {
//Call the method that makes the cuts as these will be drawn onto the texture.
int[,] horizontalCutTop, verticalCutLeft;
((SpriteShatter.Shatter) property.serializedObject.targetObject).makeCuts(spriteRenderer.sprite, horizontalCuts, verticalCuts, randomSeed,
randomness, zigzagFrequency, zigzagAmplitude, out horizontalCutTop, out verticalCutLeft);
//Create the preview texture and set its pixels from the main texture.
Texture2D previewTexture = new Texture2D(previewTextureWidth, previewTextureHeight, TextureFormat.RGBA32, false);
previewTexture.hideFlags = HideFlags.HideAndDontSave;
Color[] previewTexturePixels = new Color[previewTextureWidth * previewTextureHeight];
for (int i = 0; i < previewTextureWidth; i++)
for (int j = 0; j < previewTextureHeight; j++)
previewTexturePixels[(j * previewTextureWidth) + i] = sourcePixels[(((j * textureHeight) / previewTextureHeight) * textureWidth) +
((i * textureWidth) / previewTextureWidth)];
//Loop over the cuts and draw them on the texture (white with a black outline to cover all texture colours).
Color[] originalPreviewTexturePixels = (Color[]) previewTexturePixels.Clone();
for (int l = 0; l < 2; l++) {
for (int i = 0; i < horizontalCuts; i++)
for (int j = 0; j < textureWidth; j++) {
int previewTextureX = (j * previewTextureWidth) / textureWidth;
int previewTextureY = (horizontalCutTop[i, j] * previewTextureHeight) / textureHeight;
if (originalPreviewTexturePixels[(previewTextureY * previewTextureWidth) + previewTextureX].a > 0.001f) {
for (int m = l == 0 ? -1 : 0; m <= (l == 0 ? 1 : 0); m++)
for (int k = l == 0 ? -1 : 0; k <= (l == 0 ? 1 : 0); k++) {
if (previewTextureX + m >= 0 && previewTextureX + m < previewTextureWidth && previewTextureY + k >= 0 &&
previewTextureY + k < previewTextureHeight)
previewTexturePixels[((previewTextureY + k) * previewTextureWidth) + previewTextureX + m] = l == 0 ? Color.black :
Color.white;
}
}
}
for (int i = 0; i < verticalCuts; i++)
for (int j = 0; j < textureHeight; j++) {
int previewTextureX = (verticalCutLeft[i, j] * previewTextureWidth) / textureWidth;
int previewTextureY = (j * previewTextureHeight) / textureHeight;
if (originalPreviewTexturePixels[(previewTextureY * previewTextureWidth) + previewTextureX].a > 0.001f) {
for (int m = l == 0 ? -1 : 0; m <= (l == 0 ? 1 : 0); m++)
for (int k = l == 0 ? -1 : 0; k <= (l == 0 ? 1 : 0); k++)
if (previewTextureX + m >= 0 && previewTextureX + m < previewTextureWidth && previewTextureY + k >= 0 &&
previewTextureY + k < previewTextureHeight)
previewTexturePixels[((previewTextureY + k) * previewTextureWidth) + previewTextureX + m] = l == 0 ? Color.black :
Color.white;
}
}
}
previewTexture.SetPixels(previewTexturePixels);
previewTexture.Apply();
//Draw the texture in the editor window.
position.xMin += position.width * 0.125f;
position.xMax -= position.width * 0.125f;
position.height = previewTextureHeight;
GUIStyle style = new GUIStyle();
style.normal.background = previewTexture;
EditorGUI.LabelField(position, GUIContent.none, style);
}
}
}
示例3: SetObject
public void SetObject( Vector3[] vertices, Color[] colors, int[,] ribs )
{
if ( vertices.Length != colors.Length )
{
throw new ArgumentException( "Number of colors must be equal to number of vertices." );
}
if ( ribs.GetLength( 1 ) != 2 )
{
throw new ArgumentException( "Ribs array must have 2 coordinates per rib." );
}
this.objectPoints = (Vector3[]) vertices.Clone( );
this.colors = (Color[]) colors.Clone( );
this.lines = (int[,]) ribs.Clone( );
Recalculate( );
}
示例4: PaletteTable
public PaletteTable(Color[] palette)
{
this.palette = (Color[])palette.Clone();
}
示例5: Stroke
public void Stroke(GraphicsPath path, Graphics g, int time, float opacity)
{
int num1 = 0;
int num2 = 0;
AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
path.FillMode = FillMode.Alternate;
g.SmoothingMode = base.OwnerDocument.SmoothingMode;
SpreadMethods methods1 = this.SpreadMethod;
bool flag1 = this.Units == Units.UserSpaceOnUse;
float single1 = this.CX;
float single2 = this.CY;
float single3 = this.R;
float single4 = this.FX;
float single5 = this.FY;
PointF[] tfArray2 = new PointF[7] { new PointF(single1, single2), new PointF(single1 + single3, single2), new PointF(single1 + (single3 * ((float) Math.Sin(1.8325957145940459))), single2 + (single3 * ((float) Math.Cos(1.8325957145940459)))), new PointF(single1 + (single3 * ((float) Math.Sin(1.3089969389957472))), single2 + (single3 * ((float) Math.Cos(1.3089969389957472)))), new PointF(single1, single2 + single3), PointF.Empty, PointF.Empty } ;
this.boundsPoints = tfArray2;
GraphicsPath path1 = this.gradientpath;
path1.Reset();
path1.AddEllipse((float) (single1 - single3), (float) (single2 - single3), (float) (2f * single3), (float) (2f * single3));
RectangleF ef1 = RectangleF.Empty;
RectangleF ef2 = PathFunc.GetBounds(path);
RectangleF ef3 = RectangleF.Empty;
this.coord.Reset();
if (flag1)
{
ef3 = ((SVG) base.OwnerDocument.DocumentElement).ViewPort;
}
else
{
ef2 = new RectangleF(0f, 0f, 1f, 1f);
ef3 = ef2;
ef1 = PathFunc.GetBounds(path);
this.coord.Translate(ef1.X, ef1.Y);
this.coord.Scale(ef1.Width, ef1.Height);
}
ColorBlend blend1 = new ColorBlend(this.Stops.Count);
Color[] colorArray1 = new Color[this.Stops.Count];
float[] singleArray1 = new float[this.Stops.Count];
SvgElementCollection collection1 = this.Stops;
for (int num3 = 0; num3 < collection1.Count; num3++)
{
GradientStop stop1 = (GradientStop) collection1[num3];
AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
int num4 = 0xff;
if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
{
if (stop1.Opacity <= 1f)
{
num4 = (int) (stop1.Opacity * 255f);
}
else
{
num4 = (int) stop1.Opacity;
}
}
num4 = (int) Math.Min((float) (opacity * 255f), (float) num4);
Color color1 = stop1.Color;
float single6 = Math.Min((float) 1f, Math.Max((float) 0f, stop1.ColorOffset));
colorArray1[num3] = Color.FromArgb(num4, color1.R, color1.G, color1.B);
singleArray1[num3] = single6;
}
float[] singleArray2 = (float[]) singleArray1.Clone();
Color[] colorArray2 = (Color[]) colorArray1.Clone();
Array.Sort(singleArray2, colorArray2);
Color color2 = colorArray2[0];
Color color3 = colorArray2[colorArray2.Length - 1];
if (singleArray2[0] != 0f)
{
float[] singleArray3 = (float[]) singleArray2.Clone();
Color[] colorArray3 = (Color[]) colorArray2.Clone();
singleArray2 = new float[singleArray2.Length + 1];
colorArray2 = new Color[colorArray2.Length + 1];
colorArray3.CopyTo(colorArray2, 1);
singleArray3.CopyTo(singleArray2, 1);
singleArray2[0] = 0f;
colorArray2[0] = color2;
}
if (singleArray2[singleArray2.Length - 1] != 1f)
{
float[] singleArray4 = (float[]) singleArray2.Clone();
Color[] colorArray4 = (Color[]) colorArray2.Clone();
singleArray2 = new float[singleArray2.Length + 1];
singleArray4.CopyTo(singleArray2, 0);
singleArray2[singleArray2.Length - 1] = 1f;
colorArray2 = new Color[colorArray2.Length + 1];
colorArray4.CopyTo(colorArray2, 0);
colorArray2[colorArray2.Length - 1] = color3;
}
if (methods1 == SpreadMethods.Pad)
{
float single7 = Math.Min((float) (single1 - single3), ef2.X);
float single8 = Math.Min((float) (single2 - single3), ef2.Y);
float single9 = Math.Max(single3, (float) (ef2.Width / 2f));
float single10 = this.cx - single3;
float single11 = this.r;
for (int num5 = 0; num5 < singleArray2.Length; num5++)
{
singleArray2[num5] = ((single10 + (single11 * singleArray2[num5])) - single7) / single9;
}
if (singleArray2[0] != 0f)
//.........这里部分代码省略.........
示例6: FillObject
public Color[,] FillObject(Color[,] input)
{
if (perimeterPixels == null)
return input;
Color[,] output = (Color[,])input.Clone();
for (int i = 0; i < perimeterListPixels.Count; i++)
{
int x1 = perimeterListPixels[i].X, y1 = perimeterListPixels[i].Y;
for (int j = 0; j < perimeterListPixels.Count; j++)
{
if (i == j)
continue;
int x2 = perimeterListPixels[j].X, y2 = perimeterListPixels[j].Y;
double distance = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
double stepXDistance = ((double)(x2 - x1)) / distance;
double stepYDistance = ((double)(y2 - y1)) / distance;
for (int k = 0; k < distance; k++)
{
int uv1X = OffsetX + x1 + ((int)Math.Round(stepXDistance * k));
int uv1Y = OffsetY + y1 + ((int)Math.Round(stepYDistance * k));
if (uv1X < 0) // For safety
uv1X = 0;
if (uv1X > output.GetLength(0) - 1)
uv1X = output.GetLength(0) - 1;
if (uv1Y < 0)
uv1Y = 0;
if (uv1Y > output.GetLength(1) - 1)
uv1Y = output.GetLength(1) - 1;
output[uv1X, uv1Y] = Color.Black;
}
}
}
return output;
}
示例7: ColorizeVectors
public Color[,] ColorizeVectors(Color[,] input)
{
if (LongestChord.firstPixel == null || LongestChord.secondPixel == null
|| LongestPerpendicularChord.firstPixel == null || LongestPerpendicularChord.secondPixel == null)
return input;
Color[,] output = (Color[,])input.Clone();
double angle = LongestChord.orientation;
double uv1CosAngle = Math.Cos(angle);
double uv1SinAngle = Math.Sin(angle);
double pAngle = Math.PI / 2;
double[] rotationArray = new double[] { Math.Cos(pAngle), -1.0 * Math.Sin(pAngle), Math.Sin(pAngle), Math.Cos(pAngle) };
Matrix<double> rotationMatrix = new DenseMatrix(2, 2, rotationArray);
Vector<double> unitVector1 = new DenseVector(new double[] { uv1CosAngle, uv1SinAngle });
Vector<double> unitVector2 = new DenseVector(new double[2]);
rotationMatrix.LeftMultiply(unitVector1, unitVector2);
double uv2CosAngle = unitVector2[0];
double uv2SinAngle = unitVector2[1];
int lcX = 0;
if (uv1CosAngle > 0)
if (LongestChord.firstPixel.X < LongestChord.secondPixel.X)
lcX = LongestChord.firstPixel.X;
else
lcX = LongestChord.secondPixel.X;
else
if (LongestChord.firstPixel.X < LongestChord.secondPixel.X)
lcX = LongestChord.secondPixel.X;
else
lcX = LongestChord.firstPixel.X;
int lcY = 0;
if (uv1SinAngle > 0)
if (LongestChord.firstPixel.Y < LongestChord.secondPixel.Y)
lcY = LongestChord.firstPixel.Y;
else
lcY = LongestChord.secondPixel.Y;
else
if (LongestChord.firstPixel.Y < LongestChord.secondPixel.Y)
lcY = LongestChord.secondPixel.Y;
else
lcY = LongestChord.firstPixel.Y;
for (int i = 0; i < LongestChord.distance; i++)
{
int uv1X = OffsetX + lcX + ((int)Math.Round(uv1CosAngle * i));
int uv1Y = OffsetY + lcY + ((int)Math.Round(uv1SinAngle * i));
output[uv1X, uv1Y] = Color.Red;
}
int lpcX = 0;
if (uv2CosAngle > 0)
if (LongestPerpendicularChord.firstPixel.X < LongestPerpendicularChord.secondPixel.X)
lpcX = LongestPerpendicularChord.firstPixel.X;
else
lpcX = LongestPerpendicularChord.secondPixel.X;
else
if (LongestPerpendicularChord.firstPixel.X < LongestPerpendicularChord.secondPixel.X)
lpcX = LongestPerpendicularChord.secondPixel.X;
else
lpcX = LongestPerpendicularChord.firstPixel.X;
int lpcY = 0;
if (uv2SinAngle > 0)
if (LongestPerpendicularChord.firstPixel.Y < LongestPerpendicularChord.secondPixel.Y)
lpcY = LongestPerpendicularChord.firstPixel.Y;
else
lpcY = LongestPerpendicularChord.secondPixel.Y;
else
if (LongestPerpendicularChord.firstPixel.Y < LongestPerpendicularChord.secondPixel.Y)
lpcY = LongestPerpendicularChord.secondPixel.Y;
else
lpcY = LongestPerpendicularChord.firstPixel.Y;
for (int i = 0; i < LongestPerpendicularChord.distance; i++)
{
int uv2X = OffsetX + lpcX + ((int)Math.Round(uv2CosAngle * i));
int uv2Y = OffsetY + lpcY + ((int)Math.Round(uv2SinAngle * i));
output[uv2X, uv2Y] = Color.Blue;
}
return output;
}
示例8: Colorize
public Color[,] Colorize(Color[,] input)
{
Color[,] output = (Color[,])input.Clone();
for (int i = -4; i < 5; i++)
{
for (int j = -4; j < 5; j++)
{
output[OffsetX + LongestChord.firstPixel.X + i, OffsetY + LongestChord.firstPixel.Y + j] = Color.Red;
output[OffsetX + LongestChord.secondPixel.X + i, OffsetY + LongestChord.secondPixel.Y + j] = Color.Orange;
output[OffsetX + LongestPerpendicularChord.firstPixel.X + i, OffsetY + LongestPerpendicularChord.firstPixel.Y + j] = Color.Blue;
output[OffsetX + LongestPerpendicularChord.secondPixel.X + i, OffsetY + LongestPerpendicularChord.secondPixel.Y + j] = Color.Cyan;
}
}
return output;
}
示例9: Stroke
public void Stroke(GraphicsPath path, Graphics g, int time, float opacity)
{
int num1 = 0;
int num2 = 0;
GraphicsContainer container1 = g.BeginContainer();
AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
g.SmoothingMode = base.OwnerDocument.SmoothingMode;
SpreadMethods methods1 = this.SpreadMethod;
bool flag1 = this.Units == Units.UserSpaceOnUse;
float single1 = this.X1;
float single2 = this.Y1;
float single3 = this.X2;
float single4 = this.Y2;
if ((single1 == single3) && (single2 == single4))
{
single1 -= 1E-05f;
single3 += 1E-05f;
}
float single5 = single1;
float single6 = single2;
float single7 = single3;
float single8 = single4;
RectangleF ef1 = RectangleF.Empty;
RectangleF ef2 = RectangleF.Empty;
Matrix matrix1 = this.Transform.Matrix.Clone();
PointF[] tfArray4 = new PointF[2] { new PointF(single1, single2), new PointF(single3, single4) } ;
PointF[] tfArray1 = tfArray4;
matrix1.TransformPoints(tfArray1);
single1 = tfArray1[0].X;
single3 = tfArray1[1].X;
single2 = tfArray1[0].Y;
single4 = tfArray1[1].Y;
bool flag2 = single2 == single4;
bool flag3 = single1 == single3;
float single9 = 1f;
this.coord = new Matrix();
this.ratiomatrix = new Matrix();
RectangleF ef3 = PathFunc.GetBounds(path);
if (flag1)
{
ef1 = ((SVG) base.OwnerDocument.DocumentElement).ViewPort;
}
else
{
ef3 = new RectangleF(0f, 0f, 1f, 1f);
ef1 = ef3;
ef2 = PathFunc.GetBounds(path);
this.coord.Translate(ef2.X, ef2.Y);
this.coord.Scale(ef2.Width, ef2.Width);
this.ratiomatrix.Scale(1f, ef2.Height / ef2.Width);
}
PointF tf1 = new PointF(single1, single2);
PointF tf2 = new PointF(single3, single4);
PointF tf3 = tf1;
PointF tf4 = tf2;
ColorBlend blend1 = new ColorBlend(this.Stops.Count);
Color[] colorArray1 = new Color[this.Stops.Count];
float[] singleArray1 = new float[this.Stops.Count];
SvgElementCollection collection1 = this.Stops;
for (int num3 = 0; num3 < collection1.Count; num3++)
{
GradientStop stop1 = (GradientStop) collection1[num3];
AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
int num4 = 0xff;
if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
{
if (stop1.Opacity <= 1f)
{
num4 = (int) (stop1.Opacity * 255f);
}
else
{
num4 = (int) stop1.Opacity;
}
}
num4 = (int) Math.Min((float) (opacity * 255f), (float) num4);
Color color1 = stop1.Color;
float single10 = Math.Min((float) 1f, Math.Max((float) 0f, stop1.ColorOffset));
colorArray1[num3] = Color.FromArgb(num4, color1.R, color1.G, color1.B);
singleArray1[num3] = single10;
}
float[] singleArray2 = (float[]) singleArray1.Clone();
Color[] colorArray2 = (Color[]) colorArray1.Clone();
Array.Sort(singleArray2, colorArray2);
Color color2 = colorArray2[0];
Color color3 = colorArray2[colorArray2.Length - 1];
float single11 = singleArray2[0];
float single12 = singleArray2[singleArray2.Length - 1];
if (singleArray2[0] != 0f)
{
float[] singleArray3 = (float[]) singleArray2.Clone();
Color[] colorArray3 = (Color[]) colorArray2.Clone();
singleArray2 = new float[singleArray2.Length + 1];
colorArray2 = new Color[colorArray2.Length + 1];
colorArray3.CopyTo(colorArray2, 1);
singleArray3.CopyTo(singleArray2, 1);
singleArray2[0] = 0f;
colorArray2[0] = color2;
}
if (singleArray2[singleArray2.Length - 1] != 1f)
//.........这里部分代码省略.........
示例10: Board
public Board(Color[,] colors)
{
Colors = (Color[,])colors.Clone();
FireBoardUpdated();
}
示例11: Palette
/// <summary>
///
/// </summary>
/// <param name="aclr"></param>
public Palette(Color[] aclr)
{
m_aclr = (Color[])aclr.Clone();
}