/// <summary> /// Get color by parsing given RGBA value color string (RGBA(255,180,90,180)) /// </summary> /// <returns>true - valid color, false - otherwise</returns> private static bool GetColorByRgba(string str, int idx, int length, out RColor color) { int r = -1; int g = -1; int b = -1; int a = -1; if (length > 13) { int s = idx + 5; r = ParseIntAtIndex(str, ref s); if (s < idx + length) { g = ParseIntAtIndex(str, ref s); } if (s < idx + length) { b = ParseIntAtIndex(str, ref s); } if (s < idx + length) { a = ParseIntAtIndex(str, ref s); } } if (r > -1 && g > -1 && b > -1 && a > -1) { color = RColor.FromArgb(a, r, g, b); return(true); } color = RColor.Empty; return(false); }
/// <summary> /// Get color by parsing given RGB value color string (RGB(255,180,90)) /// </summary> /// <returns>true - valid color, false - otherwise</returns> private static bool GetColorByRgb(string str, int idx, int length, out RColor color) { var r = -1; var g = -1; var b = -1; if (length > 10) { var s = idx + 4; r = ParseIntAtIndex(str, ref s); if (s < idx + length) { g = ParseIntAtIndex(str, ref s); } if (s < idx + length) { b = ParseIntAtIndex(str, ref s); } } if (r > -1 && g > -1 && b > -1) { color = RColor.FromArgb(r, g, b); return(true); } color = RColor.Empty; return(false); }
/// <summary> /// Get color by parsing given hex value color string (#A28B34). /// </summary> /// <returns>true - valid color, false - otherwise</returns> private static bool GetColorByHex(string str, int idx, int length, out RColor color) { int r = -1; int g = -1; int b = -1; if (length == 7) { r = ParseHexInt(str, idx + 1, 2); g = ParseHexInt(str, idx + 3, 2); b = ParseHexInt(str, idx + 5, 2); } else if (length == 4) { r = ParseHexInt(str, idx + 1, 1); r = r * 16 + r; g = ParseHexInt(str, idx + 2, 1); g = g * 16 + g; b = ParseHexInt(str, idx + 3, 1); b = b * 16 + b; } if (r > -1 && g > -1 && b > -1) { color = RColor.FromArgb(r, g, b); return(true); } color = RColor.Empty; return(false); }
/// <summary> /// Draw video title on top of the iframe if found. /// </summary> private void DrawTitle(RGraphics g, RRect rect) { if (_videoTitle != null && _imageWord.Width > 40 && _imageWord.Height > 40) { var font = HtmlContainer.Adapter.GetFont("Arial", 9f, RFontStyle.Regular); g.DrawRectangle(g.GetSolidBrush(RColor.FromArgb(160, 0, 0, 0)), rect.Left, rect.Top, rect.Width, ActualFont.Height + 7); var titleRect = new RRect(rect.Left + 3, rect.Top + 3, rect.Width - 6, rect.Height - 6); g.DrawString(_videoTitle, font, RColor.WhiteSmoke, titleRect.Location, RSize.Empty, false); } }
/// <summary> /// Draw play over the iframe if we found link url. /// </summary> private void DrawPlay(RGraphics g, RRect rect) { if (_isVideo && _imageWord.Width > 70 && _imageWord.Height > 50) { var prevMode = g.SetAntiAliasSmoothingMode(); var size = new RSize(60, 40); var left = rect.Left + (rect.Width - size.Width) / 2; var top = rect.Top + (rect.Height - size.Height) / 2; g.DrawRectangle(g.GetSolidBrush(RColor.FromArgb(160, 0, 0, 0)), left, top, size.Width, size.Height); RPoint[] points = { new RPoint(left + size.Width / 3f + 1, top + 3 * size.Height / 4f), new RPoint(left + size.Width / 3f + 1, top + size.Height / 4f), new RPoint(left + 2 * size.Width / 3f + 1, top + size.Height / 2f) }; g.DrawPolygon(g.GetSolidBrush(RColor.White), points); g.ReturnPreviousSmoothingMode(prevMode); } }
/// <summary> /// Makes the specified color darker for inset/outset borders. /// </summary> private static RColor Darken(RColor c) { return(RColor.FromArgb(c.R / 2, c.G / 2, c.B / 2)); }
/// <summary> /// Convert from WinForms color to core color. /// </summary> public static RColor Convert(SKColor c) { return(RColor.FromArgb(c.Alpha, c.Red, c.Green, c.Blue)); }
/// <summary> /// Convert from WPF color to core color. /// </summary> public static RColor Convert(Color c) { return(RColor.FromArgb(c.A, c.R, c.G, c.B)); }
public static RColor ToRColor(this SDL.SDL_Color color) { return(RColor.FromArgb(color.a, color.r, color.g, color.b)); }
protected override RColor GetColorInt(string colorName) { var color = Color.FromName(colorName); return(RColor.FromArgb(color.A, color.R, color.G, color.B)); }
/// <summary> /// Convert from WinForms color to core color. /// </summary> public static RColor Convert(XColor c) { var gc = c.ToGdiColor(); return(RColor.FromArgb(gc.A, gc.R, gc.G, gc.B)); }
/// <summary> /// Convert from Eto color to core color. /// </summary> public static RColor Convert(Color c) { return(RColor.FromArgb(c.Ab, c.Rb, c.Gb, c.Bb)); }