Java 类android.graphics.Path.Direction 实例源码
项目:FiveMinsMore
文件:ClockDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
rimRadius = Math.min(bounds.width(), bounds.height()) / 2f - rimPaint.getStrokeWidth();
faceRadius = rimRadius - rimPaint.getStrokeWidth();
screwRadius = rimPaint.getStrokeWidth() * 2;
float hourHandLength = (float) (0.5 * faceRadius);
float minuteHandLength = (float) (0.7 * faceRadius);
float top = bounds.centerY() - screwRadius;
hourHandPath.reset();
hourHandPath.moveTo(bounds.centerX(), bounds.centerY());
hourHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - hourHandLength, Direction.CCW);
hourHandPath.close();
minuteHandPath.reset();
minuteHandPath.moveTo(bounds.centerX(), bounds.centerY());
minuteHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - minuteHandLength, Direction.CCW);
minuteHandPath.close();
}
项目:boohee_v5.6
文件:OverlayView.java
public void setupCropBounds() {
int height = (int) (((float) this.mThisWidth) / this.mTargetAspectRatio);
int halfDiff;
if (height > this.mThisHeight) {
int width = (int) (((float) this.mThisHeight) * this.mTargetAspectRatio);
halfDiff = (this.mThisWidth - width) / 2;
this.mCropViewRect.set((float) (getPaddingLeft() + halfDiff), (float) getPaddingTop()
, (float) ((getPaddingLeft() + width) + halfDiff), (float) (getPaddingTop() +
this.mThisHeight));
} else {
halfDiff = (this.mThisHeight - height) / 2;
this.mCropViewRect.set((float) getPaddingLeft(), (float) (getPaddingTop() + halfDiff)
, (float) (getPaddingLeft() + this.mThisWidth), (float) ((getPaddingTop() +
height) + halfDiff));
}
this.mGridPoints = null;
this.mCircularPath.reset();
this.mCircularPath.addOval(this.mCropViewRect, Direction.CW);
}
项目:boohee_v5.6
文件:MaterialRippleLayout.java
public void draw(Canvas canvas) {
boolean positionChanged = adapterPositionChanged();
if (this.rippleOverlay) {
if (!positionChanged) {
this.rippleBackground.draw(canvas);
}
super.draw(canvas);
if (!positionChanged) {
if (this.rippleRoundedCorners != 0.0f) {
Path clipPath = new Path();
clipPath.addRoundRect(new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), this.rippleRoundedCorners, this.rippleRoundedCorners, Direction.CW);
canvas.clipPath(clipPath);
}
canvas.drawCircle((float) this.currentCoords.x, (float) this.currentCoords.y, this.radius, this.paint);
return;
}
return;
}
if (!positionChanged) {
this.rippleBackground.draw(canvas);
canvas.drawCircle((float) this.currentCoords.x, (float) this.currentCoords.y, this.radius, this.paint);
}
super.draw(canvas);
}
项目:boohee_v5.6
文件:CircleIndicator.java
private void drawOutSideText(Canvas canvas) {
Paint textPaint = new Paint();
textPaint.setColor(this.mNormalGray);
textPaint.setAntiAlias(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.out_indicator_size));
int radius = getViewRadius() - this.mDividerWidth;
Path path = new Path();
path.addCircle((float) getCenterX(), (float) getCenterY(), (float) radius, Direction.CW);
if (this.mDividerIndicator.size() != 0) {
String content = BaseCircle.formatNumber(this.mStartIndicator);
canvas.drawTextOnPath(content, path, ViewUtils.getCirclePathLength((float) radius,
135.0f) - ((float) (ViewUtils.getTextWidth(textPaint, content) / 2)), 0.0f,
textPaint);
float perAngle = 270.0f / (this.mEndIndicator - this.mStartIndicator);
for (IndicatorItem item : this.mDividerIndicator) {
content = BaseCircle.formatNumber(item.end);
canvas.drawTextOnPath(content, path, ViewUtils.getCirclePathLength((float)
radius, ((item.end - this.mStartIndicator) * perAngle) + 135.0f) - (
(float) (ViewUtils.getTextWidth(textPaint, content) / 2)), 0.0f, textPaint);
}
}
}
项目:okwallet
文件:CircularProgressView.java
private void updatePath(final int w, final int h) {
final float maxAbsSize = Math.min(w, h) / 2f;
final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;
path.reset();
if (progress == 0) {
path.close();
} else if (progress < maxProgress) {
final float angle = progress * 360 / maxProgress;
final float x = w / 2f;
final float y = h / 2f;
path.moveTo(x, y);
path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
path.close();
} else {
path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
}
}
项目:MDPreference
文件:RippleDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
if(mBackgroundDrawable != null)
mBackgroundDrawable.setBounds(bounds);
mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
mBackground.reset();
switch (mMask.type) {
case Mask.TYPE_OVAL:
mBackground.addOval(mBackgroundBounds, Direction.CW);
break;
case Mask.TYPE_RECTANGLE:
mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
break;
}
}
项目:ClockDrawableAnimation
文件:ClockDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
rimRadius = Math.min(bounds.width(), bounds.height()) / 2f - rimPaint.getStrokeWidth();
faceRadius = rimRadius - rimPaint.getStrokeWidth();
screwRadius = rimPaint.getStrokeWidth() * 2;
float hourHandLength = (float) (0.5 * faceRadius);
float minuteHandLength = (float) (0.7 * faceRadius);
float top = bounds.centerY() - screwRadius;
hourHandPath.reset();
hourHandPath.moveTo(bounds.centerX(), bounds.centerY());
hourHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - hourHandLength, Direction.CCW);
hourHandPath.close();
minuteHandPath.reset();
minuteHandPath.moveTo(bounds.centerX(), bounds.centerY());
minuteHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - minuteHandLength, Direction.CCW);
minuteHandPath.close();
}
项目:iOffice
文件:SmartArtPathBuilder.java
private static Path getFunnelPath(AutoShape shape, Rect rect)
{
float width = 716f;
float height = 536f;
path.addOval(new RectF(28, 22, 688, 238), Direction.CCW);
path.moveTo(0, 130);
path.arcTo(new RectF(0, 0, 716, 260), 180, 180);
path.arcTo(new RectF(258, 444, 458, 536), 30, 150);
path.close();
sm.reset();
sm.postScale(rect.width() / width, rect.height() / height);
path.transform(sm);
path.offset(rect.left, rect.top);
return path;
}
项目:iOffice
文件:BaseShapePathBuilder.java
private static Path getFramePath(AutoShape shape, Rect rect)
{
float x = Math.min(rect.height(), rect.width()) * 0.1f;
Float[] values = shape.getAdjustData();
if (values != null && values.length >= 1)
{
if (values[0] != null)
{
x = Math.min(rect.height(), rect.width()) * values[0];
}
}
rectF.set(rect.left, rect.top, rect.right, rect.bottom);
path.addRect(rectF, Path.Direction.CW);
rectF.set(rect.left + x, rect.top + x, rect.right - x, rect.bottom - x);
path.addRect(rectF, Path.Direction.CCW);
return path;
}
项目:ombuds-android
文件:CircularProgressView.java
private void updatePath(final int w, final int h)
{
final float maxAbsSize = Math.min(w, h) / 2f;
final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;
path.reset();
if (progress == 0)
{
path.close();
}
else if (progress < maxProgress)
{
final float angle = progress * 360 / maxProgress;
final float x = w / 2f;
final float y = h / 2f;
path.moveTo(x, y);
path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
path.close();
}
else
{
path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
}
}
项目:material-master
文件:RippleDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
if(mBackgroundDrawable != null)
mBackgroundDrawable.setBounds(bounds);
mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
mBackground.reset();
switch (mMask.type) {
case Mask.TYPE_OVAL:
mBackground.addOval(mBackgroundBounds, Direction.CW);
break;
case Mask.TYPE_RECTANGLE:
mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
break;
}
}
项目:material_fork
文件:RippleDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
if(mBackgroundDrawable != null)
mBackgroundDrawable.setBounds(bounds);
mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
mBackground.reset();
switch (mMask.type) {
case Mask.TYPE_OVAL:
mBackground.addOval(mBackgroundBounds, Direction.CW);
break;
case Mask.TYPE_RECTANGLE:
mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
break;
}
}
项目:365browser
文件:PopupZoomer.java
/**
* 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);
}
项目:Bound
文件:RippleDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
if(mBackgroundDrawable != null)
mBackgroundDrawable.setBounds(bounds);
mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
mBackground.reset();
switch (mMask.type) {
case Mask.TYPE_OVAL:
mBackground.addOval(mBackgroundBounds, Direction.CW);
break;
case Mask.TYPE_RECTANGLE:
mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
break;
}
}
项目:Material-Components
文件:RippleDrawable.java
@Override
protected void onBoundsChange(Rect bounds) {
if(mBackgroundDrawable != null)
mBackgroundDrawable.setBounds(bounds);
mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
mBackground.reset();
switch (mMask.type) {
case Mask.TYPE_OVAL:
mBackground.addOval(mBackgroundBounds, Direction.CW);
break;
case Mask.TYPE_RECTANGLE:
mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
break;
}
}
项目:bither-android
文件:CircularProgressView.java
private void updatePath(final int w, final int h) {
final float maxAbsSize = Math.min(w, h) / 2f;
final float absSize = size < maxSize ? maxAbsSize * size / maxSize
: maxAbsSize - 1;
path.reset();
if (progress == 0) {
path.close();
} else if (progress < maxProgress) {
final float angle = progress * 360 / maxProgress;
final float x = w / 2f;
final float y = h / 2f;
path.moveTo(x, y);
path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y
+ absSize), 270, angle);
path.close();
} else {
path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
}
}
项目:RoundedImageView
文件:RoundedImageView.java
@Override
protected void onDraw(Canvas canvas) {
float borderWidth = this.borderWidth;
float roundWidth = this.roundWidth;
if (borderWidth < 0) {
borderWidth = ( getWidth() + getHeight() ) * .02f;
}
paint.setStrokeWidth( borderWidth );
if (roundWidth < 0) {
roundWidth = borderWidth * 2;
}
drawPath.reset();
// drawRect.set( 0 + roundWidth / 2, 0 + roundWidth / 2, getWidth() - roundWidth / 2, getHeight() - roundWidth / 2 );
drawRect.set( 0 + borderWidth / 2, 0 + borderWidth / 2, getWidth() - borderWidth / 2, getHeight() - borderWidth / 2 );
drawPath.addRoundRect( drawRect, roundWidth, roundWidth, Direction.CCW );
canvas.save();
canvas.clipPath( drawPath );
super.onDraw( canvas );
canvas.restore();
canvas.drawRoundRect( drawRect, roundWidth, roundWidth, paint );
}
项目:EffectiveAndroid
文件:DrawPathDemoActivity.java
@Override
public void onDraw(Canvas canvas) {
if (mCenter == null) {
mCenter = new Point(getWidth()/2, getHeight()/2);
}
canvas.drawColor(Color.CYAN);
float left = mCenter.x;
float top = mCenter.y;
float radius = 200;
Path p = new Path();
p.addRect(left, top, left+radius, top+radius, Direction.CW);
p.addCircle(mCenter.x, mCenter.y, radius, Direction.CW);
p.lineTo(mCenter.x + 2*radius, mCenter.y+2*radius);
p.close();
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setAntiAlias(true);
// paint.setStyle(Style.FILL_AND_STROKE);
canvas.drawPath(p, paint);
}
项目:templecoin-android-wallet
文件:CircularProgressView.java
private void updatePath(final int w, final int h)
{
final float maxAbsSize = Math.min(w, h) / 2f;
final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;
path.reset();
if (progress == 0)
{
path.close();
}
else if (progress < maxProgress)
{
final float angle = progress * 360 / maxProgress;
final float x = w / 2f;
final float y = h / 2f;
path.moveTo(x, y);
path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
path.close();
}
else
{
path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
}
}
项目:android-chromium-view
文件:PopupZoomer.java
/**
* 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);
}
项目:android-chromium
文件:PopupZoomer.java
/**
* 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);
}
项目:chromium_webview
文件:PopupZoomer.java
/**
* 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);
}
项目:FaceBarCodeDemo
文件:QRCodeGenerator.java
private void drawRoundRect(Canvas canvas, RectF rect, Paint paint,
int radius, boolean leftTop, boolean rightTop, boolean leftBottom,
boolean rightBottom) {
float roundRadius[] = new float[8];
roundRadius[0] = leftTop ? 0 : radius;
roundRadius[1] = leftTop ? 0 : radius;
roundRadius[2] = rightTop ? 0 : radius;
roundRadius[3] = rightTop ? 0 : radius;
roundRadius[4] = rightBottom ? 0 : radius;
roundRadius[5] = rightBottom ? 0 : radius;
roundRadius[6] = leftBottom ? 0 : radius;
roundRadius[7] = leftBottom ? 0 : radius;
Path path = new Path();
path.addRoundRect(rect, roundRadius, Direction.CCW);
canvas.drawPath(path, paint);
}
项目:goldcoin-android
文件:CircularProgressView.java
private void updatePath(final int w, final int h)
{
final float maxAbsSize = Math.min(w, h) / 2f;
final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;
path.reset();
if (progress == 0)
{
path.close();
}
else if (progress < maxProgress)
{
final float angle = progress * 360 / maxProgress;
final float x = w / 2f;
final float y = h / 2f;
path.moveTo(x, y);
path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
path.close();
}
else
{
path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
}
}
项目:cordova-android-chromium
文件:PopupZoomer.java
/**
* 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);
}
项目:NoticeDog
文件:CircleBackgroundMask.java
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
float dy = ((float) h) - 2.0f;
float dx = (float) w;
float padding = (float) getPaddingLeft();
this.clipPath.reset();
this.clipPath.addCircle(dx / 2.0f, dy / 2.0f, (dx / 2.0f) - padding, Direction.CW);
this.clipPath.close();
}
项目:Tribe
文件:RoundImageView.java
@Override
public void buildBoundPath(Path boundPath){
boundPath.reset();
final int width = getWidth();
final int height = getHeight();
radius = Math.min(radius, Math.min(width, height) * 0.5f);
RectF rect = new RectF(0, 0, width, height);
boundPath.addRoundRect(rect , radius, radius, Direction.CW);
}
项目:Tribe
文件:RoundImageView.java
@Override
public void buildBorderPath(Path borderPath) {
borderPath.reset();
final float halfBorderWidth = getBorderWidth() * 0.5f;
final int width = getWidth();
final int height = getHeight();
radius = Math.min(radius, Math.min(width, height) * 0.5f);
RectF rect = new RectF(halfBorderWidth, halfBorderWidth,
width - halfBorderWidth, height - halfBorderWidth);
borderPath.addRoundRect(rect , radius, radius, Direction.CW);
}
项目:boohee_v5.6
文件:SelectableRoundedImageView.java
public void draw(Canvas canvas) {
canvas.save();
if (!this.mBoundsConfigured) {
configureBounds(canvas);
if (this.mBorderWidth > 0.0f) {
adjustBorderWidthAndBorderBounds(canvas);
setBorderRadii();
}
this.mBoundsConfigured = true;
}
if (this.mOval) {
if (this.mBorderWidth > 0.0f) {
adjustCanvasForBorder(canvas);
this.mPath.addOval(this.mBounds, Direction.CW);
canvas.drawPath(this.mPath, this.mBitmapPaint);
this.mPath.reset();
this.mPath.addOval(this.mBorderBounds, Direction.CW);
canvas.drawPath(this.mPath, this.mBorderPaint);
} else {
this.mPath.addOval(this.mBounds, Direction.CW);
canvas.drawPath(this.mPath, this.mBitmapPaint);
}
} else if (this.mBorderWidth > 0.0f) {
adjustCanvasForBorder(canvas);
this.mPath.addRoundRect(this.mBounds, this.mRadii, Direction.CW);
canvas.drawPath(this.mPath, this.mBitmapPaint);
this.mPath.reset();
this.mPath.addRoundRect(this.mBorderBounds, this.mBorderRadii, Direction.CW);
canvas.drawPath(this.mPath, this.mBorderPaint);
} else {
this.mPath.addRoundRect(this.mBounds, this.mRadii, Direction.CW);
canvas.drawPath(this.mPath, this.mBitmapPaint);
}
canvas.restore();
}
项目:boohee_v5.6
文件:BaseCircle.java
protected void drawBackground(Canvas canvas) {
Paint bgPaint = new Paint();
bgPaint.setColor(this.mCircleBackground);
int radius = getViewRadius() - ((this.mDividerWidth * 3) / 2);
canvas.drawCircle((float) getCenterX(), (float) getCenterY(), (float) radius, bgPaint);
Path path = new Path();
path.addCircle((float) getCenterX(), (float) getCenterY(), (float) radius, Direction.CW);
Paint paint = new Paint();
paint.setColor(this.mCircleGray);
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(1.0f);
canvas.drawPath(path, paint);
}
项目:boohee_v5.6
文件:CircleIndicator.java
private void drawCircle(Canvas canvas) {
Paint textPaint = new Paint();
textPaint.setColor(this.mCircleWhite);
textPaint.setAntiAlias(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.out_indicator_size));
float textHeight = (float) ViewUtils.getTextHeight(textPaint);
float perAngle = 270.0f / (this.mEndIndicator - this.mStartIndicator);
int radius = (int) (((float) getViewRadius()) - (2.6f * ((float) this.mDividerWidth)));
FontMetricsInt fmi = textPaint.getFontMetricsInt();
float textRadius = (float) (radius - (Math.abs(fmi.bottom + fmi.top) / 2));
RectF oval = new RectF((float) (getCenterX() - radius), (float) (getCenterY() - radius),
(float) (getCenterX() + radius), (float) (getCenterY() + radius));
Path path = new Path();
path.addCircle((float) getCenterX(), (float) getCenterY(), textRadius, Direction.CW);
Paint circlePaint = new Paint();
circlePaint.setAntiAlias(true);
circlePaint.setStrokeWidth(16.0f + textHeight);
circlePaint.setStyle(Style.STROKE);
if (this.mDividerIndicator.size() == 0) {
circlePaint.setStrokeCap(Cap.ROUND);
circlePaint.setColor(this.mCircleGray);
canvas.drawArc(oval, 135.0f, 270.0f, false, circlePaint);
return;
}
circlePaint.setStrokeCap(Cap.ROUND);
drawCircleContent(canvas, (IndicatorItem) this.mDividerIndicator.get(0), oval, perAngle,
textRadius, path, textPaint, circlePaint);
Canvas canvas2 = canvas;
drawCircleContent(canvas2, (IndicatorItem) this.mDividerIndicator.get(this
.mDividerIndicator.size() - 1), oval, perAngle, textRadius, path, textPaint,
circlePaint);
circlePaint.setStrokeCap(Cap.BUTT);
for (int i = 1; i < this.mDividerIndicator.size() - 1; i++) {
drawCircleContent(canvas, (IndicatorItem) this.mDividerIndicator.get(i), oval,
perAngle, textRadius, path, textPaint, circlePaint);
}
}
项目:BubblePopupWindow
文件:BubbleRelativeLayout.java
@Override
protected void onDraw(Canvas canvas) {
final float width = canvas.getWidth();
final float height = canvas.getHeight();
mPath.rewind();
mPath.addRoundRect(new RectF(PADDING, PADDING, width - PADDING, height - PADDING), CORNER_RADIUS, CORNER_RADIUS, Direction.CW);
mPath.addPath(mBubbleLegPrototype, renderBubbleLegMatrix(width, height));
canvas.drawPath(mPath, mPaint);
canvas.scale((width - STROKE_WIDTH) / width, (height - STROKE_WIDTH) / height, width / 2f, height / 2f);
canvas.drawPath(mPath, mFillPaint);
}
项目:memoir
文件:BulletSpan.java
private void draw(Canvas c, Paint p, int x, int dir, int top, int bottom, int size) {
sBulletPath.reset();
sBulletPath.addCircle(0.0f, 0.0f, size, Direction.CW);
c.save();
c.translate(x + dir * size, (top + bottom) / 2.0f);
c.drawPath(sBulletPath, p);
c.restore();
}
项目:memoir
文件:BulletSpan.java
private void draw(Canvas c, Paint p, int x, int dir, int top, int bottom, int size) {
sBulletPath.reset();
sBulletPath.addCircle(0.0f, 0.0f, size, Direction.CW);
c.save();
c.translate(x + dir * size, (top + bottom) / 2.0f);
c.drawPath(sBulletPath, p);
c.restore();
}
项目:PowerToggles
文件:FolderIconCreater.java
public FolderIconCreater(Context c) {
mRes = c.getResources();
mSize = BitmapUtils.getActivityIconSize(c);
mIconSize = mSize * 3 / 5;
mRoundRect = new Path();
float gap = (mSize - mIconSize) * 0.25f;
mRoundRect.addRoundRect(new RectF(gap, gap, mSize - gap, mSize - gap), gap / 2, gap / 2, Direction.CW);
// Init variables
// cos(45) = 0.707 + ~= 0.1) = 0.8f
mBaselineIconScale = (1 + 0.8f) / (2 * (1 + PERSPECTIVE_SHIFT_FACTOR));
mBaselineIconSize = (int) (mSize * mBaselineIconScale);
mMaxPerspectiveShift = mBaselineIconSize * PERSPECTIVE_SHIFT_FACTOR;
}
项目:material-components-android
文件:CircularRevealHelper.java
private void invalidateRevealInfo() {
if (STRATEGY == CLIP_PATH) {
revealPath.rewind();
if (revealInfo != null) {
revealPath.addCircle(
revealInfo.centerX, revealInfo.centerY, revealInfo.radius, Direction.CW);
}
}
view.invalidate();
}
项目:iOffice
文件:XYChart.java
protected void drawSeriesBackgroundAndFrame(XYMultipleSeriesRenderer renderer, Canvas canvas, Rect rect, Paint paint)
{
int alpha = paint.getAlpha();
Path path = new Path();
path.addRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom, Direction.CCW);
// draw fill
BackgroundAndFill fill = renderer.getSeriesBackgroundColor();
if (fill != null)
{
paint.setStyle(Style.FILL);
BackgroundDrawer.drawPathBackground(canvas, null, 1, fill, rect, null, 1.0f, path, paint);
paint.setAlpha(alpha);
}
// draw border
Line frame = renderer.getSeriesFrame();
if (frame != null)
{
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
if(frame.isDash())
{
DashPathEffect dashPathEffect = new DashPathEffect(new float[] {5, 5}, 10);
paint.setPathEffect(dashPathEffect);
}
BackgroundDrawer.drawPathBackground(canvas, null, 1, frame.getBackgroundAndFill(), rect, null, 1.0f, path, paint);
paint.setStyle(Style.FILL);
paint.setAlpha(alpha);
}
paint.reset();
paint.setAntiAlias(true);
}
项目:iOffice
文件:AbstractChart.java
/**
* Draws the chart background.
*
* @param renderer the chart renderer
* @param canvas the canvas to paint to
* @param x the top left x value of the view to draw to
* @param y the top left y value of the view to draw to
* @param width the width of the view to draw to
* @param height the height of the view to draw to
* @param paint the paint used for drawing
* @param newColor if a new color is to be used
* @param color the color to be used
*/
protected void drawBackgroundAndFrame(DefaultRenderer renderer, Canvas canvas, IControl control, Rect rect, Paint paint)
{
int alpha = paint.getAlpha();
Path path = new Path();
path.addRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom, Direction.CCW);
// draw fill
BackgroundAndFill fill = renderer.getBackgroundAndFill();
if (fill != null)
{
paint.setStyle(Style.FILL);
BackgroundDrawer.drawPathBackground(canvas, control, 1, fill, rect, null, 1.0f, path, paint);
paint.setAlpha(alpha);
}
// draw border
Line frame = renderer.getChartFrame();
if (frame != null)
{
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
if(frame.isDash())
{
DashPathEffect dashPathEffect = new DashPathEffect(new float[] {5, 5}, 10);
paint.setPathEffect(dashPathEffect);
}
BackgroundDrawer.drawPathBackground(canvas, null, 1, frame.getBackgroundAndFill(), rect, null, 1.0f, path, paint);
paint.setStyle(Style.FILL);
paint.setAlpha(alpha);
}
paint.reset();
paint.setAntiAlias(true);
}
项目:iOffice
文件:WedgeCalloutDrawing.java
/**
* 线性标注1
* @param canvas
* @param shape
* @param rect
*/
private static Path getBorderCallout1Path(AutoShape shape, Rect rect)
{
float y1 = rect.top + rect.height() * 0.1875f;
float x1 = rect.left + rect.width() * (-0.08333f);
float y2 = rect.top + rect.height() * 1.125f;
float x2 = rect.left + rect.width() * (-0.38333f);
Float[] values = shape.getAdjustData();
if (values != null && values.length >= 4)
{
if (values[0] != null)
{
y1 = rect.top + rect.height() * values[0];
}
if (values[1] != null)
{
x1 = rect.left + rect.width() * values[1];
}
if (values[2] != null)
{
y2 = rect.top + rect.height() * values[2];
}
if (values[3] != null)
{
x2 = rect.left + rect.width() * values[3];
}
}
path.addRect(rect.left, rect.top, rect.right, rect.bottom, Path.Direction.CW);
path.moveTo(x1, y1);
path.lineTo(x2, y2);
return path;
}
项目:iOffice
文件:WedgeCalloutDrawing.java
/**
* 线性标注1(带边框和强调线)
* @param canvas
* @param shape
* @param rect
*/
private static Path getAccentBorderCallout1(AutoShape shape, Rect rect)
{
float y1 = rect.top + rect.height() * 0.1875f;
float x1 = rect.left + rect.width() * (-0.08333f);
float y2 = rect.top + rect.height() * 1.125f;
float x2 = rect.left + rect.width() * (-0.38333f);
Float[] values = shape.getAdjustData();
if (values != null && values.length >= 4)
{
if (values[0] != null)
{
y1 = rect.top + rect.height() * values[0];
}
if (values[1] != null)
{
x1 = rect.left + rect.width() * values[1];
}
if (values[2] != null)
{
y2 = rect.top + rect.height() * values[2];
}
if (values[3] != null)
{
x2 = rect.left + rect.width() * values[3];
}
}
path.addRect(rect.left, rect.top, rect.right, rect.bottom, Path.Direction.CW);
path.moveTo(x1, rect.top);
path.lineTo(x1, rect.bottom);
path.moveTo(x1, y1);
path.lineTo(x2, y2);
return path;
}