private PreviewItemDrawingParams computePreviewItemDrawingParams( int index, PreviewItemDrawingParams params) { index = NUM_ITEMS_IN_PREVIEW - index - 1; float r = (index * 1.0f) / (NUM_ITEMS_IN_PREVIEW - 1); float scale = (1 - PERSPECTIVE_SCALE_FACTOR * (1 - r)); float offset = (1 - r) * mMaxPerspectiveShift; float scaledSize = scale * mBaselineIconSize; float scaleOffsetCorrection = (1 - scale) * mBaselineIconSize; // We want to imagine our coordinates from the bottom left, growing up and to the // right. This is natural for the x-axis, but for the y-axis, we have to invert things. float transY = mAvailableSpaceInPreview - (offset + scaledSize + scaleOffsetCorrection); float transX = offset + scaleOffsetCorrection; float totalScale = mBaselineIconScale * scale; final int overlayAlpha = (int) (80 * (1 - r)); if (params == null) { params = new PreviewItemDrawingParams(transX, transY, totalScale, overlayAlpha); } else { params.transX = transX; params.transY = transY; params.scale = totalScale; params.overlayAlpha = overlayAlpha; } return params; }
private float getLocalCenterForIndex(int index, int[] center) { mParams = computePreviewItemDrawingParams(Math.min(NUM_ITEMS_IN_PREVIEW, index), mParams); mParams.transX += mPreviewOffsetX; mParams.transY += mPreviewOffsetY; float offsetX = mParams.transX + (mParams.scale * mIntrinsicIconSize) / 2; float offsetY = mParams.transY + (mParams.scale * mIntrinsicIconSize) / 2; center[0] = Math.round(offsetX); center[1] = Math.round(offsetY); return mParams.scale; }