private void drawChild(Canvas canvas, View child, LayoutParams lp) {
mSrcCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
mDstCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
mSrcCanvas.save();
int childLeft = child.getLeft();
int childTop = child.getTop();
int childRight = child.getRight();
int childBottom = child.getBottom();
mSrcCanvas.clipRect(childLeft, childTop, childRight, childBottom, Op.REPLACE);
mSrcCanvas.translate(childLeft, childTop);
child.draw(mSrcCanvas);
mSrcCanvas.restore();
mXferPaint.setXfermode(null);
mXferPaint.setColor(Color.BLACK);
float sweepAngle = (lp.endAngle - lp.startAngle) % 361;
mDstCanvas.drawArc(mBounds, lp.startAngle, sweepAngle, true, mXferPaint);
mXferPaint.setXfermode(mXfer);
mDstCanvas.drawBitmap(mSrc, 0f, 0f, mXferPaint);
canvas.drawBitmap(mDst, 0f, 0f, null);
}
java类android.graphics.Region.Op的实例源码
CircleLayout.java 文件源码
项目:xwallet
阅读 23
收藏 0
点赞 0
评论 0
Selection.java 文件源码
项目:PaintPlusPlus
阅读 26
收藏 0
点赞 0
评论 0
void commitSelectionOval(Rect rect, Op op)
{
ActionSelectionChange action = new ActionSelectionChange(image);
action.setOldRegion();
RectF rectF = new RectF(rect);
Path ovalPath = new Path();
ovalPath.addOval(rectF, CW);
Region ovalRegion = new Region();
ovalRegion.setPath(ovalPath, new Region(0, 0, imageRect.right, imageRect.bottom));
region.op(ovalRegion, op);
updatePath();
action.applyAction();
}
TouchVisualizationView.java 文件源码
项目:FMTech
阅读 19
收藏 0
点赞 0
评论 0
private final boolean a(ghu paramghu, boolean paramBoolean, Canvas paramCanvas)
{
int j = 255;
if (getDrawingTime() >= paramghu.e + this.g) {
return false;
}
if (paramBoolean)
{
float f1 = 1.0F - (float)(getDrawingTime() - paramghu.e) / this.g;
j = efj.a(Math.round(255.0F * (f1 * f1)), 0, j);
}
this.d.setAlpha(j);
if (this.h != null)
{
this.h.setBounds(paramghu.a(0, 0));
this.h.draw(paramCanvas);
}
for (;;)
{
return true;
paramCanvas.clipRect(paramghu.a(0, 0), Region.Op.UNION);
paramCanvas.drawCircle(paramghu.a, paramghu.b, paramghu.c, this.d);
}
}
BubbleTextView.java 文件源码
项目:TurboLauncher
阅读 24
收藏 0
点赞 0
评论 0
/**
* Draw this BubbleTextView into the given Canvas.
*
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private void drawWithPadding(Canvas destCanvas, int padding) {
final Rect clipRect = mTempRect;
getDrawingRect(clipRect);
// adjust the clip rect so that we don't include the text label
clipRect.bottom =
getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + getLayout().getLineTop(0);
// Draw the View into the bitmap.
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
destCanvas.scale(getScaleX(), getScaleY(),
(getWidth() + padding) / 2, (getHeight() + padding) / 2);
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
destCanvas.restore();
}
PopupZoomer.java 文件源码
项目:365browser
阅读 18
收藏 0
点赞 0
评论 0
/**
* Sets the bitmap to be used for the zoomed view.
*/
public void setBitmap(Bitmap bitmap) {
if (mZoomedBitmap != null) {
mZoomedBitmap.recycle();
mZoomedBitmap = null;
}
mZoomedBitmap = bitmap;
// Round the corners of the bitmap so it doesn't stick out around the overlay.
Canvas canvas = new Canvas(mZoomedBitmap);
Path path = new Path();
RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
float overlayCornerRadius = getOverlayCornerRadius(getContext());
path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
canvas.clipPath(path, Op.XOR);
Paint clearPaint = new Paint();
clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
clearPaint.setColor(Color.TRANSPARENT);
canvas.drawPaint(clearPaint);
}
Workspace.java 文件源码
项目:LeanLauncher
阅读 36
收藏 0
点赞 0
评论 0
/**
* Draw the View v into the given Canvas.
*
* @param v the view to draw
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private static void drawDragView(View v, Canvas destCanvas, int padding) {
final Rect clipRect = sTempRect;
v.getDrawingRect(clipRect);
destCanvas.save();
if (v instanceof TextView) {
Drawable d = ((TextView) v).getCompoundDrawables()[1];
Rect bounds = getDrawableBounds(d);
clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding);
destCanvas.translate(padding / 2 - bounds.left, padding / 2 - bounds.top);
d.draw(destCanvas);
} else {
destCanvas.translate(-v.getScrollX() + padding / 2, -v.getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
v.draw(destCanvas);
}
destCanvas.restore();
}
PopupZoomer.java 文件源码
项目:android-chromium-view
阅读 18
收藏 0
点赞 0
评论 0
/**
* Sets the bitmap to be used for the zoomed view.
*/
public void setBitmap(Bitmap bitmap) {
if (mZoomedBitmap != null) {
mZoomedBitmap.recycle();
mZoomedBitmap = null;
}
mZoomedBitmap = bitmap;
// Round the corners of the bitmap so it doesn't stick out around the overlay.
Canvas canvas = new Canvas(mZoomedBitmap);
Path path = new Path();
RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
float overlayCornerRadius = getOverlayCornerRadius(getContext());
path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
canvas.clipPath(path, Op.XOR);
Paint clearPaint = new Paint();
clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
clearPaint.setColor(Color.TRANSPARENT);
canvas.drawPaint(clearPaint);
}
BubbleTextView.java 文件源码
项目:androidProject
阅读 25
收藏 0
点赞 0
评论 0
/**
* Draw this BubbleTextView into the given Canvas.
*
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private void drawWithPadding(Canvas destCanvas, int padding) {
final Rect clipRect = mTempRect;
getDrawingRect(clipRect);
// adjust the clip rect so that we don't include the text label
clipRect.bottom =
getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + getLayout().getLineTop(0);
// Draw the View into the bitmap.
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
destCanvas.restore();
}
BubbleTextView.java 文件源码
项目:open-gel-plus
阅读 28
收藏 0
点赞 0
评论 0
/**
* Draw this BubbleTextView into the given Canvas.
*
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private void drawWithPadding(Canvas destCanvas, int padding) {
final Rect clipRect = mTempRect;
getDrawingRect(clipRect);
// adjust the clip rect so that we don't include the text label
clipRect.bottom =
getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + getLayout().getLineTop(0);
// Draw the View into the bitmap.
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
destCanvas.scale(getScaleX(), getScaleY(),
(getWidth() + padding) / 2, (getHeight() + padding) / 2);
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
destCanvas.restore();
}
PopupZoomer.java 文件源码
项目:android-chromium
阅读 18
收藏 0
点赞 0
评论 0
/**
* Sets the bitmap to be used for the zoomed view.
*/
public void setBitmap(Bitmap bitmap) {
if (mZoomedBitmap != null) {
mZoomedBitmap.recycle();
mZoomedBitmap = null;
}
mZoomedBitmap = bitmap;
// Round the corners of the bitmap so it doesn't stick out around the overlay.
Canvas canvas = new Canvas(mZoomedBitmap);
Path path = new Path();
RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
float overlayCornerRadius = getOverlayCornerRadius(getContext());
path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
canvas.clipPath(path, Op.XOR);
Paint clearPaint = new Paint();
clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
clearPaint.setColor(Color.TRANSPARENT);
canvas.drawPaint(clearPaint);
}
BubbleTextView.java 文件源码
项目:Fairphone
阅读 29
收藏 0
点赞 0
评论 0
/**
* Draw this BubbleTextView into the given Canvas.
*
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private void drawWithPadding(Canvas destCanvas, int padding) {
final Rect clipRect = mTempRect;
getDrawingRect(clipRect);
// adjust the clip rect so that we don't include the text label
clipRect.bottom =
getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + getLayout().getLineTop(0);
// Draw the View into the bitmap.
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
destCanvas.scale(getScaleX(), getScaleY(),
(getWidth() + padding) / 2, (getHeight() + padding) / 2);
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
destCanvas.restore();
}
PopupZoomer.java 文件源码
项目:chromium_webview
阅读 22
收藏 0
点赞 0
评论 0
/**
* Sets the bitmap to be used for the zoomed view.
*/
public void setBitmap(Bitmap bitmap) {
if (mZoomedBitmap != null) {
mZoomedBitmap.recycle();
mZoomedBitmap = null;
}
mZoomedBitmap = bitmap;
// Round the corners of the bitmap so it doesn't stick out around the overlay.
Canvas canvas = new Canvas(mZoomedBitmap);
Path path = new Path();
RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
float overlayCornerRadius = getOverlayCornerRadius(getContext());
path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
canvas.clipPath(path, Op.XOR);
Paint clearPaint = new Paint();
clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
clearPaint.setColor(Color.TRANSPARENT);
canvas.drawPaint(clearPaint);
}
BubbleTextView.java 文件源码
项目:Fairphone---DEPRECATED
阅读 24
收藏 0
点赞 0
评论 0
/**
* Draw this BubbleTextView into the given Canvas.
*
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private void drawWithPadding(Canvas destCanvas, int padding) {
final Rect clipRect = mTempRect;
getDrawingRect(clipRect);
// adjust the clip rect so that we don't include the text label
clipRect.bottom =
getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + getLayout().getLineTop(0);
// Draw the View into the bitmap.
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
destCanvas.scale(getScaleX(), getScaleY(),
(getWidth() + padding) / 2, (getHeight() + padding) / 2);
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
destCanvas.restore();
}
TextWithLinksContainer.java 文件源码
项目:CustomViews
阅读 19
收藏 0
点赞 0
评论 0
private boolean testTouch() {
mTouchRect.offset(mTouchX, mTouchY);
Iterator<Region> ir = mRegions.iterator();
mSelectedRegion = null;
boolean hit = false;
while (ir.hasNext()) {
Region original = ir.next();
Region region = new Region(original);
if (region.op(mTouchRect, Op.INTERSECT)) {
mSelectedRegion = original;
hit = true;
}
}
mTouchRect.offset(-mTouchX, -mTouchY);
return hit;
}
PopupZoomer.java 文件源码
项目:cordova-android-chromium
阅读 24
收藏 0
点赞 0
评论 0
/**
* Sets the bitmap to be used for the zoomed view.
*/
public void setBitmap(Bitmap bitmap) {
if (mZoomedBitmap != null) {
mZoomedBitmap.recycle();
mZoomedBitmap = null;
}
mZoomedBitmap = bitmap;
// Round the corners of the bitmap so it doesn't stick out around the overlay.
Canvas canvas = new Canvas(mZoomedBitmap);
Path path = new Path();
RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
float overlayCornerRadius = getOverlayCornerRadius(getContext());
path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
canvas.clipPath(path, Op.XOR);
Paint clearPaint = new Paint();
clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
clearPaint.setColor(Color.TRANSPARENT);
canvas.drawPaint(clearPaint);
}
DragPreviewProvider.java 文件源码
项目:LaunchEnr
阅读 25
收藏 0
点赞 0
评论 0
/**
* Draws the {@link #mView} into the given {@param destCanvas}.
*/
private void drawDragView(Canvas destCanvas) {
destCanvas.save();
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
destCanvas.translate(blurSizeOutline / 2 - bounds.left,
blurSizeOutline / 2 - bounds.top);
d.draw(destCanvas);
} else {
final Rect clipRect = mTempRect;
mView.getDrawingRect(clipRect);
boolean textVisible = false;
if (mView instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) mView).getTextVisible()) {
((FolderIcon) mView).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-mView.getScrollX() + blurSizeOutline / 2,
-mView.getScrollY() + blurSizeOutline / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
mView.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) mView).setTextVisible(true);
}
}
destCanvas.restore();
}
OverlayView.java 文件源码
项目:boohee_v5.6
阅读 27
收藏 0
点赞 0
评论 0
protected void drawDimmedLayer(@NonNull Canvas canvas) {
canvas.save();
if (this.mOvalDimmedLayer) {
canvas.clipPath(this.mCircularPath, Op.DIFFERENCE);
} else {
canvas.clipRect(this.mCropViewRect, Op.DIFFERENCE);
}
canvas.drawColor(this.mDimmedColor);
canvas.restore();
if (this.mOvalDimmedLayer) {
canvas.drawOval(this.mCropViewRect, this.mDimmedStrokePaint);
}
}
DragPreviewProvider.java 文件源码
项目:FlickLauncher
阅读 26
收藏 0
点赞 0
评论 0
/**
* Draws the {@link #mView} into the given {@param destCanvas}.
*/
private void drawDragView(Canvas destCanvas) {
destCanvas.save();
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
DRAG_BITMAP_PADDING / 2 - bounds.top);
d.draw(destCanvas);
} else {
final Rect clipRect = mTempRect;
mView.getDrawingRect(clipRect);
boolean textVisible = false;
if (mView instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) mView).getTextVisible()) {
((FolderIcon) mView).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
-mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
mView.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) mView).setTextVisible(true);
}
}
destCanvas.restore();
}
DragPreviewProvider.java 文件源码
项目:SimpleUILauncher
阅读 23
收藏 0
点赞 0
评论 0
/**
* Draws the {@link #mView} into the given {@param destCanvas}.
*/
private void drawDragView(Canvas destCanvas) {
destCanvas.save();
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
DRAG_BITMAP_PADDING / 2 - bounds.top);
d.draw(destCanvas);
} else {
final Rect clipRect = mTempRect;
mView.getDrawingRect(clipRect);
boolean textVisible = false;
if (mView instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) mView).getTextVisible()) {
((FolderIcon) mView).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
-mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
mView.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) mView).setTextVisible(true);
}
}
destCanvas.restore();
}
Workspace.java 文件源码
项目:SimplOS
阅读 32
收藏 0
点赞 0
评论 0
/**
* Draw the View v into the given Canvas.
*
* @param v the view to draw
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private static void drawDragView(View v, Canvas destCanvas, int padding) {
final Rect clipRect = sTempRect;
v.getDrawingRect(clipRect);
boolean textVisible = false;
destCanvas.save();
if (v instanceof TextView) {
Drawable d = getTextViewIcon((TextView) v);
Rect bounds = getDrawableBounds(d);
clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding);
destCanvas.translate(padding / 2 - bounds.left, padding / 2 - bounds.top);
d.draw(destCanvas);
} else {
if (v instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) v).getTextVisible()) {
((FolderIcon) v).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-v.getScrollX() + padding / 2, -v.getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
v.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) v).setTextVisible(true);
}
}
destCanvas.restore();
}
Selection.java 文件源码
项目:PaintPlusPlus
阅读 34
收藏 0
点赞 0
评论 0
void commitSelectionRectangle(Rect rect, Op op)
{
ActionSelectionChange action = new ActionSelectionChange(image);
action.setOldRegion();
region.op(rect, op);
updatePath();
action.applyAction();
}
CircleLayout.java 文件源码
项目:Madad_SOS
阅读 22
收藏 0
点赞 0
评论 0
private void drawChild(Canvas canvas, View child, LayoutParams lp) {
mSrcCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
mDstCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
mSrcCanvas.save();
int childLeft = child.getLeft();
int childTop = child.getTop();
int childRight = child.getRight();
int childBottom = child.getBottom();
mSrcCanvas.clipRect(childLeft, childTop, childRight, childBottom, Op.REPLACE);
mSrcCanvas.translate(childLeft, childTop);
child.draw(mSrcCanvas);
mSrcCanvas.restore();
mXferPaint.setXfermode(null);
mXferPaint.setColor(Color.BLACK);
float sweepAngle = (lp.endAngle - lp.startAngle) % 361;
mDstCanvas.drawArc(mBounds, lp.startAngle, sweepAngle, true, mXferPaint);
mXferPaint.setXfermode(mXfer);
mDstCanvas.drawBitmap(mSrc, 0f, 0f, mXferPaint);
canvas.drawBitmap(mDst, 0f, 0f, null);
}
Workspace.java 文件源码
项目:Trebuchet
阅读 35
收藏 0
点赞 0
评论 0
/**
* Draw the View v into the given Canvas.
*
* @param v the view to draw
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private static void drawDragView(View v, Canvas destCanvas, int padding) {
final Rect clipRect = sTempRect;
v.getDrawingRect(clipRect);
boolean textVisible = false;
destCanvas.save();
if (v instanceof TextView) {
Drawable d = getTextViewIcon((TextView) v);
Rect bounds = getDrawableBounds(d);
clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding);
destCanvas.translate(padding / 2 - bounds.left, padding / 2 - bounds.top);
d.draw(destCanvas);
} else {
if (v instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) v).getTextVisible()) {
((FolderIcon) v).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-v.getScrollX() + padding / 2, -v.getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
v.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) v).setTextVisible(true);
}
}
destCanvas.restore();
}
ShowcaseView.java 文件源码
项目:DVBViewerController
阅读 27
收藏 0
点赞 0
评论 0
@Override
protected void dispatchDraw(Canvas canvas) {
if (showcaseX < 0 || showcaseY < 0 || isRedundant) {
super.dispatchDraw(canvas);
return;
}
boolean recalculatedCling = mShowcaseDrawer.calculateShowcaseRect(showcaseX, showcaseY);
boolean recalculateText = recalculatedCling || mAlteredText;
mAlteredText = false;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && !mHasNoTarget) {
Path path = new Path();
path.addCircle(showcaseX, showcaseY, showcaseRadius, Path.Direction.CW);
canvas.clipPath(path, Op.DIFFERENCE);
}
//Draw background color
canvas.drawColor(mBackgroundColor);
// Draw the showcase drawable
if (!mHasNoTarget) {
mShowcaseDrawer.drawShowcase(canvas, showcaseX, showcaseY, scaleMultiplier, showcaseRadius);
}
// Draw the text on the screen, recalculating its position if necessary
if (recalculateText) {
mTextDrawer.calculateTextPosition(canvas.getWidth(), canvas.getHeight(), this);
}
mTextDrawer.draw(canvas, recalculateText);
super.dispatchDraw(canvas);
}
ShowcaseView.java 文件源码
项目:WeiboWeiBaTong
阅读 25
收藏 0
点赞 0
评论 0
@Override
protected void dispatchDraw(Canvas canvas) {
if (showcaseX < 0 || showcaseY < 0 || isRedundant) {
super.dispatchDraw(canvas);
return;
}
boolean recalculatedCling = mShowcaseDrawer.calculateShowcaseRect(showcaseX, showcaseY);
boolean recalculateText = recalculatedCling || mAlteredText;
mAlteredText = false;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && !mHasNoTarget) {
Path path = new Path();
path.addCircle(showcaseX, showcaseY, showcaseRadius, Path.Direction.CW);
canvas.clipPath(path, Op.DIFFERENCE);
}
//Draw background color
canvas.drawColor(mBackgroundColor);
// Draw the showcase drawable
if (!mHasNoTarget) {
mShowcaseDrawer
.drawShowcase(canvas, showcaseX, showcaseY, scaleMultiplier, showcaseRadius);
}
// Draw the text on the screen, recalculating its position if necessary
if (recalculateText) {
mTextDrawer.calculateTextPosition(canvas.getWidth(), canvas.getHeight(), this);
}
mTextDrawer.draw(canvas, recalculateText);
super.dispatchDraw(canvas);
}
Subpatch.java 文件源码
项目:PdDroidPublisher
阅读 18
收藏 0
点赞 0
评论 0
protected void drawSubpatchContent(Canvas canvas)
{
canvas.save();
Matrix matrix = new Matrix();
matrix.postTranslate(x - HMargin, y - VMargin);
canvas.concat(matrix);
canvas.clipRect(new RectF(HMargin, VMargin, HMargin + dRect.width(), VMargin + dRect.height()), Op.INTERSECT);
for(Widget widget : widgets)
{
widget.draw(canvas);
}
canvas.restore();
}
Slider.java 文件源码
项目:PdDroidPublisher
阅读 26
收藏 0
点赞 0
评论 0
public void draw(Canvas canvas) {
canvas.save();
canvas.clipRect(dRect.left, dRect.top, dRect.right, dRect.bottom + 1, Op.INTERSECT);
if (bg.draw(canvas)) {
paint.setColor(bgcolor);
paint.setStyle(Paint.Style.FILL);
canvas.drawRect(dRect,paint);
paint.setColor(fgcolor);
paint.setStrokeWidth(1);
canvas.drawLine(dRect.left /*+ 1*/, dRect.top, dRect.right, dRect.top, paint);
canvas.drawLine(dRect.left /*+ 1*/, dRect.bottom, dRect.right, dRect.bottom, paint);
canvas.drawLine(dRect.left, dRect.top /*+ 1*/, dRect.left, dRect.bottom, paint);
canvas.drawLine(dRect.right, dRect.top /*+ 1*/, dRect.right, dRect.bottom, paint);
paint.setColor(fgcolor);
paint.setStrokeWidth(3);
if (horizontal) {
canvas.drawLine(Math.round(dRect.left + getNormalizedPosition() * dRect.width()), Math.round(dRect.top /*+ 2*/), Math.round(dRect.left + getNormalizedPosition() * dRect.width()), Math.round(dRect.bottom /*- 2*/), paint);
} else {
canvas.drawLine(Math.round(dRect.left /*+ 2*/), Math.round(dRect.bottom - getNormalizedPosition() * dRect.height()), Math.round(dRect.right /*- 2*/), Math.round(dRect.bottom - getNormalizedPosition() * dRect.height()), paint);
}
} else if (!slider.none()) {
if (horizontal) {
sRect.offsetTo(getNormalizedPosition() * (dRect.width() - sRect.width()) + dRect.left, dRect.top);
} else {
sRect.offsetTo(dRect.left, (1 - getNormalizedPosition()) * (dRect.height() - sRect.height()) + dRect.top);
}
slider.draw(canvas,sRect);
fg.draw(canvas);
}
canvas.restore();
drawLabel(canvas);
}
Workspace.java 文件源码
项目:FLauncher
阅读 28
收藏 0
点赞 0
评论 0
/**
* Draw the View v into the given Canvas.
*
* @param v the view to draw
* @param destCanvas the canvas to draw on
* @param padding the horizontal and vertical padding to use when drawing
*/
private static void drawDragView(View v, Canvas destCanvas, int padding) {
final Rect clipRect = sTempRect;
v.getDrawingRect(clipRect);
boolean textVisible = false;
destCanvas.save();
if (v instanceof TextView) {
Drawable d = getTextViewIcon((TextView) v);
Rect bounds = getDrawableBounds(d);
clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding);
destCanvas.translate(padding / 2 - bounds.left, padding / 2 - bounds.top);
d.draw(destCanvas);
} else {
if (v instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) v).getTextVisible()) {
((FolderIcon) v).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-v.getScrollX() + padding / 2, -v.getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
v.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) v).setTextVisible(true);
}
}
destCanvas.restore();
}
ClipImageBorderView.java 文件源码
项目:dedecmsapp
阅读 17
收藏 0
点赞 0
评论 0
/**
* 画圆形窗口
*
* @param canvas
* @param view
* @return
*/
private Canvas drawCircleWingdow(Canvas canvas, View view) {
canvas.save();
Path path = new Path();
// 计算矩形区域的宽度
int witdh = getClipWindowWidth();
// 中心坐标
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
// 半径
int radius = witdh / 2;
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#aa000000"));
paint.setStyle(Style.FILL);
Rect viewDrawingRect = new Rect();
view.getDrawingRect(viewDrawingRect);
path.addCircle(centerX, centerY, radius, Direction.CW);
// 画外边
canvas.clipPath(path, Op.DIFFERENCE);
canvas.drawRect(viewDrawingRect, paint);
// TODO 绘制外边框
// 绘制外边框
// canvas.restore();
// canvas.clipPath(path,Op.INTERSECT);
// paint.setColor(mBorderColor);
// paint.setStrokeWidth(mBorderWidth);
// paint.setStyle(Style.STROKE);
// canvas.drawRect(viewDrawingRect, paint);
canvas.restore();
return canvas;
}
SVGParser.java 文件源码
项目:svg-android-2
阅读 26
收藏 0
点赞 0
评论 0
private void doBitmap(Canvas canvas, float x, float y, float width, float height, byte[] bytes) {
Bitmap bm = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
if (bm != null) {
// Log.d(TAG, String.format("Image %f x %f %s", width, height, bm));
bm.prepareToDraw();
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
RectF rect = new RectF(x, y, x+width, y+height);
canvas.clipRect(rect, Op.REPLACE);
canvas.drawBitmap(bm, null, rect, paint);
bm.recycle();
}
}