use of android.graphics.Rect in project Carbon by ZieIony.
the class CheckableDrawable method drawChecked.
private void drawChecked(@NonNull Canvas canvas, float radius) {
Rect bounds = getBounds();
paint.setShader(null);
paint.setColorFilter(uncheckedFilter);
canvas.drawBitmap(uncheckedBitmap, bounds.left, bounds.top, paint);
maskCanvas.drawColor(0xffffffff);
maskPaint.setXfermode(porterDuffClear);
maskCanvas.drawCircle(maskBitmap.getWidth() / 2 + bounds.width() * offset.x, maskBitmap.getHeight() / 2 + bounds.height() * offset.y, radius, maskPaint);
maskPaint.setXfermode(porterDuffSrcIn);
maskCanvas.drawBitmap(filledBitmap, 0, 0, maskPaint);
canvas.drawBitmap(maskBitmap, bounds.left, bounds.top, paint);
paint.setShader(checkedShader);
paint.setColorFilter(checkedFilter);
canvas.drawCircle(bounds.centerX() + bounds.width() * offset.x, bounds.centerY() + bounds.height() * offset.y, radius, paint);
}
use of android.graphics.Rect in project Carbon by ZieIony.
the class CheckableDrawable method draw.
@Override
public void draw(@NonNull Canvas canvas) {
if (checkedBitmap == null)
renderSVGs();
Rect bounds = getBounds();
if (animator != null && animator.isRunning()) {
if (currAnim == ANIMATION_FILL) {
drawUnchecked(canvas, currRadius);
} else {
drawChecked(canvas, currRadius);
}
} else {
if (checkedState == CheckedState.CHECKED) {
paint.setColorFilter(checkedFilter);
canvas.drawBitmap(checkedBitmap, bounds.left, bounds.top, paint);
} else if (checkedState == CheckedState.UNCHECKED) {
paint.setColorFilter(uncheckedFilter);
canvas.drawBitmap(uncheckedBitmap, bounds.left, bounds.top, paint);
} else {
paint.setColorFilter(uncheckedFilter);
canvas.drawBitmap(filledBitmap, bounds.left, bounds.top, paint);
}
}
}
use of android.graphics.Rect in project Carbon by ZieIony.
the class CoordinatorLayout method isTransformedTouchPointInView.
protected boolean isTransformedTouchPointInView(float x, float y, View child, PointF outLocalPoint) {
final Rect frame = new Rect();
child.getHitRect(frame);
return frame.contains((int) x, (int) y);
}
use of android.graphics.Rect in project Carbon by ZieIony.
the class RippleDrawableFroyo method drawBackgroundAndRipples.
private void drawBackgroundAndRipples(Canvas canvas) {
final RippleForeground active = mRipple;
final RippleBackground background = mBackground;
final int count = mExitingRipplesCount;
if (active == null && count <= 0 && (background == null || !background.isVisible())) {
// Move along, nothing to draw here.
return;
}
final float x = mHotspotBounds.exactCenterX();
final float y = mHotspotBounds.exactCenterY();
canvas.translate(x, y);
updateMaskShaderIfNeeded();
// Position the shader to account for canvas translation.
if (mMaskShader != null) {
final Rect bounds = getBounds();
mMaskMatrix.setTranslate(bounds.left - x, bounds.top - y);
mMaskShader.setLocalMatrix(mMaskMatrix);
}
// Grab the color for the current state and cut the alpha channel in
// half so that the ripple and background together yield full alpha.
final int color = mState.mColor.getColorForState(getState(), Color.BLACK);
final int halfAlpha = (Color.alpha(color) / 2) << 24;
final Paint p = getRipplePaint();
if (mMaskColorFilter != null) {
// The ripple timing depends on the paint's alpha value, so we need
// to push just the alpha channel into the paint and let the filter
// handle the full-alpha color.
final int fullAlphaColor = color | (0xFF << 24);
DrawableReflectiveUtils.setColor(mMaskColorFilter, fullAlphaColor, PorterDuff.Mode.SRC_IN);
//mMaskColorFilter.setColor(fullAlphaColor);
p.setColor(halfAlpha);
p.setColorFilter(mMaskColorFilter);
p.setShader(mMaskShader);
} else {
final int halfAlphaColor = (color & 0xFFFFFF) | halfAlpha;
p.setColor(halfAlphaColor);
p.setColorFilter(null);
p.setShader(null);
}
if (background != null && background.isVisible()) {
background.draw(canvas, p);
}
if (count > 0) {
final RippleForeground[] ripples = mExitingRipples;
for (int i = 0; i < count; i++) {
ripples[i].draw(canvas, p);
}
}
if (active != null) {
active.draw(canvas, p);
}
canvas.translate(-x, -y);
}
use of android.graphics.Rect in project Carbon by ZieIony.
the class RippleDrawableFroyo method draw.
/**
* Optimized for drawing ripples with a mask layer and optional content.
*/
@Override
public void draw(@NonNull Canvas canvas) {
pruneRipples();
// Clip to the dirty bounds, which will be the drawable bounds if we
// have a mask or content and the ripple bounds if we're projecting.
final Rect bounds = getDirtyBounds();
final int saveCount = canvas.save(Canvas.CLIP_SAVE_FLAG);
canvas.clipRect(bounds);
drawContent(canvas);
drawBackgroundAndRipples(canvas);
canvas.restoreToCount(saveCount);
}
Aggregations