public static Color32 CalculateShade(Color32 baseColor, float shading, ColorShade shade) { if (shade == ColorShade.Reference) { return new Color32 (baseColor.r, baseColor.g, baseColor.b, baseColor.a); } var col = Color32.Lerp (baseColor, shade == ColorShade.Darker ? UnityEngine.Color.black : UnityEngine.Color.white, shading); col.a = baseColor.a; return col; }
protected void Draw(int x, int y, ColorShade shade) { int pos = LineMath.PixelCoordinateToPosition (x, y, canvasWidth); if (pos < drawingLayer.Length) drawingLayer [pos] = shade; else { throw new System.IndexOutOfRangeException( string.Format("Position ({0}, {1}) that translates to index {2} is outside drawing layer (size {3}) of canvas (size {4} x {5})", x, y, pos, drawingLayer.Length, canvasWidth, canvasHeight)); } }
public static ColorShade[] NormExpand(ColorShade[] data, int width) { ColorShade[] ret = new ColorShade[data.Length]; System.Array.Copy (data, ret, data.Length); var offsets = GetKernel (width); int kernelSize = offsets.Length; for (int pos = 0; pos < data.Length; pos++) { if (data [pos] == ColorShade.None) ret [pos] = NormShade (offsets, kernelSize, data.Length, data, pos, false); } return ret; }
public void OnChangeColor(float value, ColorShade shade) { switch (shade) { case ColorShade.Red: _priceRed = GetColorPrice("RedValue", value); break; case ColorShade.Green: _priceGreen = GetColorPrice("GreenValue", value); break; case ColorShade.Blue: _priceBlue = GetColorPrice("BlueValue", value); break; } SetTotalPrice(); }
public void OnChangeColor(float value, ColorShade shade) { Color32 newColor = _image.color; switch (shade) { case ColorShade.Red: newColor.r = System.Convert.ToByte(value); break; case ColorShade.Green: newColor.g = System.Convert.ToByte(value); break; case ColorShade.Blue: newColor.b = System.Convert.ToByte(value); break; } SetColor(in newColor); }
public static Color getAndroidColor(TetrisColor color, ColorShade shade) { switch(shade) { case ColorShade.ReallyLight: return getAndroidReallyLightColor(color); case ColorShade.Light: return getAndroidLightColor(color); case ColorShade.Normal: return getAndroidColor(color); case ColorShade.Dark: return getAndroidDarkColor(color); case ColorShade.ReallyDark: return getAndroidReallyDarkColor(color); default: return Color.Black; }; }
public static ColorShade[] Erode(ColorShade[] data, int width) { ColorShade[] ret = new ColorShade[data.Length]; System.Array.Copy (data, ret, data.Length); var offsets = GetKernel (width); int kernelSize = offsets.Length; for (int pos = 0; pos < data.Length; pos++) { for (int i = 0; i < kernelSize; i++) { int testPos = pos + offsets[i]; if (testPos < 0 || testPos > data.Length || data[testPos] == ColorShade.None) { ret [pos] = ColorShade.None; break; } } } return ret; }
static ColorShade NormShade(int[] offsets, int kernelSize, int dataLength, ColorShade[] data, int pos, bool includeNoColor) { var counts = new int[4] {0, 0, 0, 0}; for (int i = 0; i < kernelSize; i++) { int testPos = pos + offsets [i]; if (testPos < 0 || testPos >= dataLength) counts [0]++; else { //Debug.Log(testPos + " " + data.Length); counts [System.Convert.ToInt32 (data [testPos])]++; } } int max = 0; ColorShade color = ColorShade.None; for (int i = includeNoColor ? 0 : 1; i < 4; i++) { if (counts [i] > max) { max = counts [i]; color = (ColorShade)i; } } return color; }
/// <summary> /// The to integer /// </summary> /// <param name="color">The color.</param> /// <param name="colorShade">The color shade.</param> /// <returns>The <see cref="int"/>.</returns> public static int ToInt(this Color color, ColorShade colorShade = ColorShade.Light) { int a = color.A; int r = color.R; int g = color.G; int b = color.B; var ratio = 1.00; if (colorShade == ColorShade.Medium) { ratio = 0.80; } else if (colorShade == ColorShade.Dark) { ratio = 0.64; } var c = (a << 24) + ((int)(r * ratio) << 16) + ((int)(g * ratio) << 8) + (int)(b * ratio); return(c); }
public UnityEngine.Color32 this[ColorShade shade] { get { switch (shade) { case ColorShade.Reference: return referenceColor; case ColorShade.Lighter: return lighterColor; case ColorShade.Darker: return darkerColor; default: return referenceColor; } } set { switch(shade) { case ColorShade.Reference: referenceColor = value; break; case ColorShade.Lighter: lighterColor = value; break; case ColorShade.Darker: darkerColor = value; break; } } }
void Fill(ColorShade shade) { Vector2 point; for (int x = 0, X = canvasWidth; x < X; x++) { for (int y = 0, Y = canvasHeight; y < Y; y++) { point = LineMath.PixelCoordinateToVector(x, y); if (PolygonMath.PointInPoly(point, polygon)) Draw (x, y, shade); } } }
protected void Draw(int pos, ColorShade shade) { drawingLayer [pos] = shade; }