当前位置: 首页>>代码示例>>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;未经允许,请勿转载。