internal static float GetAlphaFromRGBA(String value) { try { return(WebColors.GetRGBAColor(value)[3]); } catch (Exception) { return(1f); } }
/// <summary>Parses the RGBA color.</summary> /// <param name="colorValue">the color value</param> /// <returns>an RGBA value expressed as an array with four float values</returns> public static float[] ParseRgbaColor(String colorValue) { float[] rgbaColor = WebColors.GetRGBAColor(colorValue); if (rgbaColor == null) { logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.COLOR_NOT_PARSED, colorValue)); rgbaColor = new float[] { 0, 0, 0, 1 }; } return(rgbaColor); }
/// <summary>Parses the RGBA color.</summary> /// <param name="colorValue">the color value</param> /// <returns>an RGBA value expressed as an array with four float values</returns> public static float[] ParseRgbaColor(String colorValue) { float[] rgbaColor = WebColors.GetRGBAColor(colorValue); if (rgbaColor == null) { ILog logger = LogManager.GetLogger(typeof(iText.StyledXmlParser.Css.Util.CssUtils)); logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.COLOR_NOT_PARSED, colorValue)); rgbaColor = new float[] { 0, 0, 0, 1 }; } return(rgbaColor); }
internal static float GetAlphaFromRGBA(String value) { try { return(WebColors.GetRGBAColor(value)[3]); } catch (IndexOutOfRangeException) { return(1f); } catch (NullReferenceException) { return(1f); } }
private string TransformColor(string originalColor) { float[] rgbaColor = WebColors.GetRGBAColor(originalColor); float[] rgbColor = { rgbaColor[0], rgbaColor[1], rgbaColor[2] }; float[] newColorRgb = ColorBlindnessTransforms.SimulateColorBlindness(colorBlindness, rgbColor); float[] newColorRgba = { newColorRgb[0], newColorRgb[1], newColorRgb[2], rgbaColor[3] }; double[] newColorArray = ScaleColorFloatArray(newColorRgba); string newColorString = "rgba(" + (int)newColorArray[0] + "," + (int)newColorArray[1] + "," + (int)newColorArray[2] + "," + newColorArray[3] + ")"; return(newColorString); }
/// <summary>Evaluates the rgba array of the specified stop color</summary> /// <returns> /// the array of 4 floats which contains the rgba value corresponding /// to the specified stop color /// </returns> public virtual float[] GetStopColor() { float[] color = null; String colorValue = GetAttribute(SvgConstants.Tags.STOP_COLOR); if (colorValue != null) { color = WebColors.GetRGBAColor(colorValue); } if (color == null) { color = WebColors.GetRGBAColor("black"); } return(color); }
private string TransformColor(string originalColor) { // Get RGB colors values float[] rgbaColor = WebColors.GetRGBAColor(originalColor); float[] rgbColor = { rgbaColor[0], rgbaColor[1], rgbaColor[2] }; // Change RGB colors values to corresponding colour blindness RGB values float[] newColourRgb = ColorBlindnessTransforms.SimulateColorBlindness(colorBlindness, rgbColor); float[] newColourRgba = { newColourRgb[0], newColourRgb[1], newColourRgb[2], rgbaColor[3] }; // Scale and return changed color values double[] newColorArray = ScaleColorFloatArray(newColourRgba); string newColorString = "rgba(" + (int)newColorArray[0] + "," + (int)newColorArray[1] + "," + (int)newColorArray[2] + "," + newColorArray[3] + ")"; return(newColorString); }
/* (non-Javadoc) * @see com.itextpdf.styledxmlparser.css.validate.ICssDataTypeValidator#isValid(java.lang.String) */ public virtual bool IsValid(String objectString) { float[] rgbaColor = WebColors.GetRGBAColor(objectString); return(rgbaColor != null); }