public LightBall(string name, Vector3 sPos, Transform eObj, float lTime, Color glowColor) { endPos = eObj.position; lifeTime = lTime; string prefabName = "LightBall(Clone)"; GameObject lightPrefab = PrefabFactory.GetLightBallPrefab(); if (glowColor.Equals(Color.red)){ lightPrefab = PrefabFactory.GetLightBallRedPrefab(); prefabName = "LightBallRed(Clone)"; } else if (glowColor.Equals (Color.blue)){ lightPrefab = PrefabFactory.GetLightBallBluePrefab(); prefabName = "LightBallBlue(Clone)"; } else if (glowColor.Equals (Color.black)){ lightPrefab = PrefabFactory.GetLightBallDarkPrefab(); prefabName = "LightBallDark(Clone)"; } GameManager.InstantiateModel(lightPrefab, sPos); lightBall = GameObject.Find(prefabName); lightBall.name = name; lightBall.AddComponent("LightBallMove"); lightBall.transform.LookAt(eObj); GameObject glow = lightBall.transform.Find("Glow").gameObject; glow.light.color = glowColor; }
IEnumerator colorLerp1(Color col1, Color col2) { float step = 0f; while (!col1.Equals(col2)) { yield return new WaitForSeconds(0.01f); this.gameObject.GetComponent<Renderer>().material.SetColor("_Color", Color.Lerp(col1, col2, step += 0.005f)); } yield return null; }
public void SetColor(Color newColor, float duration = 0) { // Don't do anything if we're being set to the same color: if(!newColor.Equals(targetColor)) { startColor = Color; targetColor = newColor; this.duration = duration; timer = 0; } }
public void Equals() { var color1 = new Color(10, 20, 30, 40); var color2 = new Color(20, 30, 40, 50); Assert.AreNotEqual(color1, color2); Assert.AreEqual(color1, new Color(10, 20, 30, 40)); Assert.IsTrue(color1 == new Color(10, 20, 30, 40)); Assert.IsTrue(color1 != color2); Assert.IsTrue(color1.Equals((object)new Color(10, 20, 30, 40))); Assert.AreEqual(color1.PackedRgba, color1.GetHashCode()); }
public RobotRenderComponent(Entity parent, float height, float scale, Color color) : base(parent, ContentLoader.Robot) { this.Transform = Matrix.Identity; this.height = height; this.colorEffect = ContentLoader.ColorEffect; this.scale = scale; // Temp fix... if (color.Equals(Color.Red)) { this.model = ContentLoader.RobotRed; } else if (color.Equals(Color.Blue)) { this.model = ContentLoader.RobotBlue; } else if (color.Equals(Color.Yellow)) { this.model = ContentLoader.RobotYellow; } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogItemOptionValue other && ((ItemOptionId == null && other.ItemOptionId == null) || (ItemOptionId?.Equals(other.ItemOptionId) == true)) && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((Description == null && other.Description == null) || (Description?.Equals(other.Description) == true)) && ((Color == null && other.Color == null) || (Color?.Equals(other.Color) == true)) && ((Ordinal == null && other.Ordinal == null) || (Ordinal?.Equals(other.Ordinal) == true))); }
public static String getConsoleColor(Color cellColor) { if (cellColor.Equals(Color.Black)) { return "x"; } else if (cellColor.Equals(Color.Cyan)) { return "I"; } else if (cellColor.Equals(Color.Blue)) { return "J"; } else if (cellColor.Equals(Color.Orange)) { return "L"; } else if (cellColor.Equals(Color.Yellow)) { return "O"; } else if (cellColor.Equals(Color.Green)) { return "S"; } else if (cellColor.Equals(Color.Purple)) { return "T"; } else if (cellColor.Equals(Color.Red)) { return "Z"; } else { return "X"; } }
public void Ensure_that_equals_returns_false_when_compared_with_a_different_type_of_object() { var color = new Color(0, 0, 0); Assert.IsFalse(color.Equals("")); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } watch.Restart(); bool update_result = false; Dictionary <DeviceKeys, Color> keyColors = colorComposition.keyColors; if (e.Cancel) { return(false); } try { foreach (KeyValuePair <DeviceKeys, Color> pair in keyColors) { if (e.Cancel) { return(false); } if (useGlobalPeriphericColors) { if (pair.Key == DeviceKeys.Peripheral) // This is not working anymore. Was working in MASTER { ColorKBLeft = pair.Value; ColorKBCenter = pair.Value; ColorKBRight = pair.Value; ColorTouchpad = pair.Value; ColorUpdated = true; } } else { // TouchPad (It would be nice to have a Touchpad Peripheral) if (pair.Key == DeviceKeys.Peripheral) { ColorTouchpad = pair.Value; ColorUpdated = true; } } } if (e.Cancel) { return(false); } if (!useGlobalPeriphericColors) { // Clevo 3 region keyboard // Left Side (From ESC to Half Spacebar) BitmapRectangle keymap_esc = Effects.GetBitmappingFromDeviceKey(DeviceKeys.ESC); BitmapRectangle keymap_space = Effects.GetBitmappingFromDeviceKey(DeviceKeys.SPACE); PointF spacebar_center = keymap_space.Center; // Key Center int spacebar_x = (int)spacebar_center.X - keymap_esc.Left; int height = (int)spacebar_center.Y - keymap_esc.Top; BitmapRectangle region_left = new BitmapRectangle(keymap_esc.Left, keymap_esc.Top, spacebar_x, height); Color RegionLeftColor; lock (colorComposition.bitmapLock) RegionLeftColor = Utils.BitmapUtils.GetRegionColor(colorComposition.keyBitmap, region_left); if (!ColorKBLeft.Equals(RegionLeftColor)) { ColorKBLeft = RegionLeftColor; ColorUpdated = true; } if (e.Cancel) { return(false); } // Center (Other Half of Spacebar to F11) - Clevo keyboards are very compact and the right side color bleeds over to the up/left/right/down keys) BitmapRectangle keymap_f11 = Effects.GetBitmappingFromDeviceKey(DeviceKeys.F11); int f11_x_width = Convert.ToInt32(keymap_f11.Center.X - spacebar_x); BitmapRectangle region_center = new BitmapRectangle(spacebar_x, keymap_esc.Top, f11_x_width, height); Color RegionCenterColor; lock (colorComposition.bitmapLock) RegionCenterColor = Utils.BitmapUtils.GetRegionColor(colorComposition.keyBitmap, region_center); if (!ColorKBCenter.Equals(RegionCenterColor)) { ColorKBCenter = RegionCenterColor; ColorUpdated = true; } if (e.Cancel) { return(false); } // Right Side BitmapRectangle keymap_numenter = Effects.GetBitmappingFromDeviceKey(DeviceKeys.NUM_ENTER); BitmapRectangle region_right = new BitmapRectangle(Convert.ToInt32(keymap_f11.Center.X), keymap_esc.Top, Convert.ToInt32(keymap_numenter.Center.X - keymap_f11.Center.X), height); Color RegionRightColor; lock (colorComposition.bitmapLock) RegionRightColor = Utils.BitmapUtils.GetRegionColor(colorComposition.keyBitmap, region_right); if (!ColorKBRight.Equals(RegionRightColor)) { ColorKBRight = RegionRightColor; ColorUpdated = true; } } if (e.Cancel) { return(false); } SendColorsToKeyboard(forced); update_result = true; } catch (Exception exception) { Global.logger.Error("Clevo device, error when updating device. Error: " + exception); update_result = false; } watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(update_result); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (IsPaused || TimerLimit == 0) { return; } if (IsBreathingIn) { Timer += gameTime.ElapsedGameTime.Milliseconds; if (Timer >= TimerLimit) { Timer = TimerLimit; IsBreathingIn = false; if (!Loop) { IsPaused = true; } } } else { Timer -= gameTime.ElapsedGameTime.Milliseconds; if (Timer <= 0) { Timer = 0; IsBreathingIn = true; if (!Loop) { IsPaused = true; } } } Alpha = MinAlpha + (float)Timer / TimerLimit * (MaxAlpha - MinAlpha); Scale = MinScale + (float)Timer / TimerLimit * (MaxScale - MinScale); if (!StartColor.Equals(EndColor)) { BaseColor = Color.Red; var starColValue = ((float)TimerLimit - Timer) / TimerLimit; var endColValue = (float)Timer / TimerLimit; var r = (int)(StartColor.R * starColValue + EndColor.R * endColValue); var g = (int)(StartColor.G * starColValue + EndColor.G * endColValue); var b = (int)(StartColor.B * starColValue + EndColor.B * endColValue); BaseColor = new Color(r, g, b); } if (!StartTextColor.Equals(EndTextColor)) { var starColValue = ((float)TimerLimit - Timer) / TimerLimit; var endColValue = (float)Timer / TimerLimit; var r = (int)(StartTextColor.R * starColValue + EndTextColor.R * endColValue); var g = (int)(StartTextColor.G * starColValue + EndTextColor.G * endColValue); var b = (int)(StartTextColor.B * starColValue + EndTextColor.B * endColValue); TextColor = new Color(r, g, b); } }
/// <inheritdoc /> public bool Equals([AllowNull] Line other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Width == other.Width || Width != null && Width.Equals(other.Width) ) && ( Equals(WidthArray, other.WidthArray) || WidthArray != null && other.WidthArray != null && WidthArray.SequenceEqual(other.WidthArray) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( Equals(ColorArray, other.ColorArray) || ColorArray != null && other.ColorArray != null && ColorArray.SequenceEqual(other.ColorArray) ) && ( CAuto == other.CAuto || CAuto != null && CAuto.Equals(other.CAuto) ) && ( CMin == other.CMin || CMin != null && CMin.Equals(other.CMin) ) && ( CMax == other.CMax || CMax != null && CMax.Equals(other.CMax) ) && ( CMid == other.CMid || CMid != null && CMid.Equals(other.CMid) ) && ( ColorScale == other.ColorScale || ColorScale != null && ColorScale.Equals(other.ColorScale) ) && ( AutoColorScale == other.AutoColorScale || AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale) ) && ( ReverseScale == other.ReverseScale || ReverseScale != null && ReverseScale.Equals(other.ReverseScale) ) && ( ColorAxis == other.ColorAxis || ColorAxis != null && ColorAxis.Equals(other.ColorAxis) ) && ( WidthSrc == other.WidthSrc || WidthSrc != null && WidthSrc.Equals(other.WidthSrc) ) && ( ColorSrc == other.ColorSrc || ColorSrc != null && ColorSrc.Equals(other.ColorSrc) )); }
/// <summary> /// Returns different tiles depending on the color. /// </summary> /// <param name="trackTexture"></param> /// <param name="x">X coordinate inside the trackTexture</param> /// <param name="y">Y coordinate inside the trackTexture</param> /// <returns></returns> public Tile LoadTile(Texture2D trackTexture, int x, int y) { Color currentColor = GetPixelColor(trackTexture, x, y); horn = Content.Load <SoundEffect>("Sounds/horn"); // Loading the horn sound gameOverSP = Content.Load <SoundEffect>("Sounds/GameOverSP"); // Loading the GameOverSP sound gameOverMP = Content.Load <SoundEffect>("Sounds/GameOverMP"); // Loading the GameOverSP sound winner = Content.Load <SoundEffect>("Sounds/winner"); // Loading the winner sound if (currentColor.Equals(new Color(255, 127, 39))) { // Orange = A Car // Only add the amount of cars needed! if (cars.Count != numberOfPlayers) { cars.Add(new Car(new Vector2(x * Tile.Width, y * Tile.Height), Content.Load <Texture2D>("Cars/Car" + cars.Count), Content.Load <Texture2D>("Cars/CarDead"), 100, 100, 0, 1000.0f, this, cars.Count)); } return(new Tile(Content.Load <Texture2D>("Tiles/Road"), TileCollision.Road)); } else if (currentColor.Equals(new Color(195, 195, 195))) { // Grey = the road return(new Tile(Content.Load <Texture2D>("Tiles/Road"), TileCollision.Road)); } /* Y: Could be used if we want Dirt on the map. * else if (currentColor.Equals(new Color(239, 228, 176))) * { * // Beige = the dirt * return new Tile(Content.Load<Texture2D>("Tiles/Dirt"), TileCollision.Road); * } */ else if (currentColor.Equals(new Color(000, 255, 000))) { // Green = Grass return(new Tile(Content.Load <Texture2D>("Tiles/Grass"), TileCollision.Grass)); } else if (currentColor.Equals(new Color(000, 162, 232))) { // Blue = Water return(new Tile(Content.Load <Texture2D>("Tiles/Water"), TileCollision.Water)); } else if (currentColor.Equals(new Color(185, 122, 87))) { // Beige = Powerup powerups.Add(new Powerup(PowerupType.Fuel, new Vector2(x * Tile.Width, y * Tile.Height), Content.Load <Texture2D>("Tiles/Powerup"), false, false)); return(new Tile(Content.Load <Texture2D>("Tiles/Road"), TileCollision.Road)); } else if (currentColor.Equals(new Color(0, 0, 255))) { // Pure Blue = Health Pistop return(new Tile(Content.Load <Texture2D>("Tiles/PitstopHealth"), TileCollision.PitstopHealth)); } else if (currentColor.Equals(new Color(255, 0, 0))) { // Pure Red = Fuel Pistop return(new Tile(Content.Load <Texture2D>("Tiles/PitstopFuel"), TileCollision.PitstopFuel)); } else if (currentColor.Equals(new Color(163, 073, 164))) { // Purple = Strip return(new Tile(Content.Load <Texture2D>("Tiles/Strip"), TileCollision.Strip)); } else if (currentColor.Equals(new Color(255, 242, 0))) { // Yellow = Pitstop return(new Tile(Content.Load <Texture2D>("Tiles/PitstopStripRed"), TileCollision.PitstopStrip)); } else if (currentColor.Equals(new Color(202, 156, 0))) { // Dark Yellow = Pitstop return(new Tile(Content.Load <Texture2D>("Tiles/PitstopStripWhite"), TileCollision.PitstopStrip)); } else if (currentColor.Equals(new Color(0, 0, 0))) { // Black = Finish / Start if (finish != null && finish.BoundingRectangle.Contains(new Point(x * Tile.Width, y * Tile.Height))) { return(new Tile(Content.Load <Texture2D>("Tiles/Finish"), TileCollision.Checkpoint)); } Point endFinishTile = getEndTile(x, y, currentColor); int widthFinish = endFinishTile.X - x; int heightFinish = endFinishTile.Y - y; finish = new Obstacle(new Rectangle(x * Tile.Width, y * Tile.Height, widthFinish * Tile.Width, heightFinish * Tile.Height)); return(new Tile(Content.Load <Texture2D>("Tiles/Finish"), TileCollision.Checkpoint)); } else if (currentColor.Equals(new Color(255, 255, 255))) { // White = Checkpoint //check if this tile is already included in the checkpoints list // foreach (Obstacle iterator in checkpoints) { if (iterator.BoundingRectangle.Contains(new Point(x * Tile.Width, y * Tile.Height))) { return(new Tile(Content.Load <Texture2D>("Tiles/Checkpoint"), TileCollision.Checkpoint)); } } Color rightTileColor = GetPixelColor(trackTexture, x + 1, y); Color bottomTileColor = GetPixelColor(trackTexture, x, y + 1); Point endCheckpointTile = getEndTile(x, y, currentColor); // Make the Checkpoint Object and add it to the CheckPoints-List. int widthCheckpoint = endCheckpointTile.X - x; int heightCheckpoint = endCheckpointTile.Y - y; Obstacle checkpoint = new Obstacle(new Rectangle(x * Tile.Width, y * Tile.Height, widthCheckpoint * Tile.Width, heightCheckpoint * Tile.Height)); checkpoints.Add(checkpoint); return(new Tile(Content.Load <Texture2D>("Tiles/Checkpoint"), TileCollision.Checkpoint)); } else if (currentColor.Equals(new Color(136, 0, 21))) { // Red = Wall / Solid return(new Tile(Content.Load <Texture2D>("Tiles/Solid"), TileCollision.Solid)); } else { //throw new NotSupportedException(String.Format("Unsupported tile Color {0} at position {1}, {2}.", tileColor, x, y)); return(new Tile(Content.Load <Texture2D>("Tiles/Road"), TileCollision.Road)); // Instead of throwing an exception we load unknown tiles with a road texture. } }
public bool Equals(VertexPositionColorTexture other) { return(Position.Equals(other.Position) && Color.Equals(other.Color) && TextureCoordinate.Equals(other.TextureCoordinate)); }
/// <summary> /// Copy given style to initialize a new instance. /// </summary> /// <param name="style">A Style from which property values are to be copied.</param> public GraphicStyle(Style style, bool scaling = true) : base(style) { float scaleFactor = 1f; if (scaling) { using (var bitmap = new Drawing.Bitmap(1, 1)) using (var graphics = Drawing.Graphics.FromImage(bitmap)) { scaleFactor = 96 / graphics.DpiY; } } if (string.IsNullOrEmpty(Name)) { // TODO: is this needed here? should do in styledialog? Name = "Style-" + new Random().Next(1000, 9999).ToString(); } var fontStyle = Drawing.FontStyle.Regular; if (style.IsBold) { fontStyle |= Drawing.FontStyle.Bold; } if (style.IsItalic) { fontStyle |= Drawing.FontStyle.Italic; } if (style.IsUnderline) { fontStyle |= Drawing.FontStyle.Underline; } if (style.IsStrikethrough) { fontStyle |= Drawing.FontStyle.Strikeout; } try { Font = new Drawing.Font( FontFamily, (float)fontSize * scaleFactor, fontStyle); } catch (Exception exc) { logger.WriteLine( $"Error creating font({FontFamily}, {fontSize}, {fontStyle})", exc); Font = new Drawing.Font( DefaultFontFamily, (float)DefaultFontSize * scaleFactor, fontStyle); } try { Foreground = Color.Equals(Automatic) ? Drawing.Color.Black : Drawing.ColorTranslator.FromHtml(Color); } catch (Exception exc) { logger.WriteLine($"Error translating color {Color}", exc); Foreground = Drawing.Color.Black; } try { Background = Highlight.Equals(Automatic) ? Drawing.Color.Transparent : Drawing.ColorTranslator.FromHtml(Highlight); } catch (Exception exc) { logger.WriteLine($"Error translating highlight {Highlight}", exc); Background = Drawing.Color.Transparent; } }
private bool AllowOnlyChosenColour() { return(!resultantColour.Equals(colourToAllow)); }
protected bool Equals(Shadow other) { return(distance.Equals(other.distance) && angle.Equals(other.angle) && color.Equals(other.color)); }
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary> /// <param name="other">An object to compare with this object.</param> /// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns> public bool Equals(VertexPositionColor other) { return(Position.Equals(other.Position) && Color.Equals(other.Color)); }
/// <inheritdoc /> public bool Equals([AllowNull] Y other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Show == other.Show || Show != null && Show.Equals(other.Show) ) && ( Start == other.Start || Start != null && Start.Equals(other.Start) ) && ( End == other.End || End != null && End.Equals(other.End) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( Project == other.Project || Project != null && Project.Equals(other.Project) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( UseColorMap == other.UseColorMap || UseColorMap != null && UseColorMap.Equals(other.UseColorMap) ) && ( Width == other.Width || Width != null && Width.Equals(other.Width) ) && ( Highlight == other.Highlight || Highlight != null && Highlight.Equals(other.Highlight) ) && ( HighlightColor == other.HighlightColor || HighlightColor != null && HighlightColor.Equals(other.HighlightColor) ) && ( HighlightWidth == other.HighlightWidth || HighlightWidth != null && HighlightWidth.Equals(other.HighlightWidth) )); }
private bool ShouldSerializeInErrorBorderColor() { return(!InErrorBorderColor.Equals(Color.Red)); }
public void Ensure_that_equals_returns_true_for_identity() { var color = new Color(0, 0, 0); Assert.IsTrue(color.Equals(color)); Assert.IsTrue(color.Equals((object)color)); }
private void createImagesWithLetters() { int cropWidth = letterInformation.CropWidth; int cropHeight = letterInformation.CropHeight; int tmpWidth = 3 * cropWidth; int tmpHeight = 3 * cropHeight; int trashSize = letterInformation.TrashSize; OCRExtractLetter extractionLetter = new OCRExtractLetter(tmpWidth, tmpHeight, trashSize); int letterSize = letterInformation.LetterSize; int imageHeight = image.Height; int imageWidth = image.Width; //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: bool[][] visited = new bool[imageHeight][imageWidth]; bool[][] visited = RectangularArrays.ReturnRectangularBoolArray(imageHeight, imageWidth); Color white = Color.WHITE; Color color; int seqNum = 0; for (int line = 0; line < textInformation.numberOfRows(); line++) { //============================================================================== for (int j = 0; j < imageWidth; j++) { for (int k = -(letterSize / 4); k < (letterSize / 4); k++) { int rowPixel = textInformation.getRowAt(line); int i = rowPixel + k; if (i < 0 || i >= imageHeight) { continue; } //============================================================================== // fornja verzija radi, ova ima gresku // for (int k = -(letterSize / 4); k < (letterSize / 4); k++) { // int rowPixel = textInformation.getRowAt(line); // int i = rowPixel + k; // if (i < 0 || i >= imageHeight) { // continue; // } // for (int j = 0; j < imageWidth; j++) { //============================================================================== color = new Color(image.getRGB(j, i)); if (color.Equals(white)) { visited[i][j] = true; } else if (visited[i][j] == false) { BufferedImage letter = extractionLetter.extraxtLetter(image, visited, i, j); // OCRUtilities.extraxtCharacterImage(image, visited, i, j, tmpWidth, tmpHeight, letterInformation.getTrashSize()); if (letter != null) { OCRCropLetter crop = new OCRCropLetter(letter, cropWidth, cropHeight); BufferedImage croped = crop.processImage(); string character = trainingText[seqNum] + ""; string name = character + "_" + seqNum; OCRUtilities.saveToFile(croped, folderPath, name, imageExtension); seqNum++; } } } } } }
// public static void DrawTexture(Rect _DrawRect, SpriteRenderer sprr, bool _bSimpleDraw = false) // { // if (sprr == null) // { // EditorGUI.LabelField(_DrawRect, "No Texture!"); // return; // } // DrawSprite(_DrawRect, sprr.sprite, _bSimpleDraw); // } public static void DrawSprite(Rect _DrawRect, Sprite _sprite, Color _color, bool _bSquare, bool _bSimpleDraw) { if (_sprite == null || _sprite.texture == null) { EditorGUI.LabelField(_DrawRect, "No Texture!"); return; } if (_bSquare) { _DrawRect.width = _DrawRect.height = Mathf.Min(_DrawRect.width, _DrawRect.height); } Texture texture = _sprite.texture; bool bRectPacked = _sprite.packed && _sprite.packingMode == SpritePackingMode.Rectangle; Rect tr = bRectPacked ? _sprite.textureRect : _sprite.rect; Rect _SourceRect = new Rect(tr.x / texture.width, tr.y / texture.height, tr.width / texture.width, tr.height / texture.height); if (_bSimpleDraw) { float fRatio = tr.width / tr.height; if (fRatio > 1) { _DrawRect.height /= fRatio; } else if (fRatio < 1) { _DrawRect.width *= fRatio; } } bool bDrawColorRect = !_SourceRect.Equals(new Rect(0, 0, 1, 1)); #if !UNITY_2017_1_OR_NEWER bDrawColorRect = true; #endif if (!_color.Equals(Color.clear)) { if (bDrawColorRect) { GUI.DrawTextureWithTexCoords(_DrawRect, texture, _SourceRect); Rect _rt = new Rect(); float _size = Mathf.Min(_DrawRect.width, _DrawRect.height) * 0.25f; _rt.x = (_DrawRect.xMin + _DrawRect.xMax - _size) * 0.5f; _rt.y = (_DrawRect.yMin + _DrawRect.yMax - _size) * 0.5f; _rt.width = _rt.height = _size; EditorGUI.DrawRect(_rt, _color); } #if UNITY_2017_1_OR_NEWER else { GUI.DrawTexture(_DrawRect, texture, ScaleMode.StretchToFill, true, 1, _color, 0, 0); } #endif } else { GUI.DrawTextureWithTexCoords(_DrawRect, texture, _SourceRect); } if (EditorApplication.isPlaying && _sprite.packed) { GUI.Label(_DrawRect, "Playing Mode\nPacked Texture"); } }
/// <inheritdoc /> public bool Equals([AllowNull] CAxis other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( TickMode == other.TickMode || TickMode != null && TickMode.Equals(other.TickMode) ) && ( NTicks == other.NTicks || NTicks != null && NTicks.Equals(other.NTicks) ) && ( Tick0 == other.Tick0 || Tick0 != null && Tick0.Equals(other.Tick0) ) && ( DTick == other.DTick || DTick != null && DTick.Equals(other.DTick) ) && ( Equals(TickVals, other.TickVals) || TickVals != null && other.TickVals != null && TickVals.SequenceEqual(other.TickVals) ) && ( Equals(TickText, other.TickText) || TickText != null && other.TickText != null && TickText.SequenceEqual(other.TickText) ) && ( Ticks == other.Ticks || Ticks != null && Ticks.Equals(other.Ticks) ) && ( TickleN == other.TickleN || TickleN != null && TickleN.Equals(other.TickleN) ) && ( TickWidth == other.TickWidth || TickWidth != null && TickWidth.Equals(other.TickWidth) ) && ( TickColor == other.TickColor || TickColor != null && TickColor.Equals(other.TickColor) ) && ( ShowTickLabels == other.ShowTickLabels || ShowTickLabels != null && ShowTickLabels.Equals(other.ShowTickLabels) ) && ( ShowTickPrefix == other.ShowTickPrefix || ShowTickPrefix != null && ShowTickPrefix.Equals(other.ShowTickPrefix) ) && ( TickPrefix == other.TickPrefix || TickPrefix != null && TickPrefix.Equals(other.TickPrefix) ) && ( ShowTickSuffix == other.ShowTickSuffix || ShowTickSuffix != null && ShowTickSuffix.Equals(other.ShowTickSuffix) ) && ( TickSuffix == other.TickSuffix || TickSuffix != null && TickSuffix.Equals(other.TickSuffix) ) && ( ShowExponent == other.ShowExponent || ShowExponent != null && ShowExponent.Equals(other.ShowExponent) ) && ( ExponentFormat == other.ExponentFormat || ExponentFormat != null && ExponentFormat.Equals(other.ExponentFormat) ) && ( SeparateThousands == other.SeparateThousands || SeparateThousands != null && SeparateThousands.Equals(other.SeparateThousands) ) && ( TickFont == other.TickFont || TickFont != null && TickFont.Equals(other.TickFont) ) && ( TickAngle == other.TickAngle || TickAngle != null && TickAngle.Equals(other.TickAngle) ) && ( TickFormat == other.TickFormat || TickFormat != null && TickFormat.Equals(other.TickFormat) ) && ( Equals(TickFormatStops, other.TickFormatStops) || TickFormatStops != null && other.TickFormatStops != null && TickFormatStops.SequenceEqual(other.TickFormatStops) ) && ( HoverFormat == other.HoverFormat || HoverFormat != null && HoverFormat.Equals(other.HoverFormat) ) && ( ShowLine == other.ShowLine || ShowLine != null && ShowLine.Equals(other.ShowLine) ) && ( LineColor == other.LineColor || LineColor != null && LineColor.Equals(other.LineColor) ) && ( LineWidth == other.LineWidth || LineWidth != null && LineWidth.Equals(other.LineWidth) ) && ( ShowGrid == other.ShowGrid || ShowGrid != null && ShowGrid.Equals(other.ShowGrid) ) && ( GridColor == other.GridColor || GridColor != null && GridColor.Equals(other.GridColor) ) && ( GridWidth == other.GridWidth || GridWidth != null && GridWidth.Equals(other.GridWidth) ) && ( Layer == other.Layer || Layer != null && Layer.Equals(other.Layer) ) && ( UiRevision == other.UiRevision || UiRevision != null && UiRevision.Equals(other.UiRevision) ) && ( TickValsSrc == other.TickValsSrc || TickValsSrc != null && TickValsSrc.Equals(other.TickValsSrc) ) && ( TickTextSrc == other.TickTextSrc || TickTextSrc != null && TickTextSrc.Equals(other.TickTextSrc) )); }
/// <summary> /// Decodes the given Brainloller bitmap. /// </summary> /// <param name="bmp">The bitmap to decode.</param> /// <returns>The Brainfuck code contained in the bitmap.</returns> public static string Decode(Bitmap bmp) { string code = ""; Direction dir = Direction.east; int curX = 0, curY = 0; while ((curX >= 0 && curX < bmp.Width) && (curY >= 0 && curY < bmp.Height)) { Color clr = bmp.GetPixel(curX, curY); if (clr.Equals(CommandColors.Right)) { code += ">"; } if (clr.Equals(CommandColors.Left)) { code += "<"; } if (clr.Equals(CommandColors.Inc)) { code += "+"; } if (clr.Equals(CommandColors.Dec)) { code += "-"; } if (clr.Equals(CommandColors.Print)) { code += "."; } if (clr.Equals(CommandColors.Read)) { code += ","; } if (clr.Equals(CommandColors.LoopStart)) { code += "["; } if (clr.Equals(CommandColors.LoopEnd)) { code += "]"; } if (clr.Equals(CommandColors.RotateCW)) { switch (dir) { case Direction.east: dir = Direction.south; break; case Direction.south: dir = Direction.west; break; case Direction.west: dir = Direction.north; break; case Direction.north: dir = Direction.east; break; default: break; } } if (clr.Equals(CommandColors.RotateCCW)) { switch (dir) { case Direction.east: dir = Direction.north; break; case Direction.south: dir = Direction.east; break; case Direction.west: dir = Direction.south; break; case Direction.north: dir = Direction.west; break; default: break; } } switch (dir) { case Direction.east: curX++; break; case Direction.west: curX--; break; case Direction.north: curY--; break; case Direction.south: curY++; break; default: break; } } return(code); }
public Boolean Equal(Color color) { return(color.Equals(rgb)); }
protected override void OnPaint(PaintEventArgs e) { float percent = (float)(val - min) / (float)(max - min); Rectangle rect = this.ClientRectangle; // Calculate area for drawing the progress. int rectWidth = (int)((float)rect.Width * percent / (val != 0 ? val : 1)); Graphics g = e.Graphics; SolidBrush brush; LinearGradientBrush linGrBrush; int numberofcolors = progressColorList.Count; int countGreen = 0; int countRed = 0; int countGray = 0; List <Color> .Enumerator en = progressColorList.GetEnumerator(); while (en.MoveNext()) { Color currentColor = en.Current; if (currentColor.Equals(Color.Green)) { countGreen++; } if (currentColor.Equals(Color.Red)) { countRed++; } countGray++; } en.Dispose(); countGray -= countGreen + countRed; linGrBrush = new LinearGradientBrush( new Point(0, 0), new Point(0, 24), Color.LightGreen, Color.Green); //brush = new SolidBrush(Color.Green); rect.X = 0; rect.Width = rectWidth * countGreen; g.FillRectangle(linGrBrush, rect); linGrBrush = new LinearGradientBrush( new Point(0, 0), new Point(0, 24), Color.Red, Color.DarkRed); //brush = new SolidBrush(Color.Red); rect.X = rectWidth * countGreen; rect.Width = rectWidth * countRed; g.FillRectangle(linGrBrush, rect); linGrBrush = new LinearGradientBrush( new Point(0, 0), new Point(0, 24), Color.LightGray, Color.Gray); //brush = new SolidBrush(Color.Gray); rect.X = rectWidth * (countGreen + countRed); rect.Width = rectWidth * countGray; g.FillRectangle(linGrBrush, rect); // Clean up. linGrBrush.Dispose(); // Draw a three-dimensional border around the control. Draw3DBorder(g); g.Dispose(); }
private bool ShouldSerializeBorderColor() { return(!BorderColor.Equals(Color.Black)); }
/// <summary> /// sets the vertex color of a tile /// </summary> public Color VColor(IVector2 tile, Color color) { try { Color[] colors = mesh.colors; int vidx = ((tile.x * tileMatrix.y) + tile.y) * 4; if (!color.Equals(Color.clear)) { colors[vidx + 0] = color; colors[vidx + 1] = color; colors[vidx + 2] = color; colors[vidx + 3] = color; mesh.colors = colors; } return colors[vidx + 0]; } catch(System.Exception) { } return Color.clear; }
private bool ShouldSerializeImageTransparentColor() { return((_imageTransparentColor == null) || !_imageTransparentColor.Equals(Color.Empty)); }
/// <inheritdoc /> public bool Equals([AllowNull] AAxis other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( Smoothing == other.Smoothing || Smoothing != null && Smoothing.Equals(other.Smoothing) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( AutoRange == other.AutoRange || AutoRange != null && AutoRange.Equals(other.AutoRange) ) && ( RangeMode == other.RangeMode || RangeMode != null && RangeMode.Equals(other.RangeMode) ) && ( Equals(Range, other.Range) || Range != null && other.Range != null && Range.SequenceEqual(other.Range) ) && ( FixedRange == other.FixedRange || FixedRange != null && FixedRange.Equals(other.FixedRange) ) && ( CheaterType == other.CheaterType || CheaterType != null && CheaterType.Equals(other.CheaterType) ) && ( TickMode == other.TickMode || TickMode != null && TickMode.Equals(other.TickMode) ) && ( NTicks == other.NTicks || NTicks != null && NTicks.Equals(other.NTicks) ) && ( Equals(TickVals, other.TickVals) || TickVals != null && other.TickVals != null && TickVals.SequenceEqual(other.TickVals) ) && ( Equals(TickText, other.TickText) || TickText != null && other.TickText != null && TickText.SequenceEqual(other.TickText) ) && ( ShowTickLabels == other.ShowTickLabels || ShowTickLabels != null && ShowTickLabels.Equals(other.ShowTickLabels) ) && ( TickFont == other.TickFont || TickFont != null && TickFont.Equals(other.TickFont) ) && ( TickAngle == other.TickAngle || TickAngle != null && TickAngle.Equals(other.TickAngle) ) && ( TickPrefix == other.TickPrefix || TickPrefix != null && TickPrefix.Equals(other.TickPrefix) ) && ( ShowTickPrefix == other.ShowTickPrefix || ShowTickPrefix != null && ShowTickPrefix.Equals(other.ShowTickPrefix) ) && ( TickSuffix == other.TickSuffix || TickSuffix != null && TickSuffix.Equals(other.TickSuffix) ) && ( ShowTickSuffix == other.ShowTickSuffix || ShowTickSuffix != null && ShowTickSuffix.Equals(other.ShowTickSuffix) ) && ( ShowExponent == other.ShowExponent || ShowExponent != null && ShowExponent.Equals(other.ShowExponent) ) && ( ExponentFormat == other.ExponentFormat || ExponentFormat != null && ExponentFormat.Equals(other.ExponentFormat) ) && ( SeparateThousands == other.SeparateThousands || SeparateThousands != null && SeparateThousands.Equals(other.SeparateThousands) ) && ( TickFormat == other.TickFormat || TickFormat != null && TickFormat.Equals(other.TickFormat) ) && ( Equals(TickFormatStops, other.TickFormatStops) || TickFormatStops != null && other.TickFormatStops != null && TickFormatStops.SequenceEqual(other.TickFormatStops) ) && ( CategoryOrder == other.CategoryOrder || CategoryOrder != null && CategoryOrder.Equals(other.CategoryOrder) ) && ( Equals(CategoryArray, other.CategoryArray) || CategoryArray != null && other.CategoryArray != null && CategoryArray.SequenceEqual(other.CategoryArray) ) && ( LabelPadding == other.LabelPadding || LabelPadding != null && LabelPadding.Equals(other.LabelPadding) ) && ( LabelPrefix == other.LabelPrefix || LabelPrefix != null && LabelPrefix.Equals(other.LabelPrefix) ) && ( LabelSuffix == other.LabelSuffix || LabelSuffix != null && LabelSuffix.Equals(other.LabelSuffix) ) && ( ShowLine == other.ShowLine || ShowLine != null && ShowLine.Equals(other.ShowLine) ) && ( LineColor == other.LineColor || LineColor != null && LineColor.Equals(other.LineColor) ) && ( LineWidth == other.LineWidth || LineWidth != null && LineWidth.Equals(other.LineWidth) ) && ( GridColor == other.GridColor || GridColor != null && GridColor.Equals(other.GridColor) ) && ( GridWidth == other.GridWidth || GridWidth != null && GridWidth.Equals(other.GridWidth) ) && ( ShowGrid == other.ShowGrid || ShowGrid != null && ShowGrid.Equals(other.ShowGrid) ) && ( MinorGridCount == other.MinorGridCount || MinorGridCount != null && MinorGridCount.Equals(other.MinorGridCount) ) && ( MinorGridWidth == other.MinorGridWidth || MinorGridWidth != null && MinorGridWidth.Equals(other.MinorGridWidth) ) && ( MinorGridColor == other.MinorGridColor || MinorGridColor != null && MinorGridColor.Equals(other.MinorGridColor) ) && ( StartLine == other.StartLine || StartLine != null && StartLine.Equals(other.StartLine) ) && ( StartLineColor == other.StartLineColor || StartLineColor != null && StartLineColor.Equals(other.StartLineColor) ) && ( StartLineWidth == other.StartLineWidth || StartLineWidth != null && StartLineWidth.Equals(other.StartLineWidth) ) && ( EndLine == other.EndLine || EndLine != null && EndLine.Equals(other.EndLine) ) && ( EndlineWidth == other.EndlineWidth || EndlineWidth != null && EndlineWidth.Equals(other.EndlineWidth) ) && ( EndlineColor == other.EndlineColor || EndlineColor != null && EndlineColor.Equals(other.EndlineColor) ) && ( Tick0 == other.Tick0 || Tick0 != null && Tick0.Equals(other.Tick0) ) && ( DTick == other.DTick || DTick != null && DTick.Equals(other.DTick) ) && ( ArrayTick0 == other.ArrayTick0 || ArrayTick0 != null && ArrayTick0.Equals(other.ArrayTick0) ) && ( ArrayDTick == other.ArrayDTick || ArrayDTick != null && ArrayDTick.Equals(other.ArrayDTick) ) && ( TickValsSrc == other.TickValsSrc || TickValsSrc != null && TickValsSrc.Equals(other.TickValsSrc) ) && ( TickTextSrc == other.TickTextSrc || TickTextSrc != null && TickTextSrc.Equals(other.TickTextSrc) ) && ( CategoryArraySrc == other.CategoryArraySrc || CategoryArraySrc != null && CategoryArraySrc.Equals(other.CategoryArraySrc) )); }
/// <inheritdoc /> public bool Equals([AllowNull] XAxis other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Visible == other.Visible || Visible != null && Visible.Equals(other.Visible) ) && ( ShowSpikes == other.ShowSpikes || ShowSpikes != null && ShowSpikes.Equals(other.ShowSpikes) ) && ( SpikeSides == other.SpikeSides || SpikeSides != null && SpikeSides.Equals(other.SpikeSides) ) && ( SpikeThickness == other.SpikeThickness || SpikeThickness != null && SpikeThickness.Equals(other.SpikeThickness) ) && ( SpikeColor == other.SpikeColor || SpikeColor != null && SpikeColor.Equals(other.SpikeColor) ) && ( ShowBackground == other.ShowBackground || ShowBackground != null && ShowBackground.Equals(other.ShowBackground) ) && ( BackgroundColor == other.BackgroundColor || BackgroundColor != null && BackgroundColor.Equals(other.BackgroundColor) ) && ( ShowAxesLabels == other.ShowAxesLabels || ShowAxesLabels != null && ShowAxesLabels.Equals(other.ShowAxesLabels) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( CategoryOrder == other.CategoryOrder || CategoryOrder != null && CategoryOrder.Equals(other.CategoryOrder) ) && ( Equals(CategoryArray, other.CategoryArray) || CategoryArray != null && other.CategoryArray != null && CategoryArray.SequenceEqual(other.CategoryArray) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( AutoRange == other.AutoRange || AutoRange != null && AutoRange.Equals(other.AutoRange) ) && ( RangeMode == other.RangeMode || RangeMode != null && RangeMode.Equals(other.RangeMode) ) && ( Equals(Range, other.Range) || Range != null && other.Range != null && Range.SequenceEqual(other.Range) ) && ( TickMode == other.TickMode || TickMode != null && TickMode.Equals(other.TickMode) ) && ( NTicks == other.NTicks || NTicks != null && NTicks.Equals(other.NTicks) ) && ( Tick0 == other.Tick0 || Tick0 != null && Tick0.Equals(other.Tick0) ) && ( DTick == other.DTick || DTick != null && DTick.Equals(other.DTick) ) && ( Equals(TickVals, other.TickVals) || TickVals != null && other.TickVals != null && TickVals.SequenceEqual(other.TickVals) ) && ( Equals(TickText, other.TickText) || TickText != null && other.TickText != null && TickText.SequenceEqual(other.TickText) ) && ( Ticks == other.Ticks || Ticks != null && Ticks.Equals(other.Ticks) ) && ( Mirror == other.Mirror || Mirror != null && Mirror.Equals(other.Mirror) ) && ( TickleN == other.TickleN || TickleN != null && TickleN.Equals(other.TickleN) ) && ( TickWidth == other.TickWidth || TickWidth != null && TickWidth.Equals(other.TickWidth) ) && ( TickColor == other.TickColor || TickColor != null && TickColor.Equals(other.TickColor) ) && ( ShowTickLabels == other.ShowTickLabels || ShowTickLabels != null && ShowTickLabels.Equals(other.ShowTickLabels) ) && ( TickFont == other.TickFont || TickFont != null && TickFont.Equals(other.TickFont) ) && ( TickAngle == other.TickAngle || TickAngle != null && TickAngle.Equals(other.TickAngle) ) && ( TickPrefix == other.TickPrefix || TickPrefix != null && TickPrefix.Equals(other.TickPrefix) ) && ( ShowTickPrefix == other.ShowTickPrefix || ShowTickPrefix != null && ShowTickPrefix.Equals(other.ShowTickPrefix) ) && ( TickSuffix == other.TickSuffix || TickSuffix != null && TickSuffix.Equals(other.TickSuffix) ) && ( ShowTickSuffix == other.ShowTickSuffix || ShowTickSuffix != null && ShowTickSuffix.Equals(other.ShowTickSuffix) ) && ( ShowExponent == other.ShowExponent || ShowExponent != null && ShowExponent.Equals(other.ShowExponent) ) && ( ExponentFormat == other.ExponentFormat || ExponentFormat != null && ExponentFormat.Equals(other.ExponentFormat) ) && ( SeparateThousands == other.SeparateThousands || SeparateThousands != null && SeparateThousands.Equals(other.SeparateThousands) ) && ( TickFormat == other.TickFormat || TickFormat != null && TickFormat.Equals(other.TickFormat) ) && ( Equals(TickFormatStops, other.TickFormatStops) || TickFormatStops != null && other.TickFormatStops != null && TickFormatStops.SequenceEqual(other.TickFormatStops) ) && ( HoverFormat == other.HoverFormat || HoverFormat != null && HoverFormat.Equals(other.HoverFormat) ) && ( ShowLine == other.ShowLine || ShowLine != null && ShowLine.Equals(other.ShowLine) ) && ( LineColor == other.LineColor || LineColor != null && LineColor.Equals(other.LineColor) ) && ( LineWidth == other.LineWidth || LineWidth != null && LineWidth.Equals(other.LineWidth) ) && ( ShowGrid == other.ShowGrid || ShowGrid != null && ShowGrid.Equals(other.ShowGrid) ) && ( GridColor == other.GridColor || GridColor != null && GridColor.Equals(other.GridColor) ) && ( GridWidth == other.GridWidth || GridWidth != null && GridWidth.Equals(other.GridWidth) ) && ( ZeroLine == other.ZeroLine || ZeroLine != null && ZeroLine.Equals(other.ZeroLine) ) && ( ZeroLineColor == other.ZeroLineColor || ZeroLineColor != null && ZeroLineColor.Equals(other.ZeroLineColor) ) && ( ZeroLineWidth == other.ZeroLineWidth || ZeroLineWidth != null && ZeroLineWidth.Equals(other.ZeroLineWidth) ) && ( Calendar == other.Calendar || Calendar != null && Calendar.Equals(other.Calendar) ) && ( CategoryArraySrc == other.CategoryArraySrc || CategoryArraySrc != null && CategoryArraySrc.Equals(other.CategoryArraySrc) ) && ( TickValsSrc == other.TickValsSrc || TickValsSrc != null && TickValsSrc.Equals(other.TickValsSrc) ) && ( TickTextSrc == other.TickTextSrc || TickTextSrc != null && TickTextSrc.Equals(other.TickTextSrc) )); }
public bool TrueColor(Color needColor) { Color tempColor = uiButter.GetColor(); return(needColor.Equals(tempColor)); }
public bool Equals(KeyBlendState blendState) { return(colorFrom.Equals(blendState.colorFrom) && colorTo.Equals(blendState.colorTo)); }
/// <summary> /// Helper function sets a color overlay for every vertex in the buffer /// </summary> /// <param name="color">Color</param> public void SetColor(Color color) { // inefficient if (color.Equals(verts[0].Color)) return; for (int i = 0; i < verts.Length; i++) { verts[i].Color = color; } vertexBuffer.SetData<VertexPositionColorTexture>(verts); }
/// <summary> /// Reads a triangle from a binary STL file. /// </summary> /// <param name="reader"> /// The reader. /// </param> private void ReadTriangle(BinaryReader reader) { float ni = ReadFloat(reader); float nj = ReadFloat(reader); float nk = ReadFloat(reader); #pragma warning disable 168 var n = new Vector3D(ni, nj, nk); #pragma warning restore 168 float x1 = ReadFloat(reader); float y1 = ReadFloat(reader); float z1 = ReadFloat(reader); var v1 = new Point3D(x1, y1, z1); float x2 = ReadFloat(reader); float y2 = ReadFloat(reader); float z2 = ReadFloat(reader); var v2 = new Point3D(x2, y2, z2); float x3 = ReadFloat(reader); float y3 = ReadFloat(reader); float z3 = ReadFloat(reader); var v3 = new Point3D(x3, y3, z3); var attrib = Convert.ToString(ReadUInt16(reader), 2).PadLeft(16, '0').ToCharArray(); var hasColor = attrib[0].Equals('1'); if (hasColor) { int blue = attrib[15].Equals('1') ? 1 : 0; blue = attrib[14].Equals('1') ? blue + 2 : blue; blue = attrib[13].Equals('1') ? blue + 4 : blue; blue = attrib[12].Equals('1') ? blue + 8 : blue; blue = attrib[11].Equals('1') ? blue + 16 : blue; int b = blue * 8; int green = attrib[10].Equals('1') ? 1 : 0; green = attrib[9].Equals('1') ? green + 2 : green; green = attrib[8].Equals('1') ? green + 4 : green; green = attrib[7].Equals('1') ? green + 8 : green; green = attrib[6].Equals('1') ? green + 16 : green; int g = green * 8; int red = attrib[5].Equals('1') ? 1 : 0; red = attrib[4].Equals('1') ? red + 2 : red; red = attrib[3].Equals('1') ? red + 4 : red; red = attrib[2].Equals('1') ? red + 8 : red; red = attrib[1].Equals('1') ? red + 16 : red; int r = red * 8; var currentColor = Color.FromRgb(Convert.ToByte(r), Convert.ToByte(g), Convert.ToByte(b)); if (!Color.Equals(this.lastColor, currentColor)) { this.lastColor = currentColor; this.index++; } if (this.Materials.Count < this.index + 1) { this.Materials.Add(MaterialHelper.CreateMaterial(currentColor)); } } else { if (this.Materials.Count < this.index + 1) { this.Materials.Add(this.DefaultMaterial); } } if (this.Meshes.Count < this.index + 1) { this.Meshes.Add(new MeshBuilder(true, true)); } this.Meshes[this.index].AddTriangle(v1, v2, v3); // todo: add normal }
public void Ensure_that_equals_returns_false_when_compared_with_null() { var color = new Color(0, 0, 0); Assert.IsFalse(color.Equals(null)); Assert.IsFalse(color.Equals((object)null)); }
public bool Equals(LinearGradientBrushTool other) { return(ColorA.Equals(other.ColorA) && ColorB.Equals(other.ColorB) && Angle.Equals(other.Angle) && Opacity.Equals(other.Opacity)); }
private void FixColors() { // Fix the color of the button. btnChronoColor.FlatAppearance.MouseOverBackColor = btnChronoColor.BackColor; // Put a black frame around white rectangles. if (Color.Equals(btnChronoColor.BackColor, Color.FromArgb(255, 255, 255)) || Color.Equals(btnChronoColor.BackColor, Color.White)) { btnChronoColor.FlatAppearance.BorderSize = 1; } else { btnChronoColor.FlatAppearance.BorderSize = 0; } }
/// <inheritdoc /> public bool Equals([AllowNull] ErrorY other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Visible == other.Visible || Visible != null && Visible.Equals(other.Visible) ) && ( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( Symmetric == other.Symmetric || Symmetric != null && Symmetric.Equals(other.Symmetric) ) && ( Equals(Array, other.Array) || Array != null && other.Array != null && Array.SequenceEqual(other.Array) ) && ( Equals(ArrayMinus, other.ArrayMinus) || ArrayMinus != null && other.ArrayMinus != null && ArrayMinus.SequenceEqual(other.ArrayMinus) ) && ( Value == other.Value || Value != null && Value.Equals(other.Value) ) && ( ValueMinus == other.ValueMinus || ValueMinus != null && ValueMinus.Equals(other.ValueMinus) ) && ( TraceRef == other.TraceRef || TraceRef != null && TraceRef.Equals(other.TraceRef) ) && ( TraceRefMinus == other.TraceRefMinus || TraceRefMinus != null && TraceRefMinus.Equals(other.TraceRefMinus) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( Thickness == other.Thickness || Thickness != null && Thickness.Equals(other.Thickness) ) && ( Width == other.Width || Width != null && Width.Equals(other.Width) ) && ( ArraySrc == other.ArraySrc || ArraySrc != null && ArraySrc.Equals(other.ArraySrc) ) && ( ArrayMinusSrc == other.ArrayMinusSrc || ArrayMinusSrc != null && ArrayMinusSrc.Equals(other.ArrayMinusSrc) )); }
public void Equality(Color left, Color right, bool expected) { Assert.True(left.Equals(left), "left should always Equals itself"); Assert.True(right.Equals(right), "right should always Equals itself"); Assert.Equal(expected, left == right); Assert.Equal(expected, right == left); Assert.Equal(expected, left.Equals(right)); Assert.Equal(expected, right.Equals(left)); Assert.Equal(!expected, left != right); Assert.Equal(!expected, right != left); }
internal virtual void UpdateWrapperLights(IGameState new_game_state) { if (new_game_state is GameState_Wrapper) { _game_state = new_game_state; GameState_Wrapper ngw_state = (new_game_state as GameState_Wrapper); if (ngw_state.Sent_Bitmap.Length != 0) { bitmap = ngw_state.Sent_Bitmap; } SetExtraKey(Devices.DeviceKeys.LOGO, ngw_state.Extra_Keys.logo); SetExtraKey(Devices.DeviceKeys.LOGO2, ngw_state.Extra_Keys.badge); //Reversing the mousepad lights from left to right, razer takes it from right to left SetExtraKey(Devices.DeviceKeys.Peripheral, ngw_state.Extra_Keys.peripheral); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT15, ngw_state.Extra_Keys.mousepad1); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT14, ngw_state.Extra_Keys.mousepad2); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT13, ngw_state.Extra_Keys.mousepad3); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT12, ngw_state.Extra_Keys.mousepad4); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT11, ngw_state.Extra_Keys.mousepad5); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT10, ngw_state.Extra_Keys.mousepad6); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT9, ngw_state.Extra_Keys.mousepad7); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT8, ngw_state.Extra_Keys.mousepad8); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT7, ngw_state.Extra_Keys.mousepad9); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT6, ngw_state.Extra_Keys.mousepad10); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT5, ngw_state.Extra_Keys.mousepad11); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT4, ngw_state.Extra_Keys.mousepad12); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT3, ngw_state.Extra_Keys.mousepad13); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT2, ngw_state.Extra_Keys.mousepad14); SetExtraKey(Devices.DeviceKeys.MOUSEPADLIGHT1, ngw_state.Extra_Keys.mousepad15); SetExtraKey(Devices.DeviceKeys.G1, ngw_state.Extra_Keys.G1); SetExtraKey(Devices.DeviceKeys.G2, ngw_state.Extra_Keys.G2); SetExtraKey(Devices.DeviceKeys.G3, ngw_state.Extra_Keys.G3); SetExtraKey(Devices.DeviceKeys.G4, ngw_state.Extra_Keys.G4); SetExtraKey(Devices.DeviceKeys.G5, ngw_state.Extra_Keys.G5); SetExtraKey(Devices.DeviceKeys.G6, ngw_state.Extra_Keys.G6); SetExtraKey(Devices.DeviceKeys.G7, ngw_state.Extra_Keys.G7); SetExtraKey(Devices.DeviceKeys.G8, ngw_state.Extra_Keys.G8); SetExtraKey(Devices.DeviceKeys.G9, ngw_state.Extra_Keys.G9); SetExtraKey(Devices.DeviceKeys.G10, ngw_state.Extra_Keys.G10); SetExtraKey(Devices.DeviceKeys.G11, ngw_state.Extra_Keys.G11); SetExtraKey(Devices.DeviceKeys.G12, ngw_state.Extra_Keys.G12); SetExtraKey(Devices.DeviceKeys.G13, ngw_state.Extra_Keys.G13); SetExtraKey(Devices.DeviceKeys.G14, ngw_state.Extra_Keys.G14); SetExtraKey(Devices.DeviceKeys.G15, ngw_state.Extra_Keys.G15); SetExtraKey(Devices.DeviceKeys.G16, ngw_state.Extra_Keys.G16); SetExtraKey(Devices.DeviceKeys.G17, ngw_state.Extra_Keys.G17); SetExtraKey(Devices.DeviceKeys.G18, ngw_state.Extra_Keys.G18); SetExtraKey(Devices.DeviceKeys.G19, ngw_state.Extra_Keys.G19); SetExtraKey(Devices.DeviceKeys.G20, ngw_state.Extra_Keys.G20); if (ngw_state.Command.Equals("SetLighting")) { Color newfill = Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start); if (!last_fill_color.Equals(newfill)) { last_fill_color = newfill; for (int i = 0; i < bitmap.Length; i++) { bitmap[i] = (int)(((int)ngw_state.Command_Data.red_start << 16) | ((int)ngw_state.Command_Data.green_start << 8) | ((int)ngw_state.Command_Data.blue_start)); } } } else if (ngw_state.Command.Equals("SetLightingForKeyWithKeyName") || ngw_state.Command.Equals("SetLightingForKeyWithScanCode") || ngw_state.Command.Equals("SetLightingForKeyWithHidCode")) { var bitmap_key = Devices.Logitech.LogitechDevice.ToLogitechBitmap((LedCSharp.keyboardNames)(ngw_state.Command_Data.key)); if (bitmap_key != Devices.Logitech.Logitech_keyboardBitmapKeys.UNKNOWN) { bitmap[(int)bitmap_key / 4] = (int)(((int)ngw_state.Command_Data.red_start << 16) | ((int)ngw_state.Command_Data.green_start << 8) | ((int)ngw_state.Command_Data.blue_start)); } } else if (ngw_state.Command.Equals("FlashSingleKey")) { Devices.DeviceKeys dev_key = Devices.Logitech.LogitechDevice.ToDeviceKey((LedCSharp.keyboardNames)(ngw_state.Command_Data.key)); LogiFlashSingleKey neweffect = new LogiFlashSingleKey(dev_key, Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start), ngw_state.Command_Data.duration, ngw_state.Command_Data.interval ); if (key_effects.ContainsKey(dev_key)) { key_effects[dev_key] = neweffect; } else { key_effects.Add(dev_key, neweffect); } } else if (ngw_state.Command.Equals("PulseSingleKey")) { Devices.DeviceKeys dev_key = Devices.Logitech.LogitechDevice.ToDeviceKey((LedCSharp.keyboardNames)(ngw_state.Command_Data.key)); long duration = ngw_state.Command_Data.interval == 0 ? 0 : ngw_state.Command_Data.duration; LogiPulseSingleKey neweffect = new LogiPulseSingleKey(dev_key, Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start), Color.FromArgb(ngw_state.Command_Data.red_end, ngw_state.Command_Data.green_end, ngw_state.Command_Data.blue_end), duration ); if (key_effects.ContainsKey(dev_key)) { key_effects[dev_key] = neweffect; } else { key_effects.Add(dev_key, neweffect); } } else if (ngw_state.Command.Equals("PulseLighting")) { current_effect = new LogiPulseLighting( Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start), ngw_state.Command_Data.duration, ngw_state.Command_Data.interval ); } else if (ngw_state.Command.Equals("FlashLighting")) { current_effect = new LogiFlashLighting( Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start), ngw_state.Command_Data.duration, ngw_state.Command_Data.interval ); } else if (ngw_state.Command.Equals("StopEffects")) { key_effects.Clear(); current_effect = null; } else if (ngw_state.Command.Equals("SetLightingFromBitmap")) { } //LightFX else if (ngw_state.Command.Equals("LFX_GetNumDevices")) { //Retain previous lighting int fill_color_int = Utils.ColorUtils.GetIntFromColor(last_fill_color); for (int i = 0; i < bitmap.Length; i++) { bitmap[i] = fill_color_int; } foreach (var extra_key in extra_keys.Keys.ToArray()) { extra_keys[extra_key] = last_fill_color; } } else if (ngw_state.Command.Equals("LFX_GetNumLights")) { //Retain previous lighting int fill_color_int = Utils.ColorUtils.GetIntFromColor(last_fill_color); for (int i = 0; i < bitmap.Length; i++) { bitmap[i] = fill_color_int; } foreach (var extra_key in extra_keys.Keys.ToArray()) { extra_keys[extra_key] = last_fill_color; } } else if (ngw_state.Command.Equals("LFX_Light")) { //Retain previous lighting int fill_color_int = Utils.ColorUtils.GetIntFromColor(last_fill_color); for (int i = 0; i < bitmap.Length; i++) { bitmap[i] = fill_color_int; } foreach (var extra_key in extra_keys.Keys.ToArray()) { extra_keys[extra_key] = last_fill_color; } } else if (ngw_state.Command.Equals("LFX_SetLightColor")) { //Retain previous lighting int fill_color_int = Utils.ColorUtils.GetIntFromColor(last_fill_color); for (int i = 0; i < bitmap.Length; i++) { bitmap[i] = fill_color_int; } foreach (var extra_key in extra_keys.Keys.ToArray()) { extra_keys[extra_key] = last_fill_color; } } else if (ngw_state.Command.Equals("LFX_Update")) { Color newfill = Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start); if (!last_fill_color.Equals(newfill)) { last_fill_color = newfill; for (int i = 0; i < bitmap.Length; i++) { bitmap[i] = (int)(((int)ngw_state.Command_Data.red_start << 16) | ((int)ngw_state.Command_Data.green_start << 8) | ((int)ngw_state.Command_Data.blue_start)); } } foreach (var extra_key in extra_keys.Keys.ToArray()) { extra_keys[extra_key] = newfill; } } else if (ngw_state.Command.Equals("LFX_SetLightActionColor") || ngw_state.Command.Equals("LFX_ActionColor")) { Color primary = Color.Transparent; Color secondary = Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start); if (current_effect != null) { primary = current_effect.GetCurrentColor(Utils.Time.GetMillisecondsSinceEpoch() - current_effect.timeStarted); } switch (ngw_state.Command_Data.effect_type) { case "LFX_ACTION_COLOR": current_effect = new LFX_Color(primary); break; case "LFX_ACTION_PULSE": current_effect = new LFX_Pulse(primary, secondary, ngw_state.Command_Data.duration); break; case "LFX_ACTION_MORPH": current_effect = new LFX_Morph(primary, secondary, ngw_state.Command_Data.duration); break; default: current_effect = null; break; } } else if (ngw_state.Command.Equals("LFX_SetLightActionColorEx") || ngw_state.Command.Equals("LFX_ActionColorEx")) { Color primary = Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start); Color secondary = Color.FromArgb(ngw_state.Command_Data.red_end, ngw_state.Command_Data.green_end, ngw_state.Command_Data.blue_end); switch (ngw_state.Command_Data.effect_type) { case "LFX_ACTION_COLOR": current_effect = new LFX_Color(primary); break; case "LFX_ACTION_PULSE": current_effect = new LFX_Pulse(primary, secondary, ngw_state.Command_Data.duration); break; case "LFX_ACTION_MORPH": current_effect = new LFX_Morph(primary, secondary, ngw_state.Command_Data.duration); break; default: current_effect = null; break; } } else if (ngw_state.Command.Equals("LFX_Reset")) { current_effect = null; } //Razer else if (ngw_state.Command.Equals("CreateMouseEffect")) { } else if (ngw_state.Command.Equals("CreateMousepadEffect")) { } else if (ngw_state.Command.Equals("CreateKeyboardEffect")) { Color primary = Color.Red; Color secondary = Color.Blue; if (ngw_state.Command_Data.red_start >= 0 && ngw_state.Command_Data.green_start >= 0 && ngw_state.Command_Data.blue_start >= 0 ) { primary = Color.FromArgb(ngw_state.Command_Data.red_start, ngw_state.Command_Data.green_start, ngw_state.Command_Data.blue_start); } if (ngw_state.Command_Data.red_end >= 0 && ngw_state.Command_Data.green_end >= 0 && ngw_state.Command_Data.blue_end >= 0 ) { secondary = Color.FromArgb(ngw_state.Command_Data.red_end, ngw_state.Command_Data.green_end, ngw_state.Command_Data.blue_end); } switch (ngw_state.Command_Data.effect_type) { case "CHROMA_BREATHING": current_effect = new CHROMA_BREATHING(primary, secondary, ngw_state.Command_Data.effect_config); break; default: current_effect = null; break; } } else { Global.logger.Info("Unknown Wrapper Command: " + ngw_state.Command); } } }
Color GenerateColorFromNeighbor(XY xy , Color[,] pixels ) { List<XY> neigh = getneighbors(xy,pixels,false); float sumR =0 , sumG = 0, sumB = 0; foreach(XY n in neigh ) { sumR += pixels[n.x,n.y].r; sumG += pixels[n.x,n.y].g; sumB += pixels[n.x,n.y].b; } Color res = new Color( sumR / neigh.Count , sumG / neigh.Count , sumB / neigh.Count ); res.r += UnityEngine.Random.Range(-diversity,diversity); res.g += UnityEngine.Random.Range(-diversity,diversity); res.b += UnityEngine.Random.Range(-diversity,diversity); if ( res.Equals(Color.black)) { res.r = res.g = res.b = 0.05f; } return res; }
/// <summary> /// Get new rect after remove blank column /// </summary> /// <param name="bmp"></param> /// <param name="rect"></param> /// <param name="backgroundColor"></param> /// <returns></returns> public static Rectangle GetFixedWidthRect(Bitmap bmp, Rectangle rect, int minWidth, Color backgroundColor) { Rectangle result = new Rectangle(rect.Location, rect.Size); int c, r, offset; bool isCatch = false; // right side offset = 0; for (c = rect.Right - 1; c > rect.Left; c--) { for (r = rect.Top; r <= rect.Bottom - 1; r++) { if (!backgroundColor.Equals(bmp.GetPixel(c, r))) { isCatch = true; break; } } if (isCatch) { break; } offset++; } if (offset > 0) { offset--; } // left side isCatch = false; for (c = rect.Left; c < rect.Right; c++) { for (r = rect.Top; r <= rect.Bottom - 1; r++) { if (!backgroundColor.Equals(bmp.GetPixel(c, r))) { isCatch = true; break; } } if (isCatch) { break; } result.Offset(1, 0); offset++; } // all blank if (result.Left == rect.Right) { return(rect); } // min width check if (rect.Width - offset < minWidth) { int padLeft = (minWidth - (rect.Width - offset)) / 2; result.Offset(-padLeft, 0); result.Size = new Size(minWidth, rect.Height); } else { result.Size = new Size(rect.Width - offset, rect.Height); } return(result); }