@Test public void testGetShader() throws Exception { Shader shader = WXResourceUtils.getShader("linear-gradient(to bottom,#a80077,blue)", 100, 100); assertNotNull(shader); shader = WXResourceUtils.getShader("linear-gradient(to bottom,#a80077,rgb(255,255,0))", 100, 100); assertNotNull(shader); shader = WXResourceUtils.getShader("linear-gradient(to bottom,#a80077,rgba(255,255,0,0.5))", 100, 100); assertNotNull(shader); shader = WXResourceUtils.getShader("gradient", 100, 100); assertNull(shader); }
public static Shader getShader(String image, float width, float height) { List<String> valueList = parseGradientValues(image); if (valueList != null && valueList.size() == 3) { float[] points = parseGradientDirection(valueList.get(0), width, height); Shader shader = new LinearGradient(points[0], points[1], points[2], points[3], getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE), Shader.TileMode.REPEAT); return shader; } return null; }
WXResourceUtils { public static Shader getShader(String image, float width, float height) { List<String> valueList = parseGradientValues(image); if (valueList != null && valueList.size() == 3) { float[] points = parseGradientDirection(valueList.get(0), width, height); Shader shader = new LinearGradient(points[0], points[1], points[2], points[3], getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE), Shader.TileMode.REPEAT); return shader; } return null; } }
WXResourceUtils { public static Shader getShader(String image, float width, float height) { List<String> valueList = parseGradientValues(image); if (valueList != null && valueList.size() == 3) { float[] points = parseGradientDirection(valueList.get(0), width, height); Shader shader = new LinearGradient(points[0], points[1], points[2], points[3], getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE), Shader.TileMode.REPEAT); return shader; } return null; }  }
WXResourceUtils { public static Shader getShader(String image, float width, float height) { List<String> valueList = parseGradientValues(image); if (valueList != null && valueList.size() == 3) { float[] points = parseGradientDirection(valueList.get(0), width, height); Shader shader = new LinearGradient(points[0], points[1], points[2], points[3], getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE), Shader.TileMode.REPEAT); return shader; } return null; }  static int getColor(String color); static int getColor(String color, int defaultColor); static Shader getShader(String image, float width, float height); }
WXResourceUtils { public static Shader getShader(String image, float width, float height) { List<String> valueList = parseGradientValues(image); if (valueList != null && valueList.size() == 3) { float[] points = parseGradientDirection(valueList.get(0), width, height); Shader shader = new LinearGradient(points[0], points[1], points[2], points[3], getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE), Shader.TileMode.REPEAT); return shader; } return null; }  static int getColor(String color); static int getColor(String color, int defaultColor); static Shader getShader(String image, float width, float height);  }