protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { CorsairColor color; int ID; if (renderTarget.LedId == CorsairLedId.F12) { ID = (int)CorsairLedId.F12 - 61; } else { ID = (int)renderTarget.LedId - 1; } if (ID < BarProgress) { color = Color; } else if (ID == BarProgress) { float factor = (ManaP - (BarProgress - 1) * 10) / 10f; color = new CorsairColor(255, (byte)(Color.R * factor), (byte)(Color.G * factor), (byte)(Color.B * factor)); } else { color = new CorsairColor(255, 0, 0, 0); } return(color); }
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { float keyWidth = renderTarget.Rectangle.Width; int widthPixels = Math.Max(1, (int)(KeyWidthProportion * keyWidth)); int r = 0; int g = 0; int b = 0; int counter = 0; int widthOffset = Settings.FlipMode.HasFlag(FlipMode.Horizontal) ? (int)((SourceWidth - OffsetRight) - (KeyWidthProportion * (renderTarget.Point.X + (keyWidth / 2f)))) : (int)(OffsetLeft + (KeyWidthProportion * (renderTarget.Point.X - (keyWidth / 2f)))); int heightOffset = SourceHeight - OffsetBottom - EffectiveSourceHeight; // DarthAffe 05.11.2016: Vertical flipping doesn't mather in Extend-Mode // DarthAffe 06.11.2016: Validate offsets - rounding errors might cause problems (heightOffset is safe calculated -> no need to validate) widthOffset = Math.Max(0, Math.Min(SourceWidth - widthPixels, widthOffset)); for (int y = 0; y < EffectiveSourceHeight; y += Increment) { for (int x = 0; x < widthPixels; x += Increment) { int offset = ((((heightOffset + y) * SourceWidth) + widthOffset + x) * 4); b += ScreenPixelData[offset]; g += ScreenPixelData[offset + 1]; r += ScreenPixelData[offset + 2]; counter++; } } return(new CorsairColor((byte)(r / counter), (byte)(g / counter), (byte)(b / counter))); }
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color) { int barSampleIndex = Math.Min(_visualizationProvider.VisualizationData.Length, (int)Math.Floor(_visualizationProvider.VisualizationData.Length * (renderTarget.Point.X / (rectangle.Location.X + rectangle.Size.Width)))); double curBarHeight = 1.0 - Math.Max(0f, _visualizationProvider.VisualizationData[barSampleIndex]); double verticalPos = (renderTarget.Point.Y / rectangle.Size.Height); return(curBarHeight > verticalPos?color.SetA(0) : color); }
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { if (renderTarget.Led == _syncLed) { return(Color.Transparent); } return(_syncLed?.Color ?? Color.Transparent); }
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { if (renderTarget.LedId == Led) { Debug.WriteLine(Led); Debug.WriteLine(new PointF(renderTarget.Point.X / rectangle.Width, renderTarget.Point.Y / rectangle.Height)); } return(base.GetColorAtPoint(rectangle, renderTarget)); }
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { if ((KeyColors != null) && LedMapping.TryGetValue(renderTarget.Led.Id, out DeviceKeys key) && KeyColors.TryGetValue(key, out System.Drawing.Color color)) { return(new Color(color.A, color.R, color.G, color.B)); } return(Color.Transparent); }
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color) { var point = renderTarget.Led.AbsoluteLedRectangle.Center; if (_bitmap != null && _bitmap.Width - 1 >= point.X && _bitmap.Height - 1 >= point.Y) { var pixel = _bitmap.GetPixel((int)point.X, (int)point.Y); return(new Color(pixel.A, pixel.R, pixel.G, pixel.B)); } return(new Color(0, 0, 0)); }
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { if (KeyColors != null && LedMapping.TryGetValue(renderTarget.Led.Id, out DeviceKeys key) && KeyColors.TryGetValue(key, out System.Drawing.Color color)) { var c = ColorUtils.CorrectWithAlpha(color); return(new Color(c.A, c.R, c.G, c.B)); } return(Color.Transparent); }
// If you're able to include your logic which key to color here this might get easier than working with the dictionary and stuff. protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { var ledId = renderTarget.LedId; Color color; if (_keyMap.TryGetValue(ledId, out color)) { return(color); } return(CorsairColor.Transparent); }
/// <inheritdoc /> /// <summary> /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. /// </summary> /// <param name="rectangle">The rectangle in which the brush should be drawn.</param> /// <param name="renderTarget">The target (key/point) from which the color should be taken.</param> /// <returns>The color at the specified point.</returns> protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { if (Gradient == null) { return(Color.Transparent); } Point startPoint = new Point(StartPoint.X * rectangle.Size.Width, StartPoint.Y * rectangle.Size.Height); Point endPoint = new Point(EndPoint.X * rectangle.Size.Width, EndPoint.Y * rectangle.Size.Height); double offset = GradientHelper.CalculateLinearGradientOffset(startPoint, endPoint, renderTarget.Point); return(Gradient.GetColor(offset)); }
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color) { if (Bitmap == null) { return(new Color(0, 0, 0)); } var x = renderTarget.Led.AbsoluteLedRectangle.Center.X * _scale; var y = renderTarget.Led.AbsoluteLedRectangle.Center.Y * _scale; var pixel = Bitmap.GetPixel(RoundToInt(x), RoundToInt(y)); return(new Color(pixel.Alpha, pixel.Red, pixel.Green, pixel.Blue)); }
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { if (_soundDataProcessor?.BarValues == null) { return(CorsairColor.Transparent); } // This logic is also stolen from AterialDawn int barSampleIndex = (int)Math.Floor(_soundDataProcessor.BarValues.Length * (renderTarget.Point.X / (rectangle.X + rectangle.Width))); // Calculate bar sampling index float curBarHeight = 1f - Utility.Clamp(_soundDataProcessor.BarValues[barSampleIndex], 0f, 1f); // Invert this value since the keyboard is laid out with topleft being point 0,0 float verticalPos = (renderTarget.Point.Y / rectangle.Height); // If the barHeight is lower than the vertical pos currently calculated return the brush value. Otherwise do nothing by returning transparent. return(curBarHeight <= verticalPos?base.GetColorAtPoint(rectangle, renderTarget) : CorsairColor.Transparent); }
/// <inheritdoc /> protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { double centerX = rectangle.Size.Width * Center.X; double centerY = rectangle.Size.Height * Center.Y; double angle = Math.Atan2(renderTarget.Point.Y - centerY, renderTarget.Point.X - centerX) - Origin; if (angle < 0) { angle += Math.PI * 2; } double offset = angle / (Math.PI * 2); return(Gradient.GetColor(offset)); }
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { //if (renderTarget.Led == _syncLed) // return Color.Transparent; if (_syncLed == null) { return(Color.Transparent); } Color average = _syncLed[0]; for (int i = 1; i < _syncLed.Count; i++) { average = ColorUtils.colorMixer(average, _syncLed[i]); } return(average); }
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color) { double offset = CalculateOffset(rectangle, renderTarget); if (Direction == LevelBarDirection.Horizontal) { if (offset < 0) { offset = (-offset * 2); if (offset >= _visualizationProvider.VisualizationData[0]) { return(color.SetA(0)); } else { return(Gradient.GetColor(offset)); } } else { offset *= 2; if (offset >= _visualizationProvider.VisualizationData[1]) { return(color.SetA(0)); } else { return(Gradient.GetColor(offset)); } } } else { if (offset >= _visualizationProvider.VisualizationData[DataIndex]) { return(color.SetA(0)); } } return(color); }
/// <inheritdoc /> protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { if (Gradient == null) { return(Color.Transparent); } Point centerPoint = new Point(rectangle.Location.X + (rectangle.Size.Width * Center.X), rectangle.Location.Y + (rectangle.Size.Height * Center.Y)); // Calculate the distance to the farthest point from the center as reference (this has to be a corner) // ReSharper disable once RedundantCast - never trust this ... double refDistance = Math.Max(Math.Max(Math.Max(GradientHelper.CalculateDistance(rectangle.Location, centerPoint), GradientHelper.CalculateDistance(new Point(rectangle.Location.X + rectangle.Size.Width, rectangle.Location.Y), centerPoint)), GradientHelper.CalculateDistance(new Point(rectangle.Location.X, rectangle.Location.Y + rectangle.Size.Height), centerPoint)), GradientHelper.CalculateDistance(new Point(rectangle.Location.X + rectangle.Size.Width, rectangle.Location.Y + rectangle.Size.Height), centerPoint)); double distance = GradientHelper.CalculateDistance(renderTarget.Point, centerPoint); double offset = distance / refDistance; return(Gradient.GetColor(offset)); }
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { CorsairColor color; if (Damage >= DamageMax) { color = Color; } else if (IsCrit) { color = new CorsairColor(193, 5, 255); } else { float factor = (float)Math.Ceiling((float)(Damage / DamageMax) * 10) / 10f; color = new CorsairColor(255, (byte)(Color.R * factor), (byte)(Color.G * factor), (byte)(Color.B * factor)); } return(color); }
private double CalculateOffset(Rectangle rectangle, BrushRenderTarget renderTarget) { switch (Direction) { case LevelBarDirection.Left: return((rectangle.Size.Width - renderTarget.Rectangle.Center.X) / rectangle.Size.Width); case LevelBarDirection.Right: return(renderTarget.Rectangle.Center.X / rectangle.Size.Width); case LevelBarDirection.Top: return((rectangle.Size.Height - renderTarget.Rectangle.Center.Y) / rectangle.Size.Height); case LevelBarDirection.Bottom: return(renderTarget.Rectangle.Center.Y / rectangle.Size.Height); case LevelBarDirection.Horizontal: return((renderTarget.Rectangle.Center.X / rectangle.Size.Width) - 0.5); default: return(-1); } }
/// <inheritdoc /> public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color) => color.SetA(_currentValue);
/// <inheritdoc /> public void ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, ref Color color) => color.APercent = _currentValue;
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color) => color.SetA(color.A * _visualizationProvider.VisualizationData[0]);
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) => throw new NotImplementedException();
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget) { return(_syncLed.Color); }