use of android.graphics.Shader in project CustomShapeImageView by MostafaGazar.
the class SVGHandlerTest method testDoFill_byURL.
@Test
public void testDoFill_byURL() {
// given
HashMap<String, Shader> gradients = new HashMap<>();
Shader shader = mock(Shader.class);
gradients.put("gr1", shader);
// when
boolean res = parserHandler.doFill(new SVGParser.Properties(attributes(attr("fill", "url(#gr1)"))), gradients);
// then
assertThat(res, is(true));
verify(paint).setShader(shader);
verify(paint).setStyle(Paint.Style.FILL);
}
use of android.graphics.Shader in project xDrip by NightscoutFoundation.
the class CircleWatchface method prepareDrawTime.
private synchronized void prepareDrawTime() {
Log.d(TAG, "CircleWatchface start prepareDrawTime");
hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) % 12;
minute = Calendar.getInstance().get(Calendar.MINUTE);
angleBig = (((hour + minute / 60f) / 12f * 360) - 90 - BIG_HAND_WIDTH / 2f + 360) % 360;
angleSMALL = ((minute / 60f * 360) - 90 - SMALL_HAND_WIDTH / 2f + 360) % 360;
color = 0;
switch(getSgvLevel()) {
case -1:
color = getLowColor();
break;
case 0:
color = getInRangeColor();
break;
case 1:
color = getHighColor();
break;
}
if (isAnimated()) {
// Animation matrix:
int[] rainbow = { Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.CYAN };
Shader shader = new LinearGradient(0, 0, 0, 20, rainbow, null, Shader.TileMode.MIRROR);
Matrix matrix = new Matrix();
matrix.setRotate(animationAngle);
shader.setLocalMatrix(matrix);
circlePaint.setShader(shader);
} else {
circlePaint.setShader(null);
}
circlePaint.setStyle(Paint.Style.STROKE);
circlePaint.setStrokeWidth(CIRCLE_WIDTH);
circlePaint.setAntiAlias(true);
circlePaint.setColor(color);
removePaint.setStyle(Paint.Style.STROKE);
removePaint.setStrokeWidth(CIRCLE_WIDTH);
removePaint.setAntiAlias(true);
removePaint.setColor(getBackgroundColor());
;
rect = new RectF(PADDING, PADDING, (float) (displaySize.x - PADDING), (float) (displaySize.y - PADDING));
rectDelete = new RectF(PADDING - CIRCLE_WIDTH / 2, PADDING - CIRCLE_WIDTH / 2, (float) (displaySize.x - PADDING + CIRCLE_WIDTH / 2), (float) (displaySize.y - PADDING + CIRCLE_WIDTH / 2));
overlapping = ALWAYS_HIGHLIGT_SMALL || areOverlapping(angleSMALL, angleSMALL + SMALL_HAND_WIDTH + NEAR, angleBig, angleBig + BIG_HAND_WIDTH + NEAR);
Log.d(TAG, "CircleWatchface end prepareDrawTime");
}
use of android.graphics.Shader in project xDrip-plus by jamorham.
the class BIGChart method updateRainbow.
protected void updateRainbow() {
animationAngle = (animationAngle + 1) % 360;
// Animation matrix:
int[] rainbow = { Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.CYAN };
Shader shader = new LinearGradient(0, 0, 0, 20, rainbow, null, Shader.TileMode.MIRROR);
Matrix matrix = new Matrix();
matrix.setRotate(animationAngle);
shader.setLocalMatrix(matrix);
mSgv.getPaint().setShader(shader);
invalidate();
}
use of android.graphics.Shader in project seven_develop by seven123456.
the class GradientView method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = getWidth() / 2;
int height = getHeight() / 2;
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(20);
Matrix matrix = new Matrix();
matrix.setRotate(-90, width, height);
Shader shader = new LinearGradient(width, 0, getWidth(), height, Color.RED, Color.GREEN, Shader.TileMode.CLAMP);
shader.setLocalMatrix(matrix);
paint.setShader(shader);
canvas.drawCircle(width, height, 200, paint);
}
Aggregations