static void Load () { mLoaded = true; mPartial = EditorPrefs.GetString("NGUI Partial"); mFontName = EditorPrefs.GetString("NGUI Font Name"); mAtlasName = EditorPrefs.GetString("NGUI Atlas Name"); mSpriteName = EditorPrefs.GetString("NGUI Selected Sprite"); mFontData = GetObject("NGUI Font Asset") as TextAsset; mFontTexture = GetObject("NGUI Font Texture") as Texture2D; mFont = GetObject("NGUI Font") as UIFont; mAtlas = GetObject("NGUI Atlas") as UIAtlas; mAtlasPadding = EditorPrefs.GetInt("NGUI Atlas Padding", 1); mAtlasTrimming = EditorPrefs.GetBool("NGUI Atlas Trimming", true); mAtlasPMA = EditorPrefs.GetBool("NGUI Atlas PMA", true); mUnityPacking = EditorPrefs.GetBool("NGUI Unity Packing", true); mForceSquare = EditorPrefs.GetBool("NGUI Force Square Atlas", true); mPivot = (UIWidget.Pivot)EditorPrefs.GetInt("NGUI Pivot", (int)mPivot); mLayer = EditorPrefs.GetInt("NGUI Layer", -1); mDynFont = GetObject("NGUI DynFont") as Font; mDynFontSize = EditorPrefs.GetInt("NGUI DynFontSize", 16); mDynFontStyle = (FontStyle)EditorPrefs.GetInt("NGUI DynFontStyle", (int)FontStyle.Normal); mColorMode = (ColorMode)EditorPrefs.GetInt("NGUI Color Mode", (int)ColorMode.Blue); mAllDCs = EditorPrefs.GetBool("NGUI All DCs", false); if (mLayer < 0 || string.IsNullOrEmpty(LayerMask.LayerToName(mLayer))) mLayer = -1; if (mLayer == -1) mLayer = LayerMask.NameToLayer("UI"); if (mLayer == -1) mLayer = LayerMask.NameToLayer("GUI"); if (mLayer == -1) mLayer = 5; EditorPrefs.SetInt("UI Layer", mLayer); LoadColor(); }
public Surface( int width, int height, ColorMode colorMode ) { this.Width = width; this.Height = height; this.ColorMode = colorMode; this.BytesPerPixel = ( int )colorMode; this.Data = new byte[ width * height * ( int )colorMode ]; }
public SpawnSpiderWaveAction(string spPoint, List<AIAction> def, List<AIAction> close, List<AIAction> att, float del = 0f) { colorMode = ColorMode.RANDOM; spawnPoint = spPoint; defaultActions = def; closeActions = close; attackChipActions = att; delay = del; }
/// <summary> /// Renders the IImageProvider into a Bitmap. If the passed Bitmap is non-null, and it matches the passed size and color mode, it will be reused. Otherwise this method creates a new Bitmap. /// </summary> /// <param name="imageProvider">The image provider to render the image content of.</param> /// <param name="bitmap">The Bitmap to reuse, if possible. If null is passed, a new Bitmap is created.</param> /// <param name="size">The desired size of the rendered image.</param> /// <param name="outputOption">Specifies how to fit the image into the rendered rectangle, if the aspect ratio differs.</param> /// <returns>A task resulting in either the reused Bitmap, or a new one if necessary.</returns> public static Task<Bitmap> GetBitmapAsync(this IImageProvider imageProvider, Bitmap bitmap, Size size, ColorMode colorMode, OutputOption outputOption) { if (bitmap == null || bitmap.Dimensions != size || bitmap.ColorMode != colorMode) { bitmap = new Bitmap(size, colorMode); } return imageProvider.GetBitmapAsync(bitmap, outputOption).AsTask(); }
public Surface( int width, int height, ColorMode colorMode, byte[] data ) { if( data.Length != ( width * height * ( int )colorMode ) ) throw new ArgumentOutOfRangeException( "data", "data is not the right size" ); this.Width = width; this.Height = height; this.ColorMode = colorMode; this.BytesPerPixel = ( int )colorMode; this.Data = data; }
public SpawnSpiderWaveAction(bool current, int colorOffset, string spPoint, List<AIAction> def, List<AIAction> close, List<AIAction> att, float del = 0f) { colorMode = ColorMode.CURRENT; this.colorOffset = colorOffset; spawnPoint = spPoint; defaultActions = def; closeActions = close; attackChipActions = att; delay = del; }
private void SwitchToNextColorMode() { _currentMode++; if (_currentMode > ColorMode.Unicolor) { _currentMode = ColorMode.SoftRandom; } SenseHat.Display.Clear(); }
public static Format ConvertToFormat(ColorMode mode) { switch (mode) { case ColorMode.Bit16: throw new NotSupportedException(); case ColorMode.Bit32: return Format.R8G8B8A8_UNorm; default: throw new NotImplementedException(mode.ToString()); } }
public static Format ConvertToFormat(ColorMode mode) { switch (mode) { case ColorMode.Bit16: return Format.A4R4G4B4; case ColorMode.Bit32: return Format.A8R8G8B8; default: throw new NotImplementedException(mode.ToString()); } }
/// <summary> /// Renders the IImageProvider into a Bitmap. If the passed Bitmap is non-null, and it matches the passed size and color mode, it will be reused. Otherwise this method creates a new Bitmap. /// </summary> /// <param name="imageProvider">The image provider to render the image content of.</param> /// <param name="bitmap">The Bitmap to reuse, if possible. If null is passed, a new Bitmap is created.</param> /// <param name="size">The desired size of the rendered image.</param> /// <param name="outputOption">Specifies how to fit the image into the rendered rectangle, if the aspect ratio differs.</param> /// <returns>A task resulting in either the reused Bitmap, or a new one if necessary.</returns> public static async Task<Bitmap> GetBitmapAsync(this IImageProvider imageProvider, Bitmap bitmap, Size size, ColorMode colorMode, OutputOption outputOption) { if (bitmap == null || bitmap.Dimensions != size || bitmap.ColorMode != colorMode) { bitmap = new Bitmap(size, colorMode); } using (var renderer = new BitmapRenderer(imageProvider, bitmap, outputOption)) { return await renderer.RenderAsync().AsTask().ConfigureAwait(false); } }
public MSSensorMUXBase (SensorPort Port, MSSensorMUXPort Address, ColorMode SensorMode) : base (Port, (byte)Address, I2CMode.LowSpeed) { base.Initialise (); if (SensorMode == ColorMode.Reflection) Mode = 0; else if (SensorMode == ColorMode.Ambient) Mode = 1; else if (SensorMode == ColorMode.Color) Mode = 2; NumberOfM = 2; SetSensorMode (); }
public static Color Lerp(Color original, Color other, float t, ColorMode mode = ColorMode.replace) { switch(mode) { case ColorMode.replace: return Color.Lerp(original, other, t); case ColorMode.add: return Color.Lerp(original, original + other, t); case ColorMode.subtract: return Color.Lerp(original, original - other, t); case ColorMode.multiply: return Color.Lerp(original, original * other, t); case ColorMode.divide: return Color.Lerp(original, new Color(original.r / other.r, original.g / other.g, original.b / other.b, original.a / other.a), t); } return original; }
public LineStyle(string rrggbbaa, ColorMode mode, int width) { this._color = rrggbbaa; this._colorMode = mode; this._width = width; }
/// <summary> /// Basic implementation of a map src solid filling renderer. /// </summary> /// <param name="clip">The clipping rectangle.</param> /// <param name="scanner">The scans to render.</param> /// <param name="dest">The map to render to.</param> /// <param name="src">The source map.</param> /// <param name="offset">The offset of the source map.</param> /// <param name="mode">The color blending mode to use.</param> /// <param name="isAA">True if anti-aliasing is enabled.</param> public static void SolidCopyRender(Rectangle clip, Scanner scanner, DataMap<ARGB> dest, DataMap<ARGB> src, Point2D offset, ColorMode mode = ColorMode.NORMAL, bool isAA = true) { IUnsafeMap uDest = dest as IUnsafeMap; IUnsafeMap uSrc = src as IUnsafeMap; if(uDest == null) { throw new InvalidOperationException("Destination image does not support advanced color rendering!"); } if(uSrc == null) { throw new InvalidOperationException("Source image does not support advanced color rendering!"); } byte* addr = uDest.BeginUnsafeOperation(); int width = dest.Width; int stride = uDest.GetStride(); byte* srcAddr = uSrc.BeginUnsafeOperation(); int srcWidth = src.Width; int srcStride = uSrc.GetStride(); for(int y = scanner.yMin; y <= scanner.yMax; y++) { double x1 = Max(scanner[y].min, clip.Min.X); double x2 = Min(scanner[y].max, clip.Max.X); //Anti-Aliasing variables //x1 vars are x min side //x2 vars are x max side //xb vars are y min side //xa vars are y max side double x1b = 0, x1a = 0; double x2b = 0, x2a = 0; int left; int right; if(isAA) { bool hasMin = false, hasMax = false; //if not at ymin or ymin is a clipped min (aka we have another "ghost" scan) if(y > scanner.yMin || scanner.isYMinClipped) { x1b = Max(scanner[y - 1].min, clip.Min.X); x2b = Min(scanner[y - 1].max, clip.Max.X); x1b = (x1b + x1) / 2; x2b = (x2b + x2) / 2; hasMin = true; } //if not at ymax or ymax is a clipped max (aka we have another "ghost" scan) if(y < scanner.yMax || scanner.isYMaxClipped) { x1a = Max(scanner[y + 1].min, clip.Min.X); x2a = Min(scanner[y + 1].max, clip.Max.X); x1a = (x1a + x1) / 2; x2a = (x2a + x2) / 2; hasMax = true; } if(!hasMin) { //if single line shape, just make everything literal if(!hasMax) { x1b = x1a = x1; x2b = x2a = x2; }else//if at ymin, extrapolate max->current into current->min { x1b = x1 - (x1a - x1); x2b = x2 - (x2a - x2); } }else//if at ymax, extrapolate min->current into current->max if(!hasMax) { x1a = x1 + (x1 - x1b); x2a = x2 + (x2 - x2b); } //if aa, round toward center, otherwise round away to match default renderer left = (int)Math.Ceiling(Max(x1b, x1a)); right = (int)Math.Floor(Min(x2b, x2a)); }else { //if not aa, round away to match default renderer left = (int)Math.Floor(x1); right = (int)Math.Ceiling(x2); } //if valid center if(left <= right) { //solid fill with blend modes byte* ptr = addr + (left + (y * width)) * stride; byte* srcPtr = srcAddr + ((left + offset.X) + ((y + offset.Y) * srcWidth)) * srcStride; byte* endPtr = ptr + (right - left + 1) * stride; switch(mode) { case ColorMode.BLEND: { while(ptr != endPtr) { //*((ARGB*)ptr) &= *((ARGB*)srcPtr); //manually inline blending ARGB srcColor = *(ARGB*)srcPtr; ARGB color = *(ARGB*)ptr; int aComp = 255 - srcColor.A; color = new ARGB{A = (byte)(srcColor.A + color.A), R = (byte)(((srcColor.R * srcColor.A) + (color.R * aComp)) >> 8), G = (byte)(((srcColor.G * srcColor.A) + (color.G * aComp)) >> 8), B = (byte)(((srcColor.B * srcColor.A) + (color.B * aComp)) >> 8)}; *(ARGB*)ptr = color; ptr += stride; srcPtr += srcStride; } break; } case ColorMode.NORMAL: { while(ptr != endPtr) { *((ARGB*)ptr) = *((ARGB*)srcPtr); ptr += stride; srcPtr += srcStride; } break; } case ColorMode.MASK: { while(ptr != endPtr) { if((*((ARGB*)srcPtr)).A != 0) *((ARGB*)ptr) = *((ARGB*)srcPtr); ptr += stride; srcPtr += srcStride; } break; } } } //if aa, add smoothing to edges if(isAA) { int center = (left + right) / 2; if(Min(x1b, x1a) != left) AAEdgeCopy(addr, width, stride, x1b, x1a, y, srcAddr, srcWidth, srcStride, offset, true, clipMax: Min(center, clip.Max.X)); if(Max(x2b, x2a) != right) AAEdgeCopy(addr, width, stride, x2b + 1, x2a + 1, y, srcAddr, srcWidth, srcStride, offset, false, clipMin: Max(center + 1, clip.Min.X)); } } uDest.EndUnsafeOperation(); uSrc.EndUnsafeOperation(); }
private void stampSButton_Click(object sender, EventArgs e) { MyColor = ColorMode.StampS; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
static public void ToBitmap(List <byte> bytes) { ColorMode colorMode = (ColorMode)bytes[0]; ushort W = BitConverter.ToUInt16(bytes.ToArray(), 1); ushort H = BitConverter.ToUInt16(bytes.ToArray(), 3); BitmapColor[,] colors = new BitmapColor[W, H]; BitmapColor baseColor = BitmapColor.CreateColor(colorMode, Color.Empty); int counter = 0; if (colorMode == ColorMode.GrayScale_encoded) { List <bool> bits = new List <bool>(); Encoder.Decode(bytes, 5, bytes.Count - 5, p => bits.Add(p)); var decodeResult = CreateSequence(p => { byte b = 0; for (int i = 0; i < 8; i++) { if (p * 8 + i < bits.Count) { BitWise.SSetBit(ref b, i, bits[p * 8 + i] ? 1 : 0); } } return(b); }, (int)Math.Ceiling(bits.Count / 8f)).ToList(); bytes = new List <byte>(); bytes.AddRange(new byte[5] { 0, 0, 0, 0, 0 }); bytes.AddRange(decodeResult); } else if (colorMode == ColorMode.Binary_encoded) { List <bool> controlBits = new List <bool>(); Encoder.Decode(bytes, 5, bytes.Count - 5, p => controlBits.Add(p)); bytes = new List <byte>(); bytes.AddRange(new byte[5] { 0, 0, 0, 0, 0 }); bytes.AddRange(controlBits.Select(p => (byte)(p ? 1 : 0))); } else if (colorMode == ColorMode.Binary) { List <bool> controlBits = new List <bool>(); for (int i = 5; i < bytes.Count; i++) { for (int b = 0; b < 8; b++) { controlBits.Add(BitWise.Bit(bytes[i], b) == 1); } } bytes = new List <byte>(); bytes.AddRange(new byte[5] { 0, 0, 0, 0, 0 }); bytes.AddRange(controlBits.Select(p => (byte)(p ? 1 : 0))); } for (int x = 0; x < W; x++) { for (int y = 0; y < H; y++) { colors[x, y] = BitmapColor.CreateColor(colorMode, Color.Empty); colors[x, y].FromBytes(bytes.Skip(baseColor.BytesPerColor * counter + 5).Take(baseColor.BytesPerColor).ToArray()); counter++; } } Bitmap bmp = new Bitmap(W, H); for (int x = 0; x < W; x++) { for (int y = 0; y < H; y++) { bmp.SetPixel(x, y, colors[x, y].ToRGB()); } } bmp.Save("result_out3.png"); }
private static bool AddColour(XElement liElement, XNamespace defaultNamespace, XNamespace xNamespace, XDocument doc, string swatchName = "", ColorMode mode = ColorMode.All) { var name = liElement.Elements("span").First().Value; var hex = liElement.Elements("span").Last().Value; var prefix = "Primary"; if (name.StartsWith("A", StringComparison.Ordinal)) { if (mode == ColorMode.PrimaryOnly) { return(false); } prefix = "Accent"; name = name.Skip(1).Aggregate("", (current, next) => current + next); } else { if (mode == ColorMode.AccentOnly) { return(false); } } var backgroundColourElement = new XElement(defaultNamespace + "Color", hex); // new XAttribute() backgroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}", swatchName, prefix, name))); doc.Root.Add(backgroundColourElement); var liClass = liElement.Attribute("class").Value; Color foregroundColour; if (!ClassNameToForegroundIndex.TryGetValue(liClass, out foregroundColour)) { throw new Exception("Unable to map foreground color from class " + liClass); } var foreGroundColorHex = string.Format("#{0}{1}{2}{3}", ByteToHex(foregroundColour.A), ByteToHex(foregroundColour.R), ByteToHex(foregroundColour.G), ByteToHex(foregroundColour.B)); var foregroundColourElement = new XElement(defaultNamespace + "Color", foreGroundColorHex); foregroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}Foreground", swatchName, prefix, name))); doc.Root.Add(foregroundColourElement); return(true); }
public ColorControl(Control control, ColorMode mode, Color defaultColor) { this.Control = control; this.Mode = mode; this.Default = defaultColor; }
private IVisualization2d GenerateGrid(int offset, int itemByteWidth, int itemHeight, int colStride, int rowStride, int cellStride, int count, ColorMode colorConvMode, bool isFirstOdd, bool isHighBitFlipped) { // We allow the stride entries to be zero to indicate a "dense" bitmap. if (colStride == 0) { colStride = 1; } if (rowStride == 0) { rowStride = itemByteWidth * colStride; } if (cellStride == 0) { cellStride = rowStride * itemHeight; } if (offset < 0 || offset >= mFileData.Length || itemByteWidth <= 0 || itemByteWidth > MAX_DIM || itemHeight <= 0 || itemHeight > MAX_DIM || count <= 0 || count > MAX_DIM) { // should be caught by editor mAppRef.ReportError("Invalid parameter"); return(null); } if (colStride <= 0 || colStride > MAX_DIM) { mAppRef.ReportError("Invalid column stride"); return(null); } if (rowStride < itemByteWidth * colStride - (colStride - 1) || rowStride > MAX_DIM) { mAppRef.ReportError("Invalid row stride"); return(null); } int lastOffset = offset + (cellStride * (count - 1)) + rowStride * itemHeight - (colStride - 1) - 1; if (lastOffset >= mFileData.Length) { mAppRef.ReportError("Bitmap runs off end of file (last offset +" + lastOffset.ToString("x6") + ")"); return(null); } // Set the number of horizontal cells. For small counts we try to make it square, // for larger counts we use a reasonable power of 2. int hcells; if (count > 128) { hcells = 32; } else if (count > 64) { hcells = 16; } else if (count >= 32) { hcells = 8; } else { hcells = (int)Math.Sqrt(count + 1); } int vcells = (count + hcells - 1) / hcells; // Create a bitmap with room for each cell, plus a 1-pixel transparent boundary // between them and around the edges. VisBitmap8 vb = new VisBitmap8(1 + hcells * itemByteWidth * 7 + hcells, 1 + vcells * itemHeight + vcells); SetHiResPalette(vb); int cellx = 1; int celly = 1; for (int idx = 0; idx < count; idx++) { RenderBitmap(mFileData, offset + idx * cellStride, itemByteWidth, itemHeight, colStride, rowStride, colorConvMode, isFirstOdd, isHighBitFlipped, vb, cellx, celly); cellx += itemByteWidth * 7 + 1; if (cellx == vb.Width) { cellx = 1; celly += itemHeight + 1; } } return(vb); }
/// <summary> /// Constructor, creates new OCR Plugin for specified sampling resolution and color mode /// </summary> /// <param name="samplingResolution"> /// image sampling resolution (dimensions) </param> /// <param name="colorMode"> recognition color mode </param> public OcrPlugin(Dimension samplingResolution, ColorMode colorMode) : base(OCR_PLUGIN_NAME) { this.samplingResolution = samplingResolution; this.colorMode = colorMode; }
public override void OnInspectorGUI() { serializedObject.Update(); Material targetMat = target as Material; // Update inspector if user changed shader. if (targetMat.shader.name != "Colr/Master Shader") { Repaint(); EditorUtility.SetDirty(target); return; } var shdr = serializedObject.FindProperty("m_Shader"); if (isVisible && !shdr.hasMultipleDifferentValues && shdr.objectReferenceValue != null) { string[] keywordsCurrent = targetMat.shaderKeywords; EditorGUI.BeginChangeCheck(); if (targets == null || targets.Length == 0) { return; } TextureProperty(GetMaterialProperty(targets, "_MainTex"), "Texture"); EditorGUILayout.Separator(); ColorProperty(GetMaterialProperty(targets, "_TopColor"), "Top Color"); ColorProperty(GetMaterialProperty(targets, "_BottomColor"), "Bottom Color"); EditorGUILayout.Separator(); // ---- FRONT ---- frontMode = (ColorMode)EditorGUILayout.EnumPopup("Front color override", frontMode); showFront.target = frontMode != ColorMode.OFF; using (var group = new EditorGUILayout.FadeGroupScope(showFront.faded)) { if (group.visible) { EditorGUI.indentLevel++; if (frontMode == ColorMode.GRADIENT) { ColorProperty(GetMaterialProperty(targets, "_FrontTopColor"), "Front Top Color"); ColorProperty(GetMaterialProperty(targets, "_FrontBottomColor"), "Front Bottom Color"); } else { ColorProperty(GetMaterialProperty(targets, "_FrontTopColor"), "Color"); } EditorGUI.indentLevel--; } } EditorGUILayout.Separator(); // ---- BACK ---- backMode = (ColorMode)EditorGUILayout.EnumPopup("Back color override", backMode); showBack.target = backMode != ColorMode.OFF; using (var group = new EditorGUILayout.FadeGroupScope(showBack.faded)) { if (group.visible) { EditorGUI.indentLevel++; if (backMode == ColorMode.GRADIENT) { ColorProperty(GetMaterialProperty(targets, "_BackTopColor"), "Back Top Color"); ColorProperty(GetMaterialProperty(targets, "_BackBottomColor"), "Back Bottom Color"); } else { ColorProperty(GetMaterialProperty(targets, "_BackTopColor"), "Color"); } EditorGUI.indentLevel--; } } EditorGUILayout.Separator(); // ---- LEFT ---- leftMode = (ColorMode)EditorGUILayout.EnumPopup("Left color override", leftMode); showLeft.target = leftMode != ColorMode.OFF; using (var group = new EditorGUILayout.FadeGroupScope(showLeft.faded)) { if (group.visible) { EditorGUI.indentLevel++; if (leftMode == ColorMode.GRADIENT) { ColorProperty(GetMaterialProperty(targets, "_LeftTopColor"), "Left Top Color"); ColorProperty(GetMaterialProperty(targets, "_LeftBottomColor"), "Left Bottom Color"); } else { ColorProperty(GetMaterialProperty(targets, "_LeftTopColor"), "Color"); } EditorGUI.indentLevel--; } } EditorGUILayout.Separator(); // ---- RIGHT ---- rightMode = (ColorMode)EditorGUILayout.EnumPopup("Right color override", rightMode); showRight.target = rightMode != ColorMode.OFF; using (var group = new EditorGUILayout.FadeGroupScope(showRight.faded)) { if (group.visible) { EditorGUI.indentLevel++; if (rightMode == ColorMode.GRADIENT) { ColorProperty(GetMaterialProperty(targets, "_RightTopColor"), "Right Top Color"); ColorProperty(GetMaterialProperty(targets, "_RightBottomColor"), "Right Bottom Color"); } else { ColorProperty(GetMaterialProperty(targets, "_RightTopColor"), "Color"); } EditorGUI.indentLevel--; } } EditorGUILayout.Separator(); // ---- FOG ---- fogBottom = EditorGUILayout.Toggle("Fade bottom to fog", fogBottom); EditorGUILayout.Separator(); // ---- ADDITIVE ---- if (fogBottom) { independentSides = true; } else { independentSides = EditorGUILayout.Toggle("Do not mix colors of sides", independentSides); EditorGUILayout.Separator(); } // ---- GRADIENT ---- if (frontMode != ColorMode.SOLID || backMode != ColorMode.SOLID || leftMode != ColorMode.SOLID || rightMode != ColorMode.SOLID || fogBottom) { FloatProperty(GetMaterialProperty(targets, "_GradientYStartPos"), "Gradient start Y"); float h = FloatProperty(GetMaterialProperty(targets, "_GradientHeight"), "Gradient height"); if (h < 0) { targetMat.SetFloat("_GradientHeight", 0); } EditorGUILayout.Separator(); } ColorProperty(GetMaterialProperty(targets, "_LightTint"), "Light Color"); EditorGUILayout.Separator(); ColorProperty(GetMaterialProperty(targets, "_AmbientColor"), "Ambient Color"); RangeProperty(GetMaterialProperty(targets, "_AmbientPower"), "Ambient Power"); EditorGUILayout.Separator(); lightmapOn = ArrayUtility.Contains(keywordsCurrent, LIGHTMAP_COLR_ON); using (var group = new EditorGUILayout.ToggleGroupScope("Enable Lightmap", lightmapOn)) { lightmapOn = group.enabled; ColorProperty(GetMaterialProperty(targets, "_LightmapColor"), "Lightmap Color"); RangeProperty(GetMaterialProperty(targets, "_LightmapPower"), "Lightmap Power"); } EditorGUILayout.Separator(); RangeProperty(GetMaterialProperty(targets, "_Rotation"), "Gradient Angle"); GetMaterialProperty(targets, "_Offset").vectorValue = EditorGUILayout.Vector3Field("Angle Origin", GetMaterialProperty(targets, "_Offset").vectorValue); EditorGUILayout.Separator(); // If a value changed. if (EditorGUI.EndChangeCheck()) { ApplyProperties(); } } }
public override void SelectPreviousMode() { Mode = Mode.Previous(); return; }
public Color(UnityEngine.Color color, ColorMode mode) { this.color = color; this.mode = mode; }
public override void SelectNextMode() { Mode = Mode.Next(); return; }
/// <summary> /// Initializes a new instance of the NXTColorSensor class. /// </summary> /// <param name="mode">Mode.</param> public NXTColorSensor(SensorPort port, ColorMode mode) : base(port) { GetColorData(); SetMode(AnalogMode); }
int GetColor(Color color, ColorMode colorMode) { return(0); }
public LabelStyle(string rrggbbaa, ColorMode mode, double scale) { this._color = rrggbbaa; this._colorMode = mode; this._scale = scale; }
/// <summary> /// Moves to next mode /// </summary> public void SelectNextMode() { _colorMode = ColorMode.Next(); }
public void SetColorMode(ColorMode mode) { ((IStyle)Style).SetColorMode(mode); }
/// <summary> /// Moves to previous mode /// </summary> public void SelectPreviousMode() { _colorMode = ColorMode.Previous(); }
public PrintJobProperties(ColorMode colorMode, PlexMode plexMode) { this.ColorMode = colorMode; this.PlexMode = plexMode; }
/// <summary> /// Selected mode /// </summary> /// <returns>String representing selected mode</returns> public string SelectedMode() { return(ColorMode.ToString()); }
IplDepth GetImageDepth(ColorMode colorMode) { return(IplDepth.U8); }
private static Tuple<string, XDocument> ToResourceDictionary(XElement sectionElement, out bool empty, bool named = false, ColorMode mode = ColorMode.All) { empty = true; var colour = GetColourName(sectionElement); XNamespace defaultNamespace = @"http://schemas.microsoft.com/winfx/2006/xaml/presentation"; var xNamespace = XNamespace.Get("http://schemas.microsoft.com/winfx/2006/xaml"); var doc = new XDocument(new XElement(defaultNamespace + "ResourceDictionary", new XAttribute(XNamespace.Xmlns + "x", xNamespace))); foreach (var liElement in sectionElement.Element("ul").Elements("li").Skip(1)) { if (AddColour(liElement, defaultNamespace, xNamespace, doc, named ? colour : "", mode)) empty = false; } return new Tuple<string, XDocument>(colour, doc); }
private List <string> BuildPatternFromImage(string p_imageFileName, int p_gridWidth, int p_gridHeight, ColorMode p_mode) { BitmapSource bmp = new BitmapImage(new Uri(p_imageFileName)); byte[] rawPixels = new byte[bmp.PixelWidth * bmp.PixelHeight * 4]; bmp.CopyPixels(rawPixels, bmp.PixelWidth * 4, 0); double cellWidth = (double)bmp.PixelWidth / p_gridWidth; double cellHeight = (double)bmp.PixelHeight / p_gridHeight; Console.WriteLine("Width: " + cellWidth + ", Height: " + cellHeight); List <string> ret = new List <string>(); Dictionary <string, int> votes = new Dictionary <string, int>(); // Pull out a list of the colors for (double j = 0; j < bmp.PixelHeight; j += cellHeight) { Console.WriteLine("Processing line " + Math.Round(j) + ", " + (j / cellHeight)); for (double i = 0; i < bmp.PixelWidth; i += cellWidth) { double average_r = 0; double average_g = 0; double average_b = 0; //Debug.WriteLine("=== Sampling cell " + i + ", " + j); double pixelCount = 0; votes.Clear(); foreach (var c in _Palette) { votes[c.Key] = 0; } double cellMargin = 3; double cellStep = 1; //Console.WriteLine("Processing region at " + (i) + ", " + (j)); for (double cellj = cellMargin; cellj < cellHeight - cellMargin; cellj += cellStep) { for (double celli = cellMargin; celli < cellWidth - cellMargin; celli += cellStep) { var index = (int)((j + cellj) * bmp.PixelWidth + (i + celli)) * 4; var r = rawPixels[index + 2]; var g = rawPixels[index + 1]; var b = rawPixels[index]; if ((r + g + b) / 2 < 1) { continue; } //if ((r + g + b) / 2 > 253) continue; average_r += r; average_g += g; average_b += b; pixelCount += 1; votes[GetClosestColor(Color.FromRgb(rawPixels[index + 2], rawPixels[index + 1], rawPixels[index]))]++; } } average_r /= pixelCount; average_g /= pixelCount; average_b /= pixelCount; if (p_mode == ColorMode.Average) { ret.Add(GetClosestColor(Color.FromRgb((byte)average_r, (byte)average_g, (byte)average_b))); } else if (p_mode == ColorMode.Voting) { if (votes.Any(p_v => p_v.Value > 0)) { ret.Add(votes.OrderBy(p_v => p_v.Value).Last().Key); //Debug.WriteLine("=== Done sampling cell, color = " + color ); } } else { throw new NotSupportedException("Unsupported color mode"); } } } //Debug.Assert(ret.Count == p_gridHeight * p_gridWidth); return(ret); }
/// <summary> /// Set the connected sensor's mode /// </summary> /// <param name="mode">The requested mode.</param> public void SetMode(ColorMode mode) { Mode = (byte)mode; }
private static Tuple <string, XDocument> ToResourceDictionary(XElement sectionElement, out bool empty, bool named = false, ColorMode mode = ColorMode.All) { empty = true; var colour = GetColourName(sectionElement); XNamespace defaultNamespace = @"http://schemas.microsoft.com/winfx/2006/xaml/presentation"; var xNamespace = XNamespace.Get("http://schemas.microsoft.com/winfx/2006/xaml"); var doc = new XDocument(new XElement(defaultNamespace + "ResourceDictionary", new XAttribute(XNamespace.Xmlns + "x", xNamespace))); foreach (var liElement in sectionElement.Element("ul").Elements("li").Skip(1)) { if (AddColour(liElement, defaultNamespace, xNamespace, doc, named ? colour : "", mode)) { empty = false; } } return(new Tuple <string, XDocument>(colour, doc)); }
private void RadioGrayscale_CheckedChanged(object sender, EventArgs e) { if (RadioGrayscale.Checked) { colorMode = ColorMode.Grayscale; } }
/// <summary> /// Basic implementation of a constant src solid filling renderer. /// </summary> /// <param name="clip">The clipping rectangle.</param> /// <param name="scanner">The scans to render.</param> /// <param name="dest">The map to render to.</param> /// <param name="value">The constant value.</param> /// <param name="mode">The color blending mode to use.</param> /// <param name="isAA">True if anti-aliasing is enabled.</param> public static void SolidConstRender(Rectangle clip, Scanner scanner, DataMap<ARGB> dest, ARGB value, ColorMode mode = ColorMode.NORMAL, bool isAA = true) { //for constants, we can early return on blend and mask when alpha is 0 if((mode == ColorMode.BLEND || mode == ColorMode.MASK) && value.A == 0) return; //mask at non-zero is equivalent to normal if(mode == ColorMode.MASK) mode = ColorMode.NORMAL; //blend at opaque is equivalent to normal if(mode == ColorMode.BLEND && value.A == 255) mode = ColorMode.NORMAL; IUnsafeMap uDest = dest as IUnsafeMap; if(uDest == null) { throw new InvalidOperationException("Destination image does not support advanced color rendering!"); } byte* addr = uDest.BeginUnsafeOperation(); int width = dest.Width; int stride = uDest.GetStride(); for(int y = scanner.yMin; y <= scanner.yMax; y++) { double x1 = Max(scanner[y].min, clip.Min.X); double x2 = Min(scanner[y].max, clip.Max.X); //Anti-Aliasing variables //x1 vars are x min side //x2 vars are x max side //xb vars are y min side //xa vars are y max side double x1b = 0, x1a = 0; double x2b = 0, x2a = 0; int left; int right; if(isAA) { bool hasMin = false, hasMax = false; //if not at ymin or ymin is a clipped min (aka we have another "ghost" scan) if(y > scanner.yMin || scanner.isYMinClipped) { x1b = Max(scanner[y - 1].min, clip.Min.X); x2b = Min(scanner[y - 1].max, clip.Max.X); x1b = (x1b + x1) / 2; x2b = (x2b + x2) / 2; hasMin = true; } //if not at ymax or ymax is a clipped max (aka we have another "ghost" scan) if(y < scanner.yMax || scanner.isYMaxClipped) { x1a = Max(scanner[y + 1].min, clip.Min.X); x2a = Min(scanner[y + 1].max, clip.Max.X); x1a = (x1a + x1) / 2; x2a = (x2a + x2) / 2; hasMax = true; } if(!hasMin) { //if single line shape, just make everything literal if(!hasMax) { x1b = x1a = x1; x2b = x2a = x2; }else//if at ymin, extrapolate max->current into current->min { x1b = x1 - (x1a - x1); x2b = x2 - (x2a - x2); } }else//if at ymax, extrapolate min->current into current->max if(!hasMax) { x1a = x1 + (x1 - x1b); x2a = x2 + (x2 - x2b); } //if aa, round toward center left = (int)Math.Ceiling(Max(x1b, x1a)); right = (int)Math.Floor(Min(x2b, x2a)); }else { //if not aa, round away from center to match default renderer left = (int)Math.Floor(x1); right = (int)Math.Ceiling(x2); } //if valid center if(left <= right) { //solid fill with blend modes byte* ptr = addr + (left + (y * width)) * stride; byte* endPtr = ptr + (right - left + 1) * stride; switch(mode) { case ColorMode.BLEND: { //precalc value ARGB preValue = new ARGB{A = (byte)(255 - value.A), R = (byte)((value.R * value.A) >> 8), G = (byte)((value.G * value.A) >> 8), B = (byte)((value.B * value.A) >> 8)}; while(ptr != endPtr) { //*((ARGB*)ptr) &= value; //manually inline blending ARGB color = *(ARGB*)ptr; color = new ARGB{A = (byte)(value.A + color.A), R = (byte)(preValue.R + ((color.R * preValue.A) >> 8)), G = (byte)(preValue.G + ((color.G * preValue.A) >> 8)), B = (byte)(preValue.B + ((color.B * preValue.A) >> 8))}; *(ARGB*)ptr = color; ptr += stride; } break; } case ColorMode.NORMAL: { while(ptr != endPtr) { *((ARGB*)ptr) = value; ptr += stride; } break; } } } //if aa, add smoothing to edges if(isAA) { int center = (left + right) / 2; if(Min(x1b, x1a) != left) AAEdgeConst(addr, width, stride, x1b, x1a, y, value, true, clipMax: Min(center, clip.Max.X)); if(Max(x2b, x2a) != right) AAEdgeConst(addr, width, stride, x2b + 1, x2a + 1, y, value, false, clipMin: Max(center + 1, clip.Min.X)); } } uDest.EndUnsafeOperation(); }
private void RadioRGB_CheckedChanged(object sender, EventArgs e) { if (RadioRGB.Checked) { colorMode = ColorMode.RGB; } }
public LabelStyle(Color color, float scale, ColorMode newColorMode) { Color = color; m_scale = scale; colorMode = newColorMode; }
public void colorMode(ColorMode mode, float range) { colorMode(mode); m_range1 = m_range2 = m_range3 = range; }
/// <summary> /// Returns the default palette for a given bit depth and color mode. /// </summary> /// <param name="depth">The given bit depth.</param> /// <param name="mode">The given color mode.</param> /// <returns>The requested default palette.</returns> public static int[] GetPalette(BitDepth depth, ColorMode mode) { if (mode == ColorMode.Grayscale) { if (depth == BitDepth.OneBpp) { return OneBppGrayscale; } else if (depth == BitDepth.TwoBpp) { return TwoBppGrayscale; } else if (depth == BitDepth.FourBpp) { return FourBppGrayscale; } else if (depth == BitDepth.EightBpp) { return EightBppGrayscale; } } else if (mode == ColorMode.RGB) { if (depth == BitDepth.FourBpp) { return FourBppRGB121; } else if (depth == BitDepth.EightBpp) { return EightBppRGB332; } else if (depth == BitDepth.SixteenBpp) { return SixteenBppRGB565; } } else if (mode == ColorMode.ARGB) { if (depth == BitDepth.EightBpp) { return EightBppARGB2222; } else if (depth == BitDepth.SixteenBpp) { return SixteenBppARGB4444; } } else { throw new ArgumentException("No default palette for this color mode."); } throw new InvalidOperationException("You should never see this message."); }
internal void BeforeSet(ColorMode colorMode) { byte[] pixelData; ushort rows; ushort columns; if (colorMode == ColorMode.Color) { var image = new BasicColorImageSequenceIod { SamplesPerPixel = 3, PhotometricInterpretation = PhotometricInterpretation.Rgb, PixelRepresentation = 0, PixelAspectRatio = new PixelAspectRatio(1, 1), PlanarConfiguration = 0, BitsStored = 8, BitsAllocated = 8, HighBit = 7 }; this.PrintItem.GetPixelData(this, colorMode, out rows, out columns, out pixelData); image.PixelData = pixelData; image.Rows = rows; image.Columns = columns; this.BasicColorImageSequenceList.Add(image); } else { var image = new BasicGrayscaleImageSequenceIod { SamplesPerPixel = 1, PhotometricInterpretation = PhotometricInterpretation.Monochrome2, PixelRepresentation = 0, PixelAspectRatio = new PixelAspectRatio(1, 1), BitsStored = 8, BitsAllocated = 8, HighBit = 7 }; this.PrintItem.GetPixelData(this, colorMode, out rows, out columns, out pixelData); image.PixelData = pixelData; image.Rows = rows; image.Columns = columns; this.BasicGrayscaleImageSequenceList.Add(image); } }
private static Texture2D CreateModifiedTextureClone(Texture2D originalTexture, Color32 newColor, byte searchForRed, ColorMode colorMode, AlphaMode alphaMode) { Texture2D tempTexture = CreateRWTextureFromNonReadableTexture(originalTexture); int tWidth = normalTexture.width; int tHeight = normalTexture.height; var oldPixels = tempTexture.GetPixels32(); Color[] newPixels = new Color[tWidth * tHeight]; byte red = 0; byte green = 0; byte blue = 0; byte alpha = 0; for (int i = 0; i < oldPixels.Length; i++) { if (oldPixels[i].r == searchForRed) { switch (colorMode) { case ColorMode.Change: red = newColor.r; green = newColor.g; blue = newColor.b; break; case ColorMode.Ignore: red = oldPixels[i].r; green = oldPixels[i].g; blue = oldPixels[i].b; break; case ColorMode.Negative: int redNegative = oldPixels[i].r - newColor.r; red = redNegative < 0 ? byte.MinValue : (byte)redNegative; int greenNegative = oldPixels[i].g - newColor.g; green = greenNegative < 0 ? byte.MinValue : (byte)greenNegative; int blueNegative = oldPixels[i].b - newColor.b; blue = blueNegative < 0 ? byte.MinValue : (byte)blueNegative; break; case ColorMode.Positive: int redPositive = oldPixels[i].r + newColor.r; red = redPositive > 255 ? byte.MaxValue : (byte)redPositive; int greenPositive = oldPixels[i].g + newColor.g; green = greenPositive > 255 ? byte.MaxValue : (byte)greenPositive; int bluePositive = oldPixels[i].b + newColor.b; blue = bluePositive > 255 ? byte.MaxValue : (byte)bluePositive; break; } switch (alphaMode) { case AlphaMode.Change: alpha = newColor.a; break; case AlphaMode.Ignore: alpha = oldPixels[i].a; break; case AlphaMode.Negative: int alphaNegative = oldPixels[i].a - newColor.a; alpha = alphaNegative < 0 ? byte.MinValue : (byte)alphaNegative; break; case AlphaMode.Positive: int alphaPositive = oldPixels[i].a + newColor.a; alpha = alphaPositive > 255 ? byte.MaxValue : (byte)alphaPositive; break; } newPixels[i] = new Color32(red, green, blue, alpha); } else { newPixels[i] = oldPixels[i]; } } Texture2D result = new Texture2D(tWidth, tHeight); result.SetPixels(newPixels); result.Apply(); return(result); }
public void colorMode(ColorMode mode) { currentColorMode = mode; }
private void ColorTab() { if (highlightMaterial == null || !ResourcesDirectory.IsCustomMaterial(highlightMaterial)) { highlightMaterial = ResourcesDirectory.MakeCustomMaterial(colorMode, allowAlpha); if (allowAlpha) { highlightMaterial.color = new Color(0, 0, 1, 0.25f); } else { highlightMaterial.color = Color.red; } if (handler != null) { handler(highlightMaterial); } } ColorMode newMode; if (colorModeSet == ColorModeSet.UNLIT_ONLY) { newMode = ColorMode.UNLIT; } else { string[] colorModes; if (colorModeSet == ColorModeSet.OBJECT) { colorModes = OBJECT_COLOR_MODES; } else if (allowAlpha) { colorModes = TRANSPARENT_COLOR_MODES; } else { colorModes = OPAQUE_COLOR_MODES; } // TODO: this is ugly int m = System.Array.IndexOf(colorModes, COLOR_MODE_NAMES[(int)colorMode]); m = GUILayout.SelectionGrid(m, colorModes, colorModes.Length, GUIStyleSet.instance.buttonTab); newMode = (ColorMode)System.Array.IndexOf(COLOR_MODE_NAMES, colorModes[m]); } if (newMode != colorMode) { Material newMat = ResourcesDirectory.MakeCustomMaterial(newMode, allowAlpha); newMat.color = highlightMaterial.color; highlightMaterial = newMat; colorMode = newMode; if (handler != null) { handler(highlightMaterial); } } if (colorPicker == null) { colorPicker = gameObject.AddComponent <ColorPickerGUI>(); colorPicker.enabled = false; colorPicker.SetColor(highlightMaterial.color); colorPicker.includeAlpha = allowAlpha; colorPicker.handler = (Color c) => { highlightMaterial.color = c; if (handler != null) { handler(highlightMaterial); } }; } colorPicker.WindowGUI(); }
/// <summary> /// Renders bitmap data. /// </summary> /// <param name="data">Data source, typically the file data.</param> /// <param name="offset">Offset into data of the first byte.</param> /// <param name="byteWidth">Width, in bytes, of the data to render. Each byte /// represents 7 pixels in the output (more or less).</param> /// <param name="height">Height, in lines, of the data to render.</param> /// <param name="colStride">Column stride. The number of bytes used to hold each /// byte of data. Must be >= 1.</param> /// <param name="rowStride">Row stride. The number of bytes used to hold each row /// of data. Must be >= (colStride * byteWidth - (colStride - 1)).</param> /// <param name="colorMode">Color conversion mode.</param> /// <param name="isFirstOdd">If true, render as if we're starting on an odd column. /// This affects the colors.</param> /// <param name="isHighBitFlipped">If true, render as if the high bit has the /// opposite value. This affects the colors.</param> /// <param name="vb">Output bitmap object.</param> /// <param name="xstart">Initial X position in the output.</param> /// <param name="ystart">Initial Y position in the output.</param> private void RenderBitmap(byte[] data, int offset, int byteWidth, int height, int colStride, int rowStride, ColorMode colorMode, bool isFirstOdd, bool isHighBitFlipped, VisBitmap8 vb, int xstart, int ystart) { int bx = xstart; int by = ystart; switch (colorMode) { case ColorMode.Mono: { // Since we're not displaying this we don't need to worry about // half-pixel shifts, and can just convert 7 bits to pixels. for (int row = 0; row < height; row++) { int colIdx = 0; for (int col = 0; col < byteWidth; col++) { byte val = data[offset + colIdx]; for (int bit = 0; bit < 7; bit++) { if ((val & 0x01) == 0) { vb.SetPixelIndex(bx, by, (int)HiResColors.Black0); } else { vb.SetPixelIndex(bx, by, (int)HiResColors.White0); } val >>= 1; bx++; } colIdx += colStride; } bx = xstart; by++; offset += rowStride; } } break; case ColorMode.SimpleColor: { // Straightforward conversion, with no funky border effects. This // represents an idealized version of the hardware. // Bits for every byte, plus a couple of "fake" bits on the ends so // we don't have to throw range-checks everywhere. const int OVER = 2; bool[] lineBits = new bool[OVER + byteWidth * 7 + OVER]; bool[] hiFlags = new bool[OVER + byteWidth * 7 + OVER]; for (int row = 0; row < height; row++) { // Unravel the bits. Note we do each byte "backwards", i.e. the // low bit (which is generally considered to be on the right) is // the leftmost pixel. int idx = OVER; // start past "fake" bits int colIdx = 0; for (int col = 0; col < byteWidth; col++) { byte val = data[offset + colIdx]; bool hiBitSet = (val & 0x80) != 0; for (int bit = 0; bit < 7; bit++) { hiFlags[idx] = hiBitSet ^ isHighBitFlipped; lineBits[idx] = (val & 0x01) != 0; idx++; val >>= 1; } colIdx += colStride; } // Convert to color. int lastBit = byteWidth * 7; for (idx = OVER; idx < lastBit + OVER; idx++) { int colorShift = hiFlags[idx] ? 2 : 0; if (lineBits[idx] && (lineBits[idx - 1] || lineBits[idx + 1])) { // [X]11 or [1]1X; two 1s in a row is always white vb.SetPixelIndex(bx++, by, (byte)HiResColors.White0); } else if (lineBits[idx]) { // [0]10, color pixel bool isOdd = ((idx & 0x01) != 0) ^ isFirstOdd; if (isOdd) { vb.SetPixelIndex(bx++, by, (byte)((int)HiResColors.Green + colorShift)); } else { vb.SetPixelIndex(bx++, by, (byte)((int)HiResColors.Purple + colorShift)); } } else if (lineBits[idx - 1] && lineBits[idx + 1]) { // [1]01, keep color going bool isOdd = ((idx & 0x01) != 0) ^ isFirstOdd; if (isOdd) { vb.SetPixelIndex(bx++, by, (byte)((int)HiResColors.Purple + colorShift)); } else { vb.SetPixelIndex(bx++, by, (byte)((int)HiResColors.Green + colorShift)); } } else { // [0]0X or [X]01 vb.SetPixelIndex(bx++, by, (byte)HiResColors.Black0); } } // move to next row bx = xstart; by++; offset += rowStride; } } break; case ColorMode.IIgsRGB: { // Color conversion similar to what CiderPress does, but without the // half-pixel shift (we're trying to create a 1:1 bitmap, not 1:2). // // This replicates some of the oddness in Apple IIgs RGB monitor output, // but it's not quite right though. For example: // // observed generated // d5 2a: blue [dk blue] purple ... black ... // aa 55: orange [yellow] green ... white ... // 55 aa: purple [lt blue] blue ... black ... // 2a d5: green [brown] orange ... black ... // // KEGS doesn't seem to try to model this; it shows solid colors with no // wackiness. AppleWin in "Color TV" mode shows similar effects, but is // much blurrier (by design). bool[] lineBits = new bool[byteWidth * 7]; bool[] hiFlags = new bool[byteWidth * 7]; // overkill, but simpler int[] colorBuf = new int[byteWidth * 7]; for (int row = 0; row < height; row++) { // Unravel the bits. int idx = 0; int colIdx = 0; for (int col = 0; col < byteWidth; col++) { byte val = data[offset + colIdx]; bool hiBitSet = (val & 0x80) != 0; for (int bit = 0; bit < 7; bit++) { hiFlags[idx] = hiBitSet ^ isHighBitFlipped; lineBits[idx] = (val & 0x01) != 0; idx++; val >>= 1; } colIdx += colStride; } // Convert to color. int lastBit = byteWidth * 7; for (idx = 0; idx < lastBit; idx++) { int colorShift = hiFlags[idx] ? 2 : 0; if (!lineBits[idx]) { // Bit not set, set pixel to black. colorBuf[idx] = (int)HiResColors.Black0; } else { // Bit set, set pixel to white or color. if (idx > 0 && colorBuf[idx - 1] != (int)HiResColors.Black0) { // previous bit was also set, this is white colorBuf[idx] = (int)HiResColors.White0; // the previous pixel is part of a run of white colorBuf[idx - 1] = (int)HiResColors.White0; } else { // previous bit not set *or* was first pixel in line; // set color based on whether this is even or odd pixel col bool isOdd = ((idx & 0x01) != 0) ^ isFirstOdd; if (isOdd) { colorBuf[idx] = (int)HiResColors.Green + colorShift; } else { colorBuf[idx] = (int)HiResColors.Purple + colorShift; } } // Do we have a run of the same color? If so, smooth the // color out. Note that white blends smoothly with everything. if (idx > 1 && (colorBuf[idx - 2] == colorBuf[idx] || colorBuf[idx - 2] == (int)HiResColors.White0)) { colorBuf[idx - 1] = colorBuf[idx]; } } } // Write to bitmap. for (idx = 0; idx < lastBit; idx++) { vb.SetPixelIndex(bx++, by, (byte)colorBuf[idx]); } // move to next row bx = xstart; by++; offset += rowStride; } } break; default: // just leave the bitmap empty mAppRef.ReportError("Unknown ColorMode " + colorMode); break; } }
private static bool AddColour(XElement liElement, XNamespace defaultNamespace, XNamespace xNamespace, XDocument doc, string swatchName = "", ColorMode mode = ColorMode.All) { var name = liElement.Elements("span").First().Value; var hex = liElement.Elements("span").Last().Value; var prefix = "Primary"; if (name.StartsWith("A", StringComparison.Ordinal)) { if (mode == ColorMode.PrimaryOnly) return false; prefix = "Accent"; name = name.Skip(1).Aggregate("", (current, next) => current + next); } else { if (mode == ColorMode.AccentOnly) return false; } var backgroundColourElement = new XElement(defaultNamespace + "Color", hex); // new XAttribute() backgroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}", swatchName, prefix, name))); doc.Root.Add(backgroundColourElement); var liClass = liElement.Attribute("class").Value; Color foregroundColour; if (!ClassNameToForegroundIndex.TryGetValue(liClass, out foregroundColour)) throw new Exception("Unable to map foreground color from class " + liClass); var foreGroundColorHex = string.Format("#{0}{1}{2}{3}", ByteToHex(foregroundColour.A), ByteToHex(foregroundColour.R), ByteToHex(foregroundColour.G), ByteToHex(foregroundColour.B)); var foregroundColourElement = new XElement(defaultNamespace + "Color", foreGroundColorHex); foregroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}Foreground", swatchName, prefix, name))); doc.Root.Add(foregroundColourElement); return true; }
/// <summary> /// Switch mode RGB/HSV. /// </summary> public void SwitchMode() { ColorMode = ColorMode == ColorMode.Rgb ? ColorMode.Hsv : ColorMode.Rgb; SetMode(ColorMode); }
private void SetColorSettingMode(ColorMode mode, bool autoSave) { bool modeBlackAndWhite = mode == ColorMode.BlackAndWhite; bool modeGrayscale = mode == ColorMode.Grayscale; bool modeColor = mode == ColorMode.Color; SetChecked(barButtonItemBlackAndWhite, modeBlackAndWhite); SetChecked(barButtonItemGrayscale, modeGrayscale); SetChecked(barButtonItemColor, modeColor); if (modeColor) EnableModeColor(); else if (modeGrayscale) EnableModeGrayscale(); else if (modeBlackAndWhite) EnableModeBlackAndWhiteColor(); if (autoSave) scanProfile.CurrentColorMode = mode; BrightnessValueChanged(scanProfile.Brightness, false); ContrastValueChanged(scanProfile.Contrast, false); GammaValueChanged(scanProfile.Gamma, false); SetEnable(barButtonItemSmoothing, scanProfile.CurrentColorMode != ColorMode.BlackAndWhite); SetEnable(barEditItemSmoothingTrackBar, scanProfile.CurrentColorMode != ColorMode.BlackAndWhite); SetEnable(barStaticItemSmoothing, scanProfile.CurrentColorMode != ColorMode.BlackAndWhite); SetEnable(barEditItemSmoothingValue, scanProfile.CurrentColorMode != ColorMode.BlackAndWhite); }
/// <summary> /// Set mode RGB/HSV. /// </summary> public void SetMode(ColorMode mode) { RgbSliders.SetActive(mode == ColorMode.Rgb); HsvSliders.SetActive(mode == ColorMode.Hsv); Mode.text = mode == ColorMode.Rgb ? "HSV" : "RGB"; }
private void RadioPaletted_CheckedChanged(object sender, EventArgs e) { if (RadioPaletted.Checked) { colorMode = ColorMode.Paletted; } }
/// <summary> /// Initializes a new instance of the <see cref="MonoBrick.EV3.ColorSensor"/> class. /// </summary> /// <param name="mode">Mode.</param> public ColorSensor(ColorMode mode) : base((SensorMode)mode) { }
public static void decode(ref Color[] dst, int dst_offset, Color32[] src, int src_offset, int count, ColorMode inMode, bool useGamma) { if (inMode == ColorMode.RGBM8) { for (int i = 0; i < count; ++i) { RGB.fromRGBM(ref dst[i + dst_offset], src[i + src_offset], useGamma); } } else { pixelCopy(ref dst, dst_offset, src, src_offset, count); if (useGamma) { mset.Util.applyGamma(ref dst, Gamma.toLinear); } clearAlpha(ref dst, dst_offset, count); } }
/*--------------------------------------------------------------------------------------------*/ public void SetColorMode(ColorMode pMode, float pHue=0) { vColorMode = pMode; Color color = Color.white; if ( vColorMode == ColorMode.Custom ) { color = HsvToColor(pHue, 1, 1); } for ( int i = 0 ; i < Count ; ++i ) { GameObject cube = vCubes[i]; if ( vColorMode == ColorMode.Random ) { color = cube.GetComponent<DemoCube>().ColorRandom; } cube.GetComponent<Renderer>().sharedMaterial.color = color; } }
public void fromHorizCrossTexture(Texture2D tex, ColorMode texColorMode, bool useGamma) { fromHorizCrossTexture(tex, 0, texColorMode, useGamma); }
public void GetPixelData(ImageBox imageBox, ColorMode colorMode, out ushort rows, out ushort columns, out byte[] pixelData) { Platform.CheckMemberIsSet(GetPixelDataCallback, "GetPixelDataCallback"); GetPixelDataCallback(imageBox, colorMode, out rows, out columns, out pixelData); }
/// <summary> /// Implement this function to make a custom inspector. /// </summary> public override void OnInspectorGUI() { foreach (var d in targets.Cast <UIEffect>()) { var mat = d.material; if (d.isTMPro && mat) { var so = new SerializedObject(d); EffectMode eMode = (EffectMode)GetEnum <EffectMode>(mat); ColorMode cMode = (ColorMode)GetEnum <ColorMode>(mat); BlurMode bMode = (BlurMode)GetEnum <BlurMode>(mat); bool aBlur = mat.IsKeywordEnabled("EX"); if (d.effectMode != eMode || d.colorMode != cMode || d.blurMode != bMode || so.FindProperty("m_AdvancedBlur").boolValue != aBlur) { so.FindProperty("m_EffectMode").intValue = (int)eMode; so.FindProperty("m_ColorMode").intValue = (int)cMode; so.FindProperty("m_BlurMode").intValue = (int)bMode; so.FindProperty("m_AdvancedBlur").boolValue = aBlur; so.ApplyModifiedProperties(); } } } serializedObject.Update(); bool isAnyTMPro = targets.Cast <UIEffect>().Any(x => x.isTMPro); var c = target as UIEffect; //================ // Effect material. //================ var spMaterial = serializedObject.FindProperty("m_EffectMaterial"); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(spMaterial); EditorGUI.EndDisabledGroup(); //================ // Effect setting. //================ var spToneMode = serializedObject.FindProperty("m_EffectMode"); using (new EditorGUI.DisabledGroupScope(isAnyTMPro)) EditorGUILayout.PropertyField(spToneMode); // When tone is enable, show parameters. if (spToneMode.intValue != (int)EffectMode.None) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor")); EditorGUI.indentLevel--; } //================ // Color setting. //================ var spColorMode = serializedObject.FindProperty("m_ColorMode"); using (new EditorGUI.DisabledGroupScope(isAnyTMPro)) EditorGUILayout.PropertyField(spColorMode); // When color is enable, show parameters. //if (spColorMode.intValue != (int)ColorMode.Multiply) { EditorGUI.indentLevel++; SerializedProperty spColor = serializedObject.FindProperty("m_Color"); if (spColor == null && serializedObject.targetObject is UIEffect) { spColor = new SerializedObject(serializedObject.targetObjects.Select(x => (x as UIEffect).targetGraphic).ToArray()).FindProperty(!isAnyTMPro ? "m_Color" : "m_fontColor"); } EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues; #if UNITY_2018_1_OR_NEWER spColor.colorValue = EditorGUILayout.ColorField(contentEffectColor, spColor.colorValue, true, false, false); #else spColor.colorValue = EditorGUILayout.ColorField(contentEffectColor, spColor.colorValue, true, false, false, null); #endif if (EditorGUI.EndChangeCheck()) { spColor.serializedObject.ApplyModifiedProperties(); } EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor")); EditorGUI.indentLevel--; } //================ // Blur setting. //================ var spBlurMode = serializedObject.FindProperty("m_BlurMode"); using (new EditorGUI.DisabledGroupScope(isAnyTMPro)) EditorGUILayout.PropertyField(spBlurMode); // When blur is enable, show parameters. if (spBlurMode.intValue != (int)BlurMode.None) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor")); var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur"); using (new EditorGUI.DisabledGroupScope(isAnyTMPro)) EditorGUILayout.PropertyField(spAdvancedBlur); EditorGUI.indentLevel--; } serializedObject.ApplyModifiedProperties(); c.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat => { }); ShowCanvasChannelsWarning(); ShowMaterialEditors(c.materials, 1, c.materials.Length - 1); serializedObject.ApplyModifiedProperties(); }