Android ComposeShader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ComposeShader class.

This code example shows how to use the following methods:
			paint = new Paint();
			luar = new LinearGradient(0.f, 0.f, 0.f, this.getMeasuredHeight(), 0xffffffff, 0xff000000, TileMode.CLAMP);
		} 
		int rgb = Color.HSVToColor(color);
		Shader dalam = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, 0xffffffff, rgb, TileMode.CLAMP);
		ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY);
		paint.setShader(shader);
		canvas.drawRect(0.f, 0.f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint);
	} 
 
	void setHue(float hue) {
		color[0] = hue;
		invalidate();
	} 
} 
7
CodeRank
This code example shows how to use the following methods:
	LinearGradient gradient = new LinearGradient(0, 0, 0, mBitmap.getHeight(), mStartColor, mEndColor, Shader.TileMode.CLAMP);
 
	// Make a combined shader -- a performance win. 
        // The linear-gradient is the 'SRC' and the bitmap-shader is the 'DST'. 
	// Drawing the DST in the SRC will provide the opacity. 
	mPaint.setShader(new ComposeShader(bitmapShader, gradient, PorterDuff.Mode.DST_IN));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
			this.satShader = new LinearGradient(0, 0, getWidth(), 0, 0xffffffff, satColor, TileMode.CLAMP);
			newShader = true;
		} 
		 
		if(newShader){
			this.satValShader = new ComposeShader(valShader, satShader, Mode.MULTIPLY);
			shaderPaint.setShader(satValShader);
		} 
		canvas.drawRect(0, 0, getWidth(), getHeight(), shaderPaint);
		 
		if(value > 0.5 && saturation < 0.5)
			cursorPaint.setColor(Color.BLACK);
		else 
			cursorPaint.setColor(Color.WHITE);
		canvas.drawCircle(saturation*this.getWidth(), (1 - value)*this.getHeight(), this.getWidth()/75, cursorPaint);
	} 
	 
	@Override 
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
4
CodeRank
This code example shows how to use the following methods:
 
		int rgb = Color.HSVToColor(new float[] { mHue, 1f, 1f });
		Shader satGradient = new LinearGradient(0, 0, w, 0, Color.WHITE, rgb,
				Shader.TileMode.CLAMP);
 
		ComposeShader shader = new ComposeShader(valGradient, satGradient,
				PorterDuff.Mode.MULTIPLY);
 
		mGradient.setShader(shader);
		invalidate();
	} 
 
	@Override 
	public void setColor(int color) {
		mColor.setColor(color);
 
		float[] hsv = Utils.color2HSV(color);
 
		mHue = hsv[0];
 
4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
			Matrix oval = new Matrix();
			oval.setScale(1.0f, 0.7f);
			vignette.setLocalMatrix(oval);
 
			mPaint.setShader(
					new ComposeShader(mBitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
		} 
	} 
 
	@Override 
	public void draw(Canvas canvas) {
		canvas.drawRoundRect(mRect, mCornerRadius, mCornerRadius, mPaint);
	} 
 
	@Override 
	public int getOpacity() { 
		return PixelFormat.TRANSLUCENT;
	} 
 
	@Override 
4
CodeRank
This code example shows how to use the following methods:
			Matrix oval = new Matrix();
			oval.setScale(1.0f, 0.7f);
			vignette.setLocalMatrix(oval);
 
			mPaint.setShader(new ComposeShader(mBitmapShader, vignette,
					PorterDuff.Mode.SRC_OVER));
		} 
	} 
 
	@Override 
	public void draw(Canvas canvas) {
		canvas.drawRoundRect(mRect, mCornerRadius, mCornerRadius, mPaint);
	} 
 
	@Override 
	public int getOpacity() { 
		return PixelFormat.TRANSLUCENT;
	} 
 
	@Override 
4
CodeRank
This code example shows how to use the following methods:
	protected void onDraw(Canvas canvas){
		//canvas.drawRGB(200, 200, 200); 
		//canvas.drawRect(0, 0, getWidth(), getHeight(), border); 
		Shader shader1 = new LinearGradient(0, 0, getWidth(), 0, Color.WHITE, Color.HSVToColor(new float[]{getBarElement(), 1f, 1f}), Shader.TileMode.REPEAT);
		Shader shader2 = new LinearGradient(0, 0, 0, getHeight(), Color.WHITE, Color.BLACK, Shader.TileMode.REPEAT);
		Shader compose = new ComposeShader(shader1, shader2, PorterDuff.Mode.MULTIPLY);
		border.setShader(compose);
		canvas.drawRect(0, 0, getWidth(), getHeight(), border);
	} 
 
	public int getBarElement() { 
		return barElement;
	} 
 
	public void setBarElement(int barElement) {
		this.barElement = barElement;
	} 
 
} 
4
CodeRank

Related Android ComposeShader Questions & Answers:

See Code Examples for Android ComposeShader Methods: