use of android.graphics.Path in project Carbon by ZieIony.
the class FlowLayout method initCorners.
private void initCorners() {
if (cornerRadius > 0) {
cornerRadius = Math.min(cornerRadius, Math.min(getWidth(), getHeight()) / 2.0f);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setClipToOutline(true);
setOutlineProvider(ShadowShape.viewOutlineProvider);
} else {
cornersMask = new Path();
cornersMask.addRoundRect(new RectF(0, 0, getWidth(), getHeight()), cornerRadius, cornerRadius, Path.Direction.CW);
cornersMask.setFillType(Path.FillType.INVERSE_WINDING);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
setOutlineProvider(ViewOutlineProvider.BOUNDS);
}
}
use of android.graphics.Path in project WoWoViewPager by Nightonke.
the class AppIntroExampleActivity method setPath.
private void setPath() {
WoWoPathView pathView = (WoWoPathView) findViewById(R.id.pathview);
ViewGroup.LayoutParams layoutParams = pathView.getLayoutParams();
layoutParams.height = screenH;
layoutParams.width = screenW + 200;
pathView.setLayoutParams(layoutParams);
int xoff = -300;
int yoff = screenH - 616 - 300;
float xScale = 1.5f;
float yScale = 1;
Path path = new Path();
path.moveTo(xScale * (565 + xoff), screenH + yoff);
path.cubicTo(xScale * (509 + xoff), yScale * (385 + yoff), xScale * (144 + xoff), yScale * (272 + yoff), xScale * (394 + xoff), yScale * (144 + yoff));
path.cubicTo(xScale * (477 + xoff), yScale * (99 + yoff), xScale * (596 + xoff), yScale * (91 + yoff), xScale * (697 + xoff), yScale * (128 + yoff));
path.cubicTo(xScale * (850 + xoff), yScale * (189 + yoff), xScale * (803 + xoff), yScale * (324 + yoff), xScale * (66 + xoff), yScale * (307 + yoff));
pathView.setPath(path);
ViewAnimation animation = new ViewAnimation(pathView);
animation.addPageAnimaition(new WoWoPathAnimation(1, 0f, 1f, EaseType.Linear, true));
animation.addPageAnimaition(new WoWoAlphaAnimation(2, 0, 1, 1, 0, EaseType.Linear, true));
animation.addPageAnimaition(new WoWoTranslationAnimation(2, 0, 1, 0, 0, -screenW, 0, EaseType.Linear, true));
wowo.addAnimation(animation);
}
use of android.graphics.Path in project WoWoViewPager by Nightonke.
the class WoWoPathAnimationActivity method setPath.
private void setPath() {
WoWoPathView pathView = (WoWoPathView) findViewById(R.id.pathview);
ViewGroup.LayoutParams layoutParams = pathView.getLayoutParams();
layoutParams.height = screenH;
// set the pathView a little wider,
// then the airplane can hide
layoutParams.width = screenW + 200;
pathView.setLayoutParams(layoutParams);
// use this to adjust the path
int xoff = -300;
int yoff = screenH - 616 - 300;
float xScale = 1.5f;
float yScale = 1;
Path path = new Path();
path.moveTo(xScale * (565 + xoff), screenH + yoff);
path.cubicTo(xScale * (509 + xoff), yScale * (385 + yoff), xScale * (144 + xoff), yScale * (272 + yoff), xScale * (394 + xoff), yScale * (144 + yoff));
path.cubicTo(xScale * (477 + xoff), yScale * (99 + yoff), xScale * (596 + xoff), yScale * (91 + yoff), xScale * (697 + xoff), yScale * (128 + yoff));
path.cubicTo(xScale * (850 + xoff), yScale * (189 + yoff), xScale * (803 + xoff), yScale * (324 + yoff), xScale * (66 + xoff), yScale * (307 + yoff));
// set the path to pathView
pathView.setPath(path);
ViewAnimation animation = new ViewAnimation(pathView);
animation.addPageAnimaition(new WoWoPathAnimation(0, 0f, 1f, easeType, useSameEaseTypeBack));
wowo.addAnimation(animation);
}
use of android.graphics.Path in project WoWoViewPager by Nightonke.
the class WoWoPathView method init.
private void init() {
mPaint = new Paint();
mPaint.setColor(mPathColor);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(mPathWidth);
mPaint.setAntiAlias(true);
// no head
if (headImageId != 0) {
mBitmap = BitmapFactory.decodeResource(getResources(), headImageId);
if (mBitmapWidth != -1 || mBitmapHeight != -1) {
mBitmap = getResizedBitmap(mBitmap, mBitmapWidth, mBitmapHeight);
}
mBitmapOffsetX = mBitmap.getWidth() / 2;
mBitmapOffsetY = mBitmap.getHeight() / 2;
mBitmapPosition = new float[2];
mBitmapTan = new float[2];
mMatrix = new Matrix();
}
setPath(new Path());
}
use of android.graphics.Path in project android_frameworks_base by ParanoidAndroid.
the class PieMenu method onDraw.
@Override
protected void onDraw(Canvas canvas) {
if (mOpen) {
int state;
// Draw background
if (mStatusMode != -1 && !mNavbarZero && !mIsProtected) {
canvas.drawARGB((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0xcc), 0, 0, 0);
}
// Snap points
if (mCenterDistance > mOuterChevronRadius) {
for (int i = 0; i < 3; i++) {
SnapPoint snap = mSnapPoint[i];
mSnapBackground.setAlpha((int) (snap.alpha + (snap.active ? mAnimators[ANIMATOR_SNAP_GROW].fraction * 80 : 0)));
canvas.drawCircle(snap.x, snap.y, (snap.active ? mAnimators[ANIMATOR_SNAP_GROW].fraction * Math.max(getWidth(), getHeight()) * 1.5f : 0), mSnapBackground);
float snapDistanceX = snap.x - mX;
float snapDistanceY = snap.y - mY;
float snapDistance = (float) Math.sqrt(Math.pow(snapDistanceX, 2) + Math.pow(snapDistanceY, 2));
float snapTouch = snapDistance < mSnapRadius * 7 ? 200 - (snapDistance * (200 - snap.alpha) / (mSnapRadius * 7)) : snap.alpha;
mSnapBackground.setAlpha((int) (snapTouch));
int len = (int) (snap.radius * 1.3f);
int thick = (int) (len * 0.2f);
Path plus = new Path();
plus.addRect(snap.x - len / 2, snap.y - thick / 2, snap.x + len / 2, snap.y + thick / 2, Path.Direction.CW);
plus.addRect(snap.x - thick / 2, snap.y - len / 2, snap.x + thick / 2, snap.y + len / 2, Path.Direction.CW);
canvas.drawPath(plus, mSnapBackground);
}
}
// Draw base menu
for (PieItem item : mItems) {
if (!canItemDisplay(item))
continue;
drawItem(canvas, item);
}
// Paint status report only if settings allow
if (mStatusMode != -1 && !mNavbarZero && !mIsProtected) {
// Draw chevron rings
mChevronBackgroundLeft.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * mGlowOffsetLeft / 2 * (mPanelOrientation == Gravity.TOP ? 0.2 : 1)));
mChevronBackgroundRight.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * mGlowOffsetRight * (mPanelOrientation == Gravity.TOP ? 0.2 : 1)));
if (mStatusPanel.getCurrentViewState() != PieStatusPanel.QUICK_SETTINGS_PANEL) {
state = canvas.save();
canvas.rotate(90, mCenter.x, mCenter.y);
for (int i = 0; i < CHEVRON_FRAGMENTS + 1; i++) {
canvas.drawPath(mChevronPathLeft[i], mChevronBackgroundLeft);
}
canvas.restoreToCount(state);
}
if (mStatusPanel.getCurrentViewState() != PieStatusPanel.NOTIFICATIONS_PANEL) {
state = canvas.save();
canvas.rotate(180 + (1 - mAnimators[ANIMATOR_BATTERY_METER].fraction) * 90, mCenter.x, mCenter.y);
canvas.drawPath(mChevronPathRight, mChevronBackgroundRight);
canvas.restoreToCount(state);
}
// Better not show inverted junk for top pies
if (mPanelOrientation != Gravity.TOP) {
// Draw Battery
mBatteryBackground.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0x22));
mBatteryJuice.setAlpha((int) (mAnimators[ANIMATOR_ACC_SPEED15].fraction * 0x88));
state = canvas.save();
canvas.rotate(90, mCenter.x, mCenter.y);
canvas.drawPath(mBatteryPathBackground, mBatteryBackground);
canvas.restoreToCount(state);
state = canvas.save();
canvas.rotate(90, mCenter.x, mCenter.y);
canvas.drawPath(mBatteryPathJuice, mBatteryJuice);
canvas.restoreToCount(state);
// Draw clock && AM/PM
state = canvas.save();
canvas.rotate(mClockTextRotation - (1 - mAnimators[ANIMATOR_DEC_SPEED15].fraction) * 90, mCenter.x, mCenter.y);
mClockPaint.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0xcc));
float lastPos = 0;
for (int i = 0; i < mClockText.length(); i++) {
canvas.drawTextOnPath("" + mClockText.charAt(i), mStatusPath, lastPos, mClockOffset, mClockPaint);
lastPos += mClockTextOffsets[i];
}
mAmPmPaint.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0xaa));
canvas.drawTextOnPath(mClockTextAmPm, mStatusPath, lastPos - mClockTextAmPmSize, mAmPmOffset, mAmPmPaint);
canvas.restoreToCount(state);
// Device status information and date
mStatusPaint.setAlpha((int) (mAnimators[ANIMATOR_ACC_SPEED15].fraction * 0xaa));
state = canvas.save();
canvas.rotate(mPanel.getDegree() + 180 + (1 - mAnimators[ANIMATOR_DEC_SPEED15].fraction) * 90, mCenter.x, mCenter.y);
if (mPolicy.supportsTelephony()) {
canvas.drawTextOnPath(mPolicy.getNetworkProvider(), mStatusPath, 0, mStatusOffset * 4, mStatusPaint);
}
canvas.drawTextOnPath(mPolicy.getSimpleDate(), mStatusPath, 0, mStatusOffset * 3, mStatusPaint);
canvas.drawTextOnPath(mPanel.getBar().getNotificationData().size() - mHiddenNotification + " " + mContext.getString(R.string.status_bar_latest_events_title).toUpperCase(), mStatusPath, 0, mStatusOffset * 2, mStatusPaint);
canvas.drawTextOnPath(mContext.getString(R.string.quick_settings_wifi_label).toUpperCase() + ": " + mPolicy.getWifiSsid(), mStatusPath, 0, mStatusOffset * 1, mStatusPaint);
canvas.drawTextOnPath(mPolicy.getBatteryLevelReadable(), mStatusPath, 0, mStatusOffset * 0, mStatusPaint);
canvas.restoreToCount(state);
state = canvas.save();
canvas.rotate(mPanel.getDegree() + 180, mCenter.x, mCenter.y);
// Notifications
if (mStatusPanel.getCurrentViewState() != PieStatusPanel.NOTIFICATIONS_PANEL) {
for (int i = 0; i < mNotificationCount && i < 10; i++) {
mNotificationPaint.setAlpha((int) (mAnimators[ANIMATOR_ACC_INC_1 + i].fraction * mGlowOffsetRight));
canvas.drawTextOnPath(mNotificationText[i], mNotificationPath[i], 0, 0, mNotificationPaint);
int IconState = canvas.save();
int posX = (int) (mCenter.x + mNotificationsRadius + i * mNotificationsRowSize);
int posY = (int) (mCenter.y - mNotificationIconSize * 1.4f);
int iconCenter = mNotificationIconSize / 2;
canvas.rotate(90, posX + iconCenter, posY + iconCenter);
canvas.drawBitmap(mNotificationIcon[i], null, new Rect(posX, posY, posX + mNotificationIconSize, posY + mNotificationIconSize), mNotificationPaint);
canvas.restoreToCount(IconState);
}
}
canvas.restoreToCount(state);
}
}
}
}
Aggregations