Search in sources :

Example 21 with Shader

use of android.graphics.Shader in project android_packages_apps_Gallery2 by LineageOS.

the class ColorValueView method updatePaint.

private void updatePaint() {
    float[] hsv = new float[] { mHSVO[0], mHSVO[1], 0f };
    int color1 = Color.HSVToColor(hsv);
    hsv[2] = 1;
    int color2 = Color.HSVToColor(hsv);
    Shader sg = new LinearGradient(mBorder, mBorder, mBorder, mHeight - mBorder, color1, color2, Shader.TileMode.CLAMP);
    mBarPaint1.setShader(sg);
}
Also used : LinearGradient(android.graphics.LinearGradient) Shader(android.graphics.Shader) Paint(android.graphics.Paint)

Example 22 with Shader

use of android.graphics.Shader in project incubator-weex by apache.

the class WXResourceUtilsTest method testGetShader.

@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);
}
Also used : Shader(android.graphics.Shader) Test(org.junit.Test)

Example 23 with Shader

use of android.graphics.Shader in project incubator-weex by apache.

the class WXComponent method setBackgroundImage.

public void setBackgroundImage(@NonNull String bgImage) {
    if ("".equals(bgImage.trim())) {
        getOrCreateBorder().setImage(null);
    } else {
        Shader shader = WXResourceUtils.getShader(bgImage, mDomObj.getLayoutWidth(), mDomObj.getLayoutHeight());
        getOrCreateBorder().setImage(shader);
    }
}
Also used : Shader(android.graphics.Shader)

Example 24 with Shader

use of android.graphics.Shader in project incubator-weex by apache.

the class BorderDrawable method preparePaint.

private void preparePaint(@BorderWidthStyleColorType int side) {
    float borderWidth = getBorderWidth(side);
    int color = WXViewUtils.multiplyColorAlpha(getBorderColor(side), mAlpha);
    BorderStyle borderStyle = BorderStyle.values()[getBorderStyle(side)];
    Shader shader = borderStyle.getLineShader(borderWidth, color, side);
    mPaint.setShader(shader);
    mPaint.setColor(color);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
}
Also used : Shader(android.graphics.Shader) Paint(android.graphics.Paint)

Example 25 with Shader

use of android.graphics.Shader in project material-hijri-calendarview by eltohamy.

the class DayView method generateCircleDrawable.

private static Drawable generateCircleDrawable(final int color) {
    ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
    drawable.setShaderFactory(new ShapeDrawable.ShaderFactory() {

        @Override
        public Shader resize(int width, int height) {
            return new LinearGradient(0, 0, 0, 0, color, color, Shader.TileMode.REPEAT);
        }
    });
    return drawable;
}
Also used : LinearGradient(android.graphics.LinearGradient) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) Shader(android.graphics.Shader) SuppressLint(android.annotation.SuppressLint)

Aggregations

Shader (android.graphics.Shader)77 Paint (android.graphics.Paint)41 LinearGradient (android.graphics.LinearGradient)38 BitmapShader (android.graphics.BitmapShader)21 Bitmap (android.graphics.Bitmap)17 ShapeDrawable (android.graphics.drawable.ShapeDrawable)15 Matrix (android.graphics.Matrix)13 RectShape (android.graphics.drawable.shapes.RectShape)9 PaintDrawable (android.graphics.drawable.PaintDrawable)8 Point (android.graphics.Point)7 SuppressLint (android.annotation.SuppressLint)6 ColorDrawable (android.graphics.drawable.ColorDrawable)6 Drawable (android.graphics.drawable.Drawable)5 OvalShape (android.graphics.drawable.shapes.OvalShape)5 CallSuper (android.annotation.CallSuper)4 Rect (android.graphics.Rect)4 RectF (android.graphics.RectF)4 ShaderFactory (android.graphics.drawable.ShapeDrawable.ShaderFactory)4 Test (org.junit.Test)4 Canvas (android.graphics.Canvas)3