本文整理匯總了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));
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}