微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.graphics.Shader的实例源码

项目:Oblique    文件ObliqueView.java   
private void setupBitmap(ImageView imageView,float width,float height) {
    Drawable drawable = imageView.getDrawable();
    if (drawable == null) {
        return;
    }
    try {
        bitmap = (drawable instanceof BitmapDrawable) ?
                ((BitmapDrawable) drawable).getBitmap() :
                Bitmap.createBitmap(drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight(),Bitmap.Config.ARGB_8888);
    } catch (Exception e) {
        e.printstacktrace();
    }
    if (bitmap == null) {
        imageView.invalidate();
        return;
    }
    paint = new Paint(ANTI_ALIAS_FLAG);
    bitmapShader = new BitmapShader(bitmap,Shader.TileMode.CLAMP,Shader.TileMode.CLAMP);
    paint.setShader(bitmapShader);
    if (imageView.getScaleType() != ImageView.ScaleType.CENTER_CROP && imageView.getScaleType() != ImageView.ScaleType.FIT_XY) {
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    }
    bitmapShader.setLocalMatrix(setUpScaleType(bitmap,imageView,width,height));
    imageView.invalidate();
}
项目:VirtualHook    文件ShimmerViewHelper.java   
private void resetLinearGradient() {

        // our gradient is a simple linear gradient from textColor to reflectionColor. its axis is at the center
        // when it's outside of the view,the outer color (textColor) will be repeated (Shader.TileMode.CLAMP)
        // initially,the linear gradient is positioned on the left side of the view
        linearGradient = new LinearGradient(-view.getWidth(),new int[]{
                        primaryColor,reflectionColor,primaryColor,},new float[]{
                        0,0.5f,1
                },Shader.TileMode.CLAMP
        );

        paint.setShader(linearGradient);
    }
项目:simpledialogFragments    文件ColorWheelView.java   
protected void updateColorDependant(boolean hsvChanged,boolean hueChanged){
    if (hueChanged) {
        Shader base = new LinearGradient(A.x,A.y,(B.x + C.x) / 2,(B.y + C.y) / 2,Color.HSVToColor(new float[]{mColor.hue(),1,1}),Color.BLACK,Shader.TileMode.CLAMP);
        Shader light = new LinearGradient((A.x + C.x) / 2,(A.y + C.y) / 2,B.x,B.y,Color.WHITE,Shader.TileMode.CLAMP);
        Shader both = new ComposeShader(base,light,PorterDuff.Mode.ADD);
        paint.setShader(both);
    }
    if (hsvChanged) {
        dotPaint.setColor(mColor.inverted().rgb());
        dot = new PointF(
                C.x + (B.x - C.x + (A.x - B.x) * mColor.sat()) * mColor.val(),C.y + (B.y - C.y + (A.y - B.y) * mColor.sat()) * mColor.val());
    }
}
项目:spline    文件SaturationValueDrawable.java   
@Override
public void draw(Canvas canvas) {
    Rect b = getBounds();
    int height = b.height();
    int width = b.width();

    Paint valuePaint = new Paint();
    valuePaint.setShader(
            new LinearGradient(0,mInset,height - mInset,Shader.TileMode.CLAMP)
    );

    float hsv[] = {mHue,1.0f,1.0f};
    int pureHue = Color.HSVToColor(hsv);
    Paint saturationPaint = new Paint();
    saturationPaint.setShader(
            new LinearGradient(mInset,width - mInset,pureHue,Shader.TileMode.CLAMP)
    );
    saturationPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));

    canvas.drawRect(b,valuePaint);
    canvas.drawRect(b,saturationPaint);
}
项目:BubbleView    文件BubbleDrawable.java   
public BubbleDrawable(Builder builder) {
    triangleWidth = builder.triangleWidth;
    triangleHeight = builder.triangleHeight;
    offset = builder.offset;
    radius = builder.radius;
    orientation = builder.orientation;
    bitmap = builder.bitmap;
    borderWidth = builder.borderWidth;
    centerarrow = builder.centerarrow;
    shadowRadius = builder.shadowRadius;
    shadowColor = builder.shadowColor;

    borderPaint.setStyle(Paint.Style.stroke);
    borderPaint.setstrokeCap(Paint.Cap.ROUND);
    borderPaint.setColor(builder.borderColor);

    leftTopRadiusRect = new RectF();
    rightBottomradiusRect = new RectF();
    leftBottomradiusRect = new RectF();
    rightTopRadiusRect = new RectF();

    bitmapShader = new BitmapShader(bitmap,Shader.TileMode.CLAMP);
    bitmapPaint.setShader(bitmapShader);
}
项目:xlight_android_native    文件SVBar.java   
/**
 * Set the bar color. <br>
 * <br>
 * Its discouraged to use this method.
 * 
 * @param color
 */
public void setColor(int color) {
    int x1,y1;
    if(mOrientation) {
        x1 = (mBarLength + mBarPointerHaloRadius);
        y1 = mBarThickness;
    }        else {
        x1 = mBarThickness;
        y1 = (mBarLength + mBarPointerHaloRadius);
    }

    Color.colorToHSV(color,mHSVColor);
    shader = new LinearGradient(mBarPointerHaloRadius,x1,y1,new int[] {Color.WHITE,color,Color.BLACK},null,Shader.TileMode.CLAMP);
    mBarPaint.setShader(shader);
    calculateColor(mBarPointerPosition);
    mBarPointerPaint.setColor(mColor);
    if (mPicker != null) {
        mPicker.setNewCenterColor(mColor);
        if(mPicker.hasOpacityBar())
            mPicker.changeOpacityBarColor(mColor);
    }
    invalidate();
}
项目:Picasso-transformations    文件RoundedCornersTransformation.java   
@Override public Bitmap transform(Bitmap source) {

    int width = source.getWidth();
    int height = source.getHeight();

    Bitmap bitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(new BitmapShader(source,Shader.TileMode.CLAMP));
    drawRoundRect(canvas,paint,height);
    source.recycle();

    return bitmap;
  }
项目:OpenEyesReading-android    文件CircleImageView.java   
private void setupView() {
    if (!mReady) {
        mSetupPending = true;
        return;
    }
    if (mBitmap == null) return;
    mBitmapShader = new BitmapShader(mBitmap,Shader.TileMode.CLAMP);
    mBitmapPaint.setAntiAlias(true);
    mBitmapPaint.setShader(mBitmapShader);
    mBorderPaint.setStyle(Paint.Style.stroke);
    mBorderPaint.setAntiAlias(true);
    mBitmapHeight = mBitmap.getHeight();
    mBitmapWidth = mBitmap.getWidth();
    mBorderRect.set(0,getWidth(),getHeight());
    mDrawableRect.set(mBorderRect);
    mDrawableRadius = Math.min(mDrawableRect.height() / 2,mDrawableRect.width() / 2);
    updateShaderMatrix();
    invalidate();
}
项目:FriskyImage    文件FriskyShimmerViewHelper.java   
private void resetLinearGradient() {

        // our gradient is a simple linear gradient from textColor to reflectionColor. its axis is at the center
        // when it's outside of the view,Shader.TileMode.CLAMP
        );

        paint.setShader(linearGradient);
    }
项目:ShimmerLayout    文件ShimmerLayout.java   
private Bitmap getSourceMaskBitmap() {
    if (sourceMaskBitmap != null) {
        return sourceMaskBitmap;
    }

    int width = maskRect.width();
    int height = getHeight();

    final int edgeColor = reduceColorAlphaValuetoZero(shimmerColor);
    LinearGradient gradient = new LinearGradient(
            -maskRect.left,width + maskRect.left,new int[]{edgeColor,shimmerColor,edgeColor},getGradientColordistribution(),Shader.TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setShader(gradient);

    sourceMaskBitmap = createBitmap(width,height);
    Canvas canvas = new Canvas(sourceMaskBitmap);
    canvas.rotate(shimmerAngle,width / 2,height / 2);
    canvas.drawRect(-maskRect.left,maskRect.top,maskRect.bottom,paint);

    return sourceMaskBitmap;
}
项目:microMathematics    文件SVBar.java   
/**
 * Set the bar color. <br>
 * <br>
 * Its discouraged to use this method.
 * 
 * @param color
 */
public void setColor(int color) {
    int x1,y1;
    if (mOrientation) {
        x1 = (mBarLength + mBarPointerHaloRadius);
        y1 = mBarThickness;
    } else {
        x1 = mBarThickness;
        y1 = (mBarLength + mBarPointerHaloRadius);
    }

    Color.colorToHSV(color,new int[] { Color.WHITE,Color.BLACK },Shader.TileMode.CLAMP);
    mBarPaint.setShader(shader);
    calculateColor(mBarPointerPosition);
    mBarPointerPaint.setColor(mColor);
    if (mPicker != null) {
        mPicker.setNewCenterColor(mColor);
        if (mPicker.hasOpacityBar())
            mPicker.changeOpacityBarColor(mColor);
    }
    invalidate();
}
项目:app_secompufscar    文件Pessoa.java   
public Bitmap getFotoBitmap(Context context) {

        Bitmap image;

        if (this.foto != null) {
            image = BitmapFactory.decodeByteArray(this.foto,this.foto.length);
        } else {
            image = BitmapFactory.decodeResource(context.getResources(),R.drawable.pessoa_foto_default);
        }

        Bitmap imageRounded = Bitmap.createBitmap(image.getWidth(),image.getHeight(),image.getConfig());
        Canvas canvas = new Canvas(imageRounded);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setShader(new BitmapShader(image,Shader.TileMode.CLAMP));
        canvas.drawRoundRect((new RectF(0,image.getWidth(),image.getHeight())),image.getWidth() / 2,paint);// Round Image Corner 100 100 100 100

        return imageRounded;
    }
项目:HoldingButton    文件HoldingDrawable.java   
public void setCancelIcon(Bitmap bitmap) {
    if (bitmap != null) {
        mCancelIconWidth = bitmap.getWidth();
        mCancelIconHeight = bitmap.getHeight();
        mCancelIconShader = new BitmapShader(bitmap,Shader.TileMode.CLAMP);
        mCancelIconShader.setLocalMatrix(mCancelIconMatrix);
        mCancelIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mCancelIconPaint.setShader(mCancelIconShader);
        mCancelIconPaint.setColorFilter(new PorterDuffColorFilter(Color.WHITE,PorterDuff.Mode.SRC_IN));

        invalidateSelf();
    } else {
        mCancelIconWidth = 0;
        mCancelIconHeight = 0;
        mCancelIconMatrix = null;
        mCancelIconPaint = null;
    }
}
项目:RLibrary    文件ShimmerViewHelper.java   
private void resetLinearGradient() {

        // our gradient is a simple linear gradient from textColor to reflectionColor. its axis is at the center
        // when it's outside of the view,Shader.TileMode.CLAMP
        );

        paint.setShader(linearGradient);
    }
项目:app_secompufscar    文件Instagram.java   
public static Bitmap getimageRound(byte[] imageByte) {

        Bitmap image;

        image = BitmapFactory.decodeByteArray(imageByte,imageByte.length);

        //Todo: Verificar se o formato da imagem está correto;
        Bitmap imageRounded = Bitmap.createBitmap(image.getWidth(),paint);// Round Image Corner 100 100 100 100

        return imageRounded;
    }
项目:DMAudioStreamer    文件CircleImageView.java   
private void updateShader() {
    if (image == null)
        return;

    // Crop Center Image
    image = cropBitmap(image);

    // Create Shader
    BitmapShader shader = new BitmapShader(image,Shader.TileMode.CLAMP);

    // Center Image in Shader
    Matrix matrix = new Matrix();
    matrix.setScale((float) canvasSize / (float) image.getWidth(),(float) canvasSize / (float) image.getHeight());
    shader.setLocalMatrix(matrix);

    // Set Shader in Paint
    paint.setShader(shader);
}
项目:spinify_android    文件TouchImageView.java   
@Override
protected void onDraw(Canvas canvas) {
    onDrawReady = true;
    imageRenderedAtLeastOnce = true;
    if (delayedZoomVariables != null) {
        setZoom(delayedZoomVariables.scale,delayedZoomVariables.focusX,delayedZoomVariables.focusY,delayedZoomVariables.scaleType);
        delayedZoomVariables = null;
    }
    super.onDraw(canvas);
    if (!zooming) {
        buildDrawingCache();
    } else {

        bitmap = getDrawingCache();
        shader = new BitmapShader(bitmap,Shader.TileMode.CLAMP);

        paint = new Paint();
        paint.setShader(shader);
        eMatrix.reset();
        eMatrix.postScale(2f,2f,zoomPos.x,zoomPos.y);
        paint.getShader().setLocalMatrix(eMatrix);
        canvas.drawCircle(zoomPos.x,zoomPos.y,sizeOfMagnifier,paint);
    }
}
项目:android-project-gallery    文件RoundedDrawable.java   
public RoundedDrawable(Bitmap bitmap)
{

    mBitmapWidth = bitmap.getWidth();
    mBitmapHeight = bitmap.getHeight();
    mBitmapRect.set(0,mBitmapWidth,mBitmapHeight);

    mBitmapShader = new BitmapShader(bitmap,Shader.TileMode.CLAMP);
    mBitmapShader.setLocalMatrix(mShaderMatrix);

    mBitmapPaint = new Paint();
    mBitmapPaint.setStyle(Paint.Style.FILL);
    mBitmapPaint.setAntiAlias(true);
    mBitmapPaint.setShader(mBitmapShader);

    mBorderPaint = new Paint();
    mBorderPaint.setStyle(Paint.Style.stroke);
    mBorderPaint.setAntiAlias(true);
    mBorderPaint.setColor(mBorderColor.getColorForState(getState(),DEFAULT_BORDER_COLOR));
    mBorderPaint.setstrokeWidth(mBorderWidth);
}
项目:SnakeViewMaker    文件RoundTransformation.java   
@Override
protected Bitmap transform(BitmapPool pool,Bitmap toTransform,int outWidth,int outHeight) {
    if (null == toTransform)
        return null;

    // outWidth is the width of the target ImageView,and the same to outHeight
    // all the ori bitmaps loaded may have different size,in order to the clipped
    // the bitmaps have the same size and shape,we use the target ImageView's size
    // to create bitmaps
    updateDrawBound(toTransform.getWidth(),toTransform.getHeight(),outWidth,outHeight);

    Bitmap bitmap = pool.get(drawWidth,drawHeight,Bitmap.Config.ARGB_8888);
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(drawWidth,Bitmap.Config.ARGB_8888);
    }
    bitmap.setHasAlpha(true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(new BitmapShader(toTransform,paint);
    return bitmap;
}
项目:HeroVideo-master    文件CircleImageView.java   
private void setup()
{

    if (!mReady)
    {
        mSetupPending = true;
        return;
    }

    if (mBitmap == null)
    {
        return;
    }

    mBitmapShader = new BitmapShader(mBitmap,Shader.TileMode.CLAMP);

    mBitmapPaint.setAntiAlias(true);
    mBitmapPaint.setShader(mBitmapShader);

    mBorderPaint.setStyle(Paint.Style.stroke);
    mBorderPaint.setAntiAlias(true);
    mBorderPaint.setColor(mBorderColor);
    mBorderPaint.setstrokeWidth(mBorderWidth);

    mBitmapHeight = mBitmap.getHeight();
    mBitmapWidth = mBitmap.getWidth();

    mBorderRect.set(0,getHeight());
    mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2,(mBorderRect.width() - mBorderWidth) / 2);

    mDrawableRect.set(mBorderRect);
    if (!mBorderOverlay)
    {
        mDrawableRect.inset(mBorderWidth,mBorderWidth);
    }
    mDrawableRadius = Math.min(mDrawableRect.height() / 2,mDrawableRect.width() / 2);

    updateShaderMatrix();
    invalidate();
}
项目:Building-Android-UIs-with-custom-views    文件OwnCustomView.java   
@Override
protected void onDraw(Canvas canvas) {
    if (firstDraw) {
        LinearGradient lg = new LinearGradient(0,getHeight(),colorArray,Shader.TileMode.CLAMP);

        backgroundPaint.setShader(lg);
        firstDraw = false;
    }

    canvas.drawRect(0,backgroundPaint);
    super.onDraw(canvas);
}
项目:Mire    文件NoiseEffect.java   
public NoiseEffect(Bitmap bitmap,int grainFPS,float scale) {
    super(bitmap,0);
    shader = new BitmapShader(bitmap,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT);
    matrix = new Matrix();

    shader.setLocalMatrix(matrix);
    paint.setShader(shader);
    paint.setAlpha(144);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN));
    lastGrainOffset = System.currentTimeMillis();
    this.grainFPS = grainFPS;
    this.scale=scale;
}
项目:cwac-crossport    文件CircularBorderDrawable.java   
/**
 * Creates a vertical {@link LinearGradient}
 * @return
 */
private Shader createGradientShader() {
  final Rect rect = mRect;
  copyBounds(rect);

  final float borderRatio = mBorderWidth / rect.height();

  final int[] colors = new int[6];
  colors[0] = ColorUtils.compositeColors(mTopOuterstrokeColor,mCurrentBorderTintColor);
  colors[1] = ColorUtils.compositeColors(mTopInnerstrokeColor,mCurrentBorderTintColor);
      colors[2] = ColorUtils.compositeColors(
          ColorUtils.setAlphaComponent(mTopInnerstrokeColor,0),mCurrentBorderTintColor);
      colors[3] = ColorUtils.compositeColors(
          ColorUtils.setAlphaComponent(mBottomInnerstrokeColor,mCurrentBorderTintColor);
  colors[4] = ColorUtils.compositeColors(mBottomInnerstrokeColor,mCurrentBorderTintColor);
  colors[5] = ColorUtils.compositeColors(mBottomOuterstrokeColor,mCurrentBorderTintColor);

  final float[] positions = new float[6];
  positions[0] = 0f;
  positions[1] = borderRatio;
  positions[2] = 0.5f;
  positions[3] = 0.5f;
  positions[4] = 1f - borderRatio;
  positions[5] = 1f;

  return new LinearGradient(
              0,rect.top,rect.bottom,colors,positions,Shader.TileMode.CLAMP);
}
项目:GitHub    文件CircleProgressBar.java   
public ovalShadow(int shadowRadius,int circleDiameter) {
    super();
    mShadowPaint = new Paint();
    mShadowRadius = shadowRadius;
    mCircleDiameter = circleDiameter;
    mRadialGradient = new RadialGradient(mCircleDiameter / 2,mCircleDiameter / 2,mShadowRadius,new int[]{
            FILL_SHADOW_COLOR,Color.TRANSPARENT
    },Shader.TileMode.CLAMP);
    mShadowPaint.setShader(mRadialGradient);
}
项目:LJFramework    文件ImageUtils.java   
/**
 * 添加倒影
 *
 * @param src 源图片的
 * @param reflectionHeight 倒影高度
 * @param recycle 是否回收
 * @return 带倒影图片
 */
public static Bitmap addReflection(Bitmap src,int reflectionHeight,boolean recycle) {
    if (isEmptyBitmap(src)) {
        return null;
    }
    // 原图与倒影之间的间距
    final int REFLECTION_GAP = 0;
    int srcWidth = src.getWidth();
    int srcHeight = src.getHeight();
    Matrix matrix = new Matrix();
    matrix.preScale(1,-1);
    Bitmap reflectionBitmap = Bitmap.createBitmap(src,srcHeight -
            reflectionHeight,srcWidth,reflectionHeight,matrix,false);
    Bitmap ret = Bitmap.createBitmap(srcWidth,srcHeight + reflectionHeight,src.getConfig());
    Canvas canvas = new Canvas(ret);
    canvas.drawBitmap(src,null);
    canvas.drawBitmap(reflectionBitmap,srcHeight + REFLECTION_GAP,null);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    LinearGradient shader = new LinearGradient(0,srcHeight,ret.getHeight() +
                    REFLECTION_GAP,0x70FFFFFF,0x00FFFFFF,Shader.TileMode.MIRROR);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.DST_IN));
    canvas.drawRect(0,ret.getHeight(),paint);
    if (!reflectionBitmap.isRecycled()) {
        reflectionBitmap.recycle();
    }
    if (recycle && !src.isRecycled()) {
        src.recycle();
    }
    return ret;
}
项目:ShortcutMenu    文件CircleDrawable.java   
public CircleDrawable(Bitmap bitmap,int margin) {
    this.margin = margin;
    this.oBitmap = bitmap;
    bitmapShader = new BitmapShader(bitmap,Shader.TileMode.CLAMP);
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(bitmapShader);
}
项目:GitHub    文件TransformationUtils.java   
/**
 * Creates a bitmap from a source bitmap and rounds the corners.
 *
 * @param inBitmap the source bitmap to use as a basis for the created bitmap.
 * @param width the width of the generated bitmap.
 * @param height the height of the generated bitmap.
 * @param roundingRadius the corner radius to be applied (in device-specific pixels).
 * @return a {@link Bitmap} similar to inBitmap but with rounded corners.
 * @throws IllegalArgumentException if roundingRadius,width or height is 0 or less.
 */
public static Bitmap roundedCorners(@NonNull BitmapPool pool,@NonNull Bitmap inBitmap,int width,int height,int roundingRadius) {
  Preconditions.checkArgument(width > 0,"width must be greater than 0.");
  Preconditions.checkArgument(height > 0,"height must be greater than 0.");
  Preconditions.checkArgument(roundingRadius > 0,"roundingRadius must be greater than 0.");

  // Alpha is required for this transformation.
  Bitmap toTransform = getAlphaSafeBitmap(pool,inBitmap);
  Bitmap result = pool.get(width,Bitmap.Config.ARGB_8888);

  result.setHasAlpha(true);

  BitmapShader shader = new BitmapShader(toTransform,Shader.TileMode.CLAMP);
  Paint paint = new Paint();
  paint.setAntiAlias(true);
  paint.setShader(shader);
  RectF rect = new RectF(0,result.getWidth(),result.getHeight());
  BITMAP_DRAWABLE_LOCK.lock();
  try {
    Canvas canvas = new Canvas(result);
    canvas.drawColor(Color.TRANSPARENT,PorterDuff.Mode.CLEAR);
    canvas.drawRoundRect(rect,roundingRadius,paint);
    clear(canvas);
  } finally {
    BITMAP_DRAWABLE_LOCK.unlock();
  }

  if (!toTransform.equals(inBitmap)) {
    pool.put(toTransform);
  }

  return result;
}
项目:ShimmerDemo    文件AbsFocusBorder.java   
private void setShimmerAnimating(boolean shimmerAnimating)
{
    mShimmerAnimating = shimmerAnimating;
    if (mShimmerAnimating)
    {
        mShimmerlinearGradient = new LinearGradient(0,mFrameRectF.width(),mFrameRectF.height(),new int[] {0x00FFFFFF,0x1AFFFFFF,mShimmerColor,0x00FFFFFF},new float[] {0f,0.2f,0.8f,1f},Shader.TileMode.CLAMP);
        mShimmerPaint.setShader(mShimmerlinearGradient);
    }
}
项目:GitHub    文件ForecastView.java   
private void initGradient() {
    float centerX = getWidth() * 0.5f;
    Shader gradient = new LinearGradient(
            centerX,centerX,currentGradient,Shader.TileMode.MIRROR);
    gradientPaint.setShader(gradient);
}
项目:GitHub    文件RoundedBitmapDrawable.java   
private void updatePaint() {
  Bitmap bitmap = getBitmap();
  if (mLastBitmap == null || mLastBitmap.get() != bitmap) {
    mLastBitmap = new WeakReference<Bitmap>(bitmap);
    mPaint.setShader(new BitmapShader(bitmap,Shader.TileMode.CLAMP));
    mIsShaderTransformDirty = true;
  }
  if (mIsShaderTransformDirty) {
    mPaint.getShader().setLocalMatrix(mTransform);
    mIsShaderTransformDirty = false;
  }
}
项目:JD-Test    文件MaterialProgressDrawable.java   
public ovalShadow(int shadowRadius,Shader.TileMode.CLAMP);
    mShadowPaint.setShader(mRadialGradient);
}
项目:LandscapeView    文件Cloud.java   
public void draw(Canvas canvas) {
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    canvas.scale(scale,0.8f * scale,x,y);
    for (Puff p : puffs) {
        LandscapeView.paint.setShader(new RadialGradient(x + p.x,y + p.y - p.size / 2,p.size,new int[]{0xffffffff,p.color},new float[]{0.9f,1},Shader.TileMode.CLAMP));
        LandscapeView.paint.setAlpha(255);
        canvas.drawCircle(x + p.x,y + p.y,LandscapeView.paint);
    }
    canvas.restore();
}
项目:Rxjava2.0Demo    文件RoundCircleImageView.java   
public RoundCircleImageView(Bitmap mBitmap) {
    this.mBitmap = mBitmap;
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    BitmapShader shader = new BitmapShader(mBitmap,Shader.TileMode.CLAMP);
    mPaint.setShader(shader);
    mWidth = Math.min(mBitmap.getWidth(),mBitmap.getHeight());
}
项目:Rxjava2.0Demo    文件RoundImageDrawable.java   
public RoundImageDrawable(Bitmap bitmap) {
    mBitmap = bitmap;
    BitmapShader shader = new BitmapShader(bitmap,Shader.TileMode.CLAMP);
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setShader(shader);
    mRectF = new RectF();
}
项目:bubble-rank    文件BubbleRank.java   
private void setBitmapShaders(int index,Bitmap bitmap) {
    if (bitmap != null && getBigRadius() > 0 && getSmallRadius() > 0) {
        bigPicShaders.put(
                index,new BitmapShader(
                        getResizedBitmap(bitmap,getBigRadius() * 2,getBigRadius() * 2),Shader.TileMode.CLAMP));
        smallPicShaders.put(
                index,getSmallRadius() * 2,getSmallRadius() * 2),Shader.TileMode.CLAMP));
    }
}
项目:KUtils-master    文件CircleImageView.java   
private void setup() {
    if (!mReady) {
        mSetupPending = true;
        return;
    }

    if (mBitmap == null) {
        return;
    }

    mBitmapShader = new BitmapShader(mBitmap,(mBorderRect.width() - mBorderWidth) / 2);

    mDrawableRect.set(mBorderWidth,mBorderWidth,mBorderRect.width() - mBorderWidth,mBorderRect.height() - mBorderWidth);
    mDrawableRadius = Math.min(mDrawableRect.height() / 2,mDrawableRect.width() / 2);

    updateShaderMatrix();
    invalidate();
}
项目:ucar-weex-core    文件WXComponent.java   
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);
  }
}
项目:ucar-weex-core    文件WXResourceUtils.java   
/**
 * Assembly gradients
 * @param image gradient values contains direction、colors
 * @param width component width
 * @param height component height
 * @return gradient shader
 */
public static Shader getShader(String image,float height) {
  List<String> valueList = parseGradientValues(image);
  if (valueList != null && valueList.size() == 3) {
    float[] points = parseGradientDirection(valueList.get(0),height);
    Shader shader = new LinearGradient(points[0],points[1],points[2],points[3],getColor(valueList.get(1),Color.WHITE),getColor(valueList.get(2),Shader.TileMode.REPEAT);
    return shader;
  }
  return null;
}
项目:terminal-seekbar    文件TerminalBackDrawable.java   
@Override
public void draw(Canvas canvas) {

    terminalPaint.setStyle(Paint.Style.FILL);
    terminalPaint.setColor(color);
    terminalPaint.setAlpha(alpha);
    //int[] toAlpha = new int[]{Color.argb(255,Color.red(255),Color.green(255),Color.blue(255)),Color.argb(0,Color.red(0),Color.green(0),Color.blue(0))};
    int[] toAlpha = new int[]{Color.argb(255,255,225),0)};
    RadialGradient shader = new RadialGradient(cx,cy,radius,toAlpha,Shader.TileMode.MIRROR);
    terminalPaint.setShader(shader);
    terminalPaint.setstrokeJoin(Paint.Join.ROUND);
    terminalPaint.setstrokeCap(Paint.Cap.ROUND);
    canvas.drawCircle(cx,terminalPaint);
}
项目:RLibrary    文件SwipeBackLayout.java   
/**
 * 绘制侧滑时,左边的渐变线
 */
protected void drawSwipeLine(Canvas canvas) {
    if (mTargetView != null && mTargetView.getLeft() != getMeasuredWidth()) {
        mDimRect.set(mTargetView.getLeft() - dimWidth,mTargetView.getLeft(),getMeasuredHeight());
        mPaint.setAlpha((int) (255 * (1 - (mTargetView.getLeft() * 1f / getMeasuredWidth()))));
        mPaint.setShader(new LinearGradient(mDimRect.left,mDimRect.right,new int[]{Color.TRANSPARENT,Color.parseColor("#40000000")},Shader.TileMode.CLAMP));
        canvas.drawRect(mDimRect,mPaint);
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。