當前位置: 首頁>>代碼示例>>Java>>正文


Java ComposeShader類代碼示例

本文整理匯總了Java中android.graphics.ComposeShader的典型用法代碼示例。如果您正苦於以下問題:Java ComposeShader類的具體用法?Java ComposeShader怎麽用?Java ComposeShader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ComposeShader類屬於android.graphics包,在下文中一共展示了ComposeShader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initPaint

import android.graphics.ComposeShader; //導入依賴的package包/類
private void initPaint() {
        DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
        textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, textSize, dm);
        mPaint = new Paint();
        mPaint.setColor(Color.RED);
        mPaint.setAntiAlias(true);
        mPaint.setStrokeWidth(1);
        mPaint.setTextSize(35);
        mPaint.setColorFilter(new ColorFilter());
//        mPaint.setStyle(Paint.Style.STROKE);
        mPath = new Path();
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg1);
        bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.bg2);
        bitmapShader1 = new BitmapShader(bitmap1, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        shader = new ComposeShader(bitmapShader, bitmapShader1, PorterDuff.Mode.SRC_OVER);

    }
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:19,代碼來源:DrawTextView.java

示例2: createColorWheelBitmap

import android.graphics.ComposeShader; //導入依賴的package包/類
private Bitmap createColorWheelBitmap(int width, int height) {

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

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:27,代碼來源:ColorPicker.java

示例3: updateColorDependant

import android.graphics.ComposeShader; //導入依賴的package包/類
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.BLACK, 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());
    }
}
 
開發者ID:eltos,項目名稱:SimpleDialogFragments,代碼行數:17,代碼來源:ColorWheelView.java

示例4: onDraw

import android.graphics.ComposeShader; //導入依賴的package包/類
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas)
{
	super.onDraw(canvas);
	int width  = getMeasuredWidth();
	int height = getMeasuredHeight();

	int new_color = Color.HSVToColor(hsv);
	if(color != new_color)
	{
		Shader shader_x = new LinearGradient(0.0F, 0.0F, width, 0.0F, Color.WHITE, new_color, TileMode.CLAMP);
		
		ComposeShader shader = new ComposeShader(shader_y, shader_x, PorterDuff.Mode.MULTIPLY);
		paint.setShader(shader);
		
		color = new_color;
	}
	canvas.drawRect(0.0F, 0.0F, width, height, paint);
}
 
開發者ID:KAlO2,項目名稱:PerfectShow,代碼行數:21,代碼來源:ColorPickerCircle.java

示例5: createColorWheelBitmap

import android.graphics.ComposeShader; //導入依賴的package包/類
private Bitmap createColorWheelBitmap(int width, int height) {

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

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f, 1f, 1f};
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
 
開發者ID:mercadopago,項目名稱:px-android,代碼行數:27,代碼來源:ColorPicker.java

示例6: onDraw

import android.graphics.ComposeShader; //導入依賴的package包/類
@Override
protected void onDraw(final Canvas canvas) {
	super.onDraw(canvas);

	if (this.paint == null) {
		this.paint = new Paint();
		this.luar = new LinearGradient(0.f, 0.f, 0.f, this.ukuranUiPx, 0xffffffff, 0xff000000,
				TileMode.CLAMP);
	}

	this.tmp00[1] = this.tmp00[2] = 1.f;
	this.tmp00[0] = this.hue;
	int rgb = Color.HSVToColor(this.tmp00);

	this.dalam = new LinearGradient(0.f, 0.f, this.ukuranUiPx, 0.f, 0xffffffff, rgb,
			TileMode.CLAMP);
	ComposeShader shader = new ComposeShader(this.luar, this.dalam, PorterDuff.Mode.MULTIPLY);

	this.paint.setShader(shader);

	canvas.drawRect(0.f, 0.f, this.ukuranUiPx, this.ukuranUiPx, this.paint);
}
 
開發者ID:andrewxu10,項目名稱:Upkeep,代碼行數:23,代碼來源:AmbilWarnaKotak.java

示例7: onClick

import android.graphics.ComposeShader; //導入依賴的package包/類
@Override
public void onClick(final View v) {
    switch (new Random().nextInt(5)) {
        case 0:
            mPaint.setShader(sweepGradient);
            break;
        case 1:
            mPaint.setShader(linearGradient);
            break;
        case 2:
            mPaint.setShader(radialGradient);
            break;
        case 3:
            mPaint.setShader(bitmapShader1);
            break;
        case 4:
            final Shader composeShader = new ComposeShader(bitmapShader1,
                    new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.ic_msg_unread),
                            Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)
                    , intToMode(new Random().nextInt(16)));
            mPaint.setShader(composeShader);
            break;
    }
    invalidate();
}
 
開發者ID:Thewhitelight,項目名稱:CircleProgressView,代碼行數:26,代碼來源:CustomView.java

示例8: drawSatValPanel

import android.graphics.ComposeShader; //導入依賴的package包/類
private void drawSatValPanel(Canvas canvas) {
    RectF rect = this.mSatValRect;
    this.mBorderPaint.setColor(this.mBorderColor);
    canvas.drawRect(this.mDrawingRect.left, this.mDrawingRect.top, BORDER_WIDTH_PX + rect.right, BORDER_WIDTH_PX + rect.bottom, this.mBorderPaint);
    if (this.mValShader == null) {
        this.mValShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, -1, ViewCompat.MEASURED_STATE_MASK, TileMode.CLAMP);
    }
    this.mSatShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top, -1, Color.HSVToColor(new float[]{this.mHue, BORDER_WIDTH_PX, BORDER_WIDTH_PX}), TileMode.CLAMP);
    this.mSatValPaint.setShader(new ComposeShader(this.mValShader, this.mSatShader, Mode.MULTIPLY));
    canvas.drawRect(rect, this.mSatValPaint);
    Point p = satValToPoint(this.mSat, this.mVal);
    this.mSatValTrackerPaint.setColor(ViewCompat.MEASURED_STATE_MASK);
    canvas.drawCircle((float) p.x, (float) p.y, this.PALETTE_CIRCLE_TRACKER_RADIUS - (BORDER_WIDTH_PX * this.mDensity), this.mSatValTrackerPaint);
    this.mSatValTrackerPaint.setColor(0xffdddddd);
    canvas.drawCircle((float) p.x, (float) p.y, this.PALETTE_CIRCLE_TRACKER_RADIUS, this.mSatValTrackerPaint);
}
 
開發者ID:heshshark,項目名稱:ToastUI,代碼行數:17,代碼來源:ColorPickerView.java

示例9: updateMainColors

import android.graphics.ComposeShader; //導入依賴的package包/類
private void updateMainColors(int color) {
    if (baseColor == color) {
        return;
    }

    baseColor = color;

    Shader gradientShader = new LinearGradient(0.f,
                                               0.f,
                                               NUMBER_OF_GRADIENTS,
                                               0.f,
                                               Color.WHITE,
                                               baseColor,
                                               Shader.TileMode.CLAMP);
    ComposeShader shader = new ComposeShader(gradientShader,
                                             baseGradientShader,
                                             PorterDuff.Mode.MULTIPLY);
    gradientsPaint.setShader(shader);
    preRenderingCanvas
            .drawRect(0.f, 0.f, NUMBER_OF_GRADIENTS, NUMBER_OF_GRADIENTS, gradientsPaint);
}
 
開發者ID:yombunker,項目名稱:Android-ColorPicker,代碼行數:22,代碼來源:ColorAreaPicker.java

示例10: getDefaultOuterRimPaint

import android.graphics.ComposeShader; //導入依賴的package包/類
/**
 * Set default outer rim paint
 *
 * @return paint
 *          Paint for outer rim
 */
private Paint getDefaultOuterRimPaint() {
	/** Linear gradient to create the 3D effect */
	final LinearGradient verticalGradient = new LinearGradient(mOuterRimRect.left, mOuterRimRect.top, mOuterRimRect.left,
			mOuterRimRect.bottom, Color.rgb(255, 255, 255), Color.rgb(84, 90, 100), TileMode.REPEAT);

	/** Bitmap for outer rim */
	final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.darkwood);
	/** Bitmap shader for the metallic style */
	final BitmapShader outerRimTile = new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
	/** Matrix for outer rim */
	final Matrix matrix = new Matrix();
	matrix.setScale(1.0f / bitmap.getWidth(), 1.0f / bitmap.getHeight());
	outerRimTile.setLocalMatrix(matrix);

	/** Paint for outer rim */
	final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setShader(new ComposeShader(verticalGradient, outerRimTile, PorterDuff.Mode.MULTIPLY));
	paint.setFilterBitmap(true);
	return paint;
}
 
開發者ID:beegee-tokyo,項目名稱:WeatherStation,代碼行數:27,代碼來源:GaugeView.java

示例11: getDefaultInnerRimPaint

import android.graphics.ComposeShader; //導入依賴的package包/類
/**
 * Set default inner rim paint
 *
 * @return paint
 *          Paint for inner rim
 */
private Paint getDefaultInnerRimPaint() {
	/** Linear gradient to create the 3D effect */
	final LinearGradient verticalGradient = new LinearGradient(mOuterRimRect.left, mOuterRimRect.top, mOuterRimRect.left,
			mOuterRimRect.bottom, Color.rgb(255, 255, 255), Color.rgb(84, 90, 100), TileMode.REPEAT);

	/** Bitmap for inner rim */
	final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.darkerwood);
	/** Bitmap shader for the metallic style */
	final BitmapShader innerRimTile = new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
	/** Matrix for inner rim */
	final Matrix matrix = new Matrix();
	matrix.setScale(1.0f / bitmap.getWidth(), 1.0f / bitmap.getHeight());
	innerRimTile.setLocalMatrix(matrix);

	/** Paint for outer rim */
	final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setShader(new ComposeShader(verticalGradient, innerRimTile, PorterDuff.Mode.MULTIPLY));
	paint.setFilterBitmap(true);
	return paint;
}
 
開發者ID:beegee-tokyo,項目名稱:WeatherStation,代碼行數:27,代碼來源:GaugeView.java

示例12: getDefaultOuterRimPaint

import android.graphics.ComposeShader; //導入依賴的package包/類
public Paint getDefaultOuterRimPaint() {
    // Use a linear gradient to create the 3D effect
    final LinearGradient verticalGradient = new LinearGradient(mOuterRimRect.left, mOuterRimRect.top, mOuterRimRect.left,
            mOuterRimRect.bottom, Color.rgb(255, 255, 255), Color.rgb(84, 90, 100), TileMode.REPEAT);

    // Use a Bitmap shader for the metallic style
    final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.light_alu);
    final BitmapShader aluminiumTile = new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
    final Matrix matrix = new Matrix();
    matrix.setScale(1.0f / bitmap.getWidth(), 1.0f / bitmap.getHeight());
    aluminiumTile.setLocalMatrix(matrix);

    final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setShader(new ComposeShader(verticalGradient, aluminiumTile, PorterDuff.Mode.MULTIPLY));
    paint.setFilterBitmap(true);
    return paint;
}
 
開發者ID:sygi1982,項目名稱:bmw-dash,代碼行數:18,代碼來源:GaugeView.java

示例13: getDefaultOuterRimPaint

import android.graphics.ComposeShader; //導入依賴的package包/類
public Paint getDefaultOuterRimPaint() {
	// Use a linear gradient to create the 3D effect
	final LinearGradient verticalGradient = new LinearGradient(mOuterRimRect.left, mOuterRimRect.top, mOuterRimRect.left,
			mOuterRimRect.bottom, Color.rgb(255, 255, 255), Color.rgb(84, 90, 100), TileMode.REPEAT);

	// Use a Bitmap shader for the metallic style
	final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.light_alu);
	final BitmapShader aluminiumTile = new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
	final Matrix matrix = new Matrix();
	matrix.setScale(1.0f / bitmap.getWidth(), 1.0f / bitmap.getHeight());
	aluminiumTile.setLocalMatrix(matrix);

	final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setShader(new ComposeShader(verticalGradient, aluminiumTile, PorterDuff.Mode.MULTIPLY));
	paint.setFilterBitmap(true);
	return paint;
}
 
開發者ID:JCRin,項目名稱:ECU-Obd-Elm327-Bluetooth,代碼行數:18,代碼來源:GaugeRpm.java

示例14: onDraw

import android.graphics.ComposeShader; //導入依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);

	if(paint==null)
	{
		paint = new Paint();
		lg = new LinearGradient(0.0f, 0.0f, 0.0f, this.getMeasuredHeight(), 0xffffffff, 0xff000000,  TileMode.CLAMP);
	}
	
	if(updateColor){
		int rgb = Color.HSVToColor(color);
		lg2 = new LinearGradient(0.0f, 0.0f, this.getMeasuredWidth(), 0.0f, 0xffffffff, rgb, TileMode.CLAMP);
		shader = new ComposeShader(lg, lg2, PorterDuff.Mode.MULTIPLY);
		updateColor = false;
	}
	
	paint.setShader(shader);
	canvas.drawRect(0.0f, 0.0f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint);
}
 
開發者ID:mpakarlsson,項目名稱:ilearnrw-reader,代碼行數:21,代碼來源:ColorSquare.java

示例15: onBoundsChange

import android.graphics.ComposeShader; //導入依賴的package包/類
@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    mRect.set(mMargin, mMargin, bounds.width() - mMargin, bounds.height() - mMargin);

    if (USE_VIGNETTE) {
        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);

        mPaint.setShader(
                new ComposeShader(mBitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
    }
}
 
開發者ID:tajchert,項目名稱:CEEHack,代碼行數:20,代碼來源:RoundCornersDrawable.java


注:本文中的android.graphics.ComposeShader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。