当前位置: 首页>>代码示例>>Java>>正文


Java RadialGradient.setLocalMatrix方法代码示例

本文整理汇总了Java中android.graphics.RadialGradient.setLocalMatrix方法的典型用法代码示例。如果您正苦于以下问题:Java RadialGradient.setLocalMatrix方法的具体用法?Java RadialGradient.setLocalMatrix怎么用?Java RadialGradient.setLocalMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.RadialGradient的用法示例。


在下文中一共展示了RadialGradient.setLocalMatrix方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBoundsChange

import android.graphics.RadialGradient; //导入方法依赖的package包/类
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    RadialGradient vignette = new RadialGradient(this.mRect.centerX(), (this.mRect.centerY() * 1.0f) / 0.7f, this.mRect.centerX() * 1.3f, new int[]{0, 0, 2130706432}, new float[]{0.0f, 0.7f, 1.0f}, TileMode.CLAMP);
    Matrix oval = new Matrix();
    oval.setScale(1.0f, 0.7f);
    vignette.setLocalMatrix(oval);
    this.paint.setShader(new ComposeShader(this.bitmapShader, vignette, Mode.SRC_OVER));
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:RoundedVignetteBitmapDisplayer.java

示例2: onBoundsChange

import android.graphics.RadialGradient; //导入方法依赖的package包/类
@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    RadialGradient vignette = new RadialGradient(
            mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f,
            new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f},
            Shader.TileMode.CLAMP);

    Matrix oval = new Matrix();
    oval.setScale(1.0f, 0.7f);
    vignette.setLocalMatrix(oval);

    paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
}
 
开发者ID:Spencer231,项目名称:GifImageLoader,代码行数:15,代码来源:RoundedVignetteBitmapDisplayer.java

示例3: onBoundsChange

import android.graphics.RadialGradient; //导入方法依赖的package包/类
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    RadialGradient vignette = new RadialGradient(this.mRect.centerX(), (this.mRect
            .centerY() * 1.0f) / 0.7f, this.mRect.centerX() * 1.3f, new int[]{0, 0,
            2130706432}, new float[]{0.0f, 0.7f, 1.0f}, TileMode.CLAMP);
    Matrix oval = new Matrix();
    oval.setScale(1.0f, 0.7f);
    vignette.setLocalMatrix(oval);
    this.paint.setShader(new ComposeShader(this.bitmapShader, vignette, Mode.SRC_OVER));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:RoundedVignetteBitmapDisplayer.java

示例4: fillCanvasWithHole

import android.graphics.RadialGradient; //导入方法依赖的package包/类
private void fillCanvasWithHole(Canvas canvas, ColorChangeTask task, float radius, boolean transparent){
	if(transparent)
		return;
	
	float scale = radius / GRADIENT_RADIUS;
	
	mMatrix.reset();
	mMatrix.postScale(scale, scale, task.x, task.y);
	RadialGradient shader = getShader(task);
	shader.setLocalMatrix(mMatrix);
	mShaderPaint.setShader(shader);
	canvas.drawRect(getBounds(), mShaderPaint);
}
 
开发者ID:XhinLiang,项目名称:MDPreference,代码行数:14,代码来源:RevealDrawable.java

示例5: onBoundsChange

import android.graphics.RadialGradient; //导入方法依赖的package包/类
@Override
protected void onBoundsChange(Rect bounds) {
	super.onBoundsChange(bounds);
	RadialGradient vignette = new RadialGradient(
			mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f,
			new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f},
			Shader.TileMode.CLAMP);

	Matrix oval = new Matrix();
	oval.setScale(1.0f, 0.7f);
	vignette.setLocalMatrix(oval);

	paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:15,代码来源:RoundedVignetteBitmapDisplayer.java

示例6: onBoundsChange

import android.graphics.RadialGradient; //导入方法依赖的package包/类
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    RadialGradient vignette = new RadialGradient(this.mRect.centerX(), this.mRect.centerY() * 1.0F / 0.7F, this.mRect.centerX() * 1.3F, new int[]{0, 0, 2130706432}, new float[]{0.0F, 0.7F, 1.0F}, TileMode.CLAMP);
    Matrix oval = new Matrix();
    oval.setScale(1.0F, 0.7F);
    vignette.setLocalMatrix(oval);
    this.paint.setShader(new ComposeShader(this.bitmapShader, vignette, Mode.SRC_OVER));
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:9,代码来源:RoundedLomoBitmapDisplayer.java

示例7: initPaint

import android.graphics.RadialGradient; //导入方法依赖的package包/类
private void initPaint() {
	// 实例化画笔
	mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

	// 去饱和、提亮、色相矫正
	mBitmapPaint.setColorFilter(new ColorMatrixColorFilter(new float[] { 0.8587F, 0.2940F, -0.0927F, 0, 6.79F, 0.0821F, 0.9145F, 0.0634F, 0, 6.79F, 0.2019F, 0.1097F, 0.7483F, 0, 6.79F, 0, 0, 0, 1, 0 }));

	// 实例化Shader图形的画笔
	mShaderPaint = new Paint();

	// 根据我们源图的大小生成暗角Bitmap
	darkCornerBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);

	// 将该暗角Bitmap注入Canvas
	Canvas canvas = new Canvas(darkCornerBitmap);

	// 计算径向渐变半径
	float radiu = canvas.getHeight() * (2F / 3F);

	// 实例化径向渐变
	RadialGradient radialGradient = new RadialGradient(canvas.getWidth() / 2F, canvas.getHeight() / 2F, radiu, new int[] { 0, 0, 0xAA000000 }, new float[] { 0F, 0.7F, 1.0F }, Shader.TileMode.CLAMP);

	// 实例化一个矩阵
	Matrix matrix = new Matrix();

	// 设置矩阵的缩放
	matrix.setScale(canvas.getWidth() / (radiu * 2F), 1.0F);

	// 设置矩阵的预平移
	matrix.preTranslate(((radiu * 2F) - canvas.getWidth()) / 2F, 0);

	// 将该矩阵注入径向渐变
	radialGradient.setLocalMatrix(matrix);

	// 设置画笔Shader
	mShaderPaint.setShader(radialGradient);

	// 绘制矩形
	canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mShaderPaint);
}
 
开发者ID:xu6148152,项目名称:binea_project_for_android,代码行数:41,代码来源:DreamEffectView.java

示例8: init

import android.graphics.RadialGradient; //导入方法依赖的package包/类
private void init() {
    // 位图
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(getResources(), R.mipmap.ic_baoqiang, options);
    mBitmap = MeasureUtil.decodeSampledBitmapFromResource(getResources(), R.mipmap.ic_baoqiang,
            MeasureUtil.getScreenWidth((Activity) getContext()),
            MeasureUtil.getScreenWidth((Activity) getContext()) * options.outHeight / options.outWidth);

    // 混合模式
    mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SCREEN);

    mWidth = MeasureUtil.getScreenWidth((Activity) getContext());
    mHeight = MeasureUtil.getScreenHeight((Activity) getContext()) - MeasureUtil.getStatusBarHeight(getContext()) - MeasureUtil.getToolbarHeight(getContext());

    mSrcX = mWidth / 2 - mBitmap.getWidth() / 2;
    mSrcY = mHeight / 2 - mBitmap.getHeight() / 2;

    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    // 去饱和、提亮、色相矫正
    mBitmapPaint.setColorFilter(new ColorMatrixColorFilter(new float[]{
            0.8587F, 0.2940F, -0.0927F, 0, 6.79F,
            0.0821F, 0.9145F, 0.0634F, 0, 6.79F,
            0.2019F, 0.1097F, 0.7483F, 0, 6.79F,
            0, 0, 0, 1, 0}));
    mBitmapPaint.setXfermode(mXfermode);

    mShaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    // 根据我们源图的大小生成暗角Bitmap
    mDarkCornerBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
    // 将该暗角Bitmap注入Canvas
    Canvas canvas = new Canvas(mDarkCornerBitmap);
    // 计算径向渐变半径
    float radius = canvas.getHeight() * 2 / 3.0f;

    // RadialGradient 径向渐变,径向渐变说的简单点就是个圆形中心向四周渐变的效果
    // colors是一个int型数组,我们用来定义所有渐变的颜色,positions表示的是渐变的相对区域,其取值只有0到1
    RadialGradient radialGradient = new RadialGradient(canvas.getWidth() / 2,
            canvas.getHeight() / 2,
            radius,
            // 0x00000000透明度为100%黑色
            new int[]{0x00000000, 0x00000000, 0xAA000000},
            new float[]{0F, 0.7F, 1.0F},
            Shader.TileMode.CLAMP);
    Matrix matrix = new Matrix();
    // 设置矩阵的缩放
    matrix.setScale(canvas.getWidth() / (radius * 2f), 1f);
    // 设置矩阵的预平移(preTranslate是指在上面的setScale前)
    matrix.preTranslate(((radius * 2F) - canvas.getWidth()) / 2F, 0);
    // 将该矩阵注入径向渐变
    radialGradient.setLocalMatrix(matrix);

    mShaderPaint.setShader(radialGradient);
    // 绘制矩形
    canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mShaderPaint);

}
 
开发者ID:oubowu,项目名称:AndroidExerciseProgram,代码行数:58,代码来源:DreamEffectView.java

示例9: initPaint

import android.graphics.RadialGradient; //导入方法依赖的package包/类
private void initPaint() {
		mPaint = new Paint(Paint.ANTI_ALIAS_FLAG|Paint.DITHER_FLAG);

		x = Utils.getScreenWidth(mContext) / 2;
		y = Utils.getScreenHeight(mContext) / 2;

		mSrcBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.aa);

		mPaint.setColorFilter(new ColorMatrixColorFilter(new float[]{0.8587F, 0.2940F, -0.0927F, 0, 6.79F, 0.0821F, 0.9145F, 0.0634F, 0, 6.79F, 0.2019F, 0.1097F, 0.7483F, 0, 6.79F, 0, 0, 0, 1, 0}));
//		mPaint.setShader(new LinearGradient(x, y + mSrcBitmap.getHeight(), x, y + mSrcBitmap.getHeight() + mSrcBitmap.getHeight() / 4, 0xAA000000, Color.TRANSPARENT, Shader.TileMode.CLAMP));

		mRefBitmap = Bitmap.createBitmap(mSrcBitmap.getWidth(), mSrcBitmap.getHeight(), Bitmap.Config.ARGB_8888);

		Canvas canvas = new Canvas(mRefBitmap);

		float radiu = canvas.getHeight() * (2F / 3F);
		RadialGradient radialGradient = new RadialGradient(canvas.getWidth() / 2F, canvas.getHeight() / 2F, radiu, new int[] { 0, 0, 0xAA000000 }, new float[] { 0F, 0.7F, 1.0F }, Shader.TileMode.CLAMP);

		Matrix matrix = new Matrix();

		matrix.setScale(canvas.getWidth() / (radiu * 2F), 1.0F);
		matrix.preTranslate(((radiu * 2F) - canvas.getWidth()) / 2F, 0);

		radialGradient.setLocalMatrix(matrix);

		mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SCREEN);

		shaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
		shaderPaint.setShader(radialGradient);

		canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), shaderPaint);
	}
 
开发者ID:xu6148152,项目名称:binea_project_for_android,代码行数:33,代码来源:DreamEffectView.java


注:本文中的android.graphics.RadialGradient.setLocalMatrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。