Java Code Examples for android.graphics.drawable.GradientDrawable#setBounds()
The following examples show how to use
android.graphics.drawable.GradientDrawable#setBounds() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CirclePageIndicator.java From JianshuApp with GNU General Public License v3.0 | 6 votes |
private void drawUnselect(Canvas canvas, int count, int verticalOffset, int horizontalOffset) { for (int i = 0; i < count; i++) { Rect rect = unselectRects.get(i); rect.left = horizontalOffset + (indicatorWidth + indicatorGap) * i; rect.top = verticalOffset; rect.right = rect.left + indicatorWidth; rect.bottom = rect.top + indicatorHeight; GradientDrawable unselectDrawable = unselectDrawables.get(i); unselectDrawable.setCornerRadius(cornerRadius); unselectDrawable.setColor(unselectColor); unselectDrawable.setStroke(strokeWidth, strokeColor); unselectDrawable.setBounds(rect); unselectDrawable.draw(canvas); } }
Example 2
Source File: OverlappedWidget.java From BookReader with Apache License 2.0 | 6 votes |
@Override protected void drawCurrentPageShadow(Canvas canvas) { canvas.save(); GradientDrawable shadow; if (actiondownX > mScreenWidth >> 1) { shadow = mBackShadowDrawableLR; shadow.setBounds((int) (mScreenWidth + touch_down - 5), 0, (int) (mScreenWidth + touch_down + 5), mScreenHeight); } else { shadow = mBackShadowDrawableRL; shadow.setBounds((int) (touch_down - 5), 0, (int) (touch_down + 5), mScreenHeight); } shadow.draw(canvas); try { canvas.restore(); } catch (Exception e) { } }
Example 3
Source File: PageWidget.java From BookReader with Apache License 2.0 | 5 votes |
@Override protected void drawNextPageAreaAndShadow(Canvas canvas) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } canvas.drawBitmap(mNextPageBitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 4
Source File: PageWidget.java From coolreader with MIT License | 5 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y)); mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 5
Source File: BookPageView.java From CrawlerForReader with Apache License 2.0 | 5 votes |
/** * 绘制A区域右阴影 * * @param canvas */ private void drawPathARightShadow(Canvas canvas, Path pathA) { canvas.restore(); canvas.save(); float viewDiagonalLength = (float) Math.hypot(viewWidth, viewHeight);//view对角线长度 int left = (int) h.x; int right = (int) (h.x + viewDiagonalLength * 10);//需要足够长的长度 int top; int bottom; GradientDrawable gradientDrawable; if (style.equals(STYLE_TOP_RIGHT)) { gradientDrawable = drawableRightTopRight; top = (int) (h.y - rPathAShadowDis / 2); bottom = (int) h.y; } else { gradientDrawable = drawableRightLowerRight; top = (int) h.y; bottom = (int) (h.y + rPathAShadowDis / 2); } gradientDrawable.setBounds(left, top, right, bottom); Path mPath = new Path(); mPath.moveTo(a.x - Math.max(rPathAShadowDis, lPathAShadowDis) / 2, a.y); // mPath.lineTo(i.x,i.y); mPath.lineTo(h.x, h.y); mPath.lineTo(a.x, a.y); mPath.close(); canvas.clipPath(pathA); canvas.clipPath(mPath, Region.Op.INTERSECT); float mDegrees = (float) Math.toDegrees(Math.atan2(a.y - h.y, a.x - h.x)); canvas.rotate(mDegrees, h.x, h.y); gradientDrawable.draw(canvas); }
Example 6
Source File: BookPageView.java From CrawlerForReader with Apache License 2.0 | 5 votes |
/** * 绘制B区域阴影,阴影左深右浅 * * @param canvas */ private void drawPathBShadow(Canvas canvas) { int deepOffset = 0;//深色端的偏移值 int lightOffset = 0;//浅色端的偏移值 float aTof = (float) Math.hypot((a.x - f.x), (a.y - f.y));//a到f的距离 float viewDiagonalLength = (float) Math.hypot(viewWidth, viewHeight);//对角线长度 int left; int right; int top = (int) c.y; int bottom = (int) (viewDiagonalLength + c.y); GradientDrawable gradientDrawable; if (style.equals(STYLE_TOP_RIGHT)) {//f点在右上角 //从左向右线性渐变 gradientDrawable = drawableBTopRight; left = (int) (c.x - deepOffset);//c点位于左上角 right = (int) (c.x + aTof / 4 + lightOffset); } else { //从右向左线性渐变 gradientDrawable = drawableBLowerRight; left = (int) (c.x - aTof / 4 - lightOffset);//c点位于左下角 right = (int) (c.x + deepOffset); } gradientDrawable.setBounds(left, top, right, bottom);//设置阴影矩形 float rotateDegrees = (float) Math.toDegrees(Math.atan2(e.x - f.x, h.y - f.y));//旋转角度 canvas.rotate(rotateDegrees, c.x, c.y);//以c为中心点旋转 gradientDrawable.draw(canvas); }
Example 7
Source File: PageWidget.java From Jreader with GNU General Public License v2.0 | 5 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 8
Source File: BookPageView.java From BookPage with MIT License | 5 votes |
/** * 绘制A区域右阴影 * @param canvas */ private void drawPathARightShadow(Canvas canvas, Path pathA){ canvas.restore(); canvas.save(); float viewDiagonalLength = (float) Math.hypot(viewWidth, viewHeight);//view对角线长度 int left = (int) h.x; int right = (int) (h.x + viewDiagonalLength*10);//需要足够长的长度 int top; int bottom; GradientDrawable gradientDrawable; if (style.equals(STYLE_TOP_RIGHT)) { gradientDrawable = drawableRightTopRight; top = (int) (h.y- rPathAShadowDis /2); bottom = (int) h.y; } else { gradientDrawable = drawableRightLowerRight; top = (int) h.y; bottom = (int) (h.y+ rPathAShadowDis /2); } gradientDrawable.setBounds(left,top,right,bottom); Path mPath = new Path(); mPath.moveTo(a.x- Math.max(rPathAShadowDis, lPathAShadowDis) /2,a.y); // mPath.lineTo(i.x,i.y); mPath.lineTo(h.x,h.y); mPath.lineTo(a.x,a.y); mPath.close(); canvas.clipPath(pathA); canvas.clipPath(mPath, Region.Op.INTERSECT); float mDegrees = (float) Math.toDegrees(Math.atan2(a.y-h.y, a.x-h.x)); canvas.rotate(mDegrees, h.x, h.y); gradientDrawable.draw(canvas); }
Example 9
Source File: PageView.java From android-open-source-project-analysis with Apache License 2.0 | 5 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 10
Source File: BookPageView.java From BookPage with MIT License | 5 votes |
/** * 绘制C区域阴影,阴影左浅右深 * @param canvas */ private void drawPathCShadow(Canvas canvas){ int deepOffset = 1;//深色端的偏移值 int lightOffset = -30;//浅色端的偏移值 float viewDiagonalLength = (float) Math.hypot(viewWidth, viewHeight);//view对角线长度 int midpoint_ce = (int) (c.x + e.x) / 2;//ce中点 int midpoint_jh = (int) (j.y + h.y) / 2;//jh中点 float minDisToControlPoint = Math.min(Math.abs(midpoint_ce - e.x), Math.abs(midpoint_jh - h.y));//中点到控制点的最小值 int left; int right; int top = (int) c.y; int bottom = (int) (viewDiagonalLength + c.y); GradientDrawable gradientDrawable; if (style.equals(STYLE_TOP_RIGHT)) { gradientDrawable = drawableCTopRight; left = (int) (c.x - lightOffset); right = (int) (c.x + minDisToControlPoint + deepOffset); } else { gradientDrawable = drawableCLowerRight; left = (int) (c.x - minDisToControlPoint - deepOffset); right = (int) (c.x + lightOffset); } gradientDrawable.setBounds(left,top,right,bottom); float mDegrees = (float) Math.toDegrees(Math.atan2(e.x- f.x, h.y - f.y)); canvas.rotate(mDegrees, c.x, c.y); gradientDrawable.draw(canvas); }
Example 11
Source File: SimulationPageAnim.java From NovelReader with MIT License | 5 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 12
Source File: PageWidget.java From fangzhuishushenqi with Apache License 2.0 | 5 votes |
@Override protected void drawNextPageAreaAndShadow(Canvas canvas) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } canvas.drawBitmap(mNextPageBitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 13
Source File: SimulationPageAnim.java From HaoReader with GNU General Public License v3.0 | 4 votes |
/** * 绘制翻起页背面 */ private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) { int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2; float f1 = Math.abs(i - mBezierControl1.x); int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2; float f2 = Math.abs(i1 - mBezierControl2.y); float f3 = Math.min(f1, f2); mPath1.reset(); mPath1.moveTo(mBezierVertex2.x, mBezierVertex2.y); mPath1.lineTo(mBezierVertex1.x, mBezierVertex1.y); mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y); mPath1.lineTo(mTouchX, mTouchY); mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y); mPath1.close(); GradientDrawable mFolderShadowDrawable; int left; int right; if (mIsRTandLB) { left = (int) (mBezierStart1.x - 1); right = (int) (mBezierStart1.x + f3 + 1); mFolderShadowDrawable = mFolderShadowDrawableLR; } else { left = (int) (mBezierStart1.x - f3 - 1); right = (int) (mBezierStart1.x + 1); mFolderShadowDrawable = mFolderShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { canvas.clipPath(mPath1); } else { canvas.clipPath(mPath1, Region.Op.INTERSECT); } } catch (Exception ignored) { } //对Bitmap进行取色 int color = bitmap.getPixel(ScreenUtils.dpToPx(10), ScreenUtils.dpToPx(10)); canvas.drawColor(color); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength)); mFolderShadowDrawable.draw(canvas); canvas.restore(); }
Example 14
Source File: pageView.java From Jreader with GNU General Public License v2.0 | 4 votes |
/** * 绘制翻起页背面 * * @param canvas * @param bitmap */ private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) { int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2; float f1 = Math.abs(i - mBezierControl1.x); int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2; float f2 = Math.abs(i1 - mBezierControl2.y); float f3 = Math.min(f1, f2); mPath1.reset(); mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y); mPath1.lineTo(mTouch.x, mTouch.y); mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y); mPath1.close(); GradientDrawable mFolderShadowDrawable; int left; int right; if (mIsRTandLB) { left = (int) (mBezierStart1.x - 1); right = (int) (mBezierStart1.x + f3 + 1); mFolderShadowDrawable = mFolderShadowDrawableLR; } else { left = (int) (mBezierStart1.x - f3 - 1); right = (int) (mBezierStart1.x + 1); mFolderShadowDrawable = mFolderShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } mPaint.setColorFilter(mColorMatrixFilter); float dis = (float) Math.hypot(mCornerX - mBezierControl1.x, mBezierControl2.y - mCornerY); float f8 = (mCornerX - mBezierControl1.x) / dis; float f9 = (mBezierControl2.y - mCornerY) / dis; mMatrixArray[0] = 1 - 2 * f9 * f9; mMatrixArray[1] = 2 * f8 * f9; mMatrixArray[3] = mMatrixArray[1]; mMatrixArray[4] = 1 - 2 * f8 * f8; mMatrix.reset(); mMatrix.setValues(mMatrixArray); mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y); mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y); canvas.drawBitmap(bitmap, mMatrix, mPaint); // canvas.drawBitmap(bitmap, mMatrix, null); mPaint.setColorFilter(null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength)); mFolderShadowDrawable.draw(canvas); canvas.restore(); }
Example 15
Source File: PageWidget.java From fangzhuishushenqi with Apache License 2.0 | 4 votes |
@Override protected void drawCurrentBackArea(Canvas canvas) { int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2; float f1 = Math.abs(i - mBezierControl1.x); int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2; float f2 = Math.abs(i1 - mBezierControl2.y); float f3 = Math.min(f1, f2); mPath1.reset(); mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y); mPath1.lineTo(mTouch.x, mTouch.y); mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y); mPath1.close(); GradientDrawable mFolderShadowDrawable; int left; int right; if (mIsRTandLB) { left = (int) (mBezierStart1.x - 1); right = (int) (mBezierStart1.x + f3 + 1); mFolderShadowDrawable = mFolderShadowDrawableLR; } else { left = (int) (mBezierStart1.x - f3 - 1); right = (int) (mBezierStart1.x + 1); mFolderShadowDrawable = mFolderShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } mPaint.setColorFilter(mColorMatrixFilter); float dis = (float) Math.hypot(mCornerX - mBezierControl1.x, mBezierControl2.y - mCornerY); float f8 = (mCornerX - mBezierControl1.x) / dis; float f9 = (mBezierControl2.y - mCornerY) / dis; mMatrixArray[0] = 1 - 2 * f9 * f9; mMatrixArray[1] = 2 * f8 * f9; mMatrixArray[3] = mMatrixArray[1]; mMatrixArray[4] = 1 - 2 * f8 * f8; mMatrix.reset(); mMatrix.setValues(mMatrixArray); mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y); mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y); canvas.drawBitmap(mCurPageBitmap, mMatrix, mPaint); // canvas.drawBitmap(bitmap, mMatrix, null); mPaint.setColorFilter(null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength)); mFolderShadowDrawable.draw(canvas); canvas.restore(); }
Example 16
Source File: SimulationPageAnim.java From HaoReader with GNU General Public License v3.0 | 4 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBezierVertex1.x, mBezierVertex1.y); mPath1.lineTo(mBezierVertex2.x, mBezierVertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { canvas.clipPath(mPath1); } else { canvas.clipPath(mPath1, Region.Op.INTERSECT); } } catch (Exception ignored) { } canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example 17
Source File: SimulationPageAnim.java From a with GNU General Public License v3.0 | 4 votes |
/** * 绘制翻起页背面 */ private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) { int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2; float f1 = Math.abs(i - mBezierControl1.x); int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2; float f2 = Math.abs(i1 - mBezierControl2.y); float f3 = Math.min(f1, f2); mPath1.reset(); mPath1.moveTo(mBezierVertex2.x, mBezierVertex2.y); mPath1.lineTo(mBezierVertex1.x, mBezierVertex1.y); mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y); mPath1.lineTo(mTouchX, mTouchY); mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y); mPath1.close(); GradientDrawable mFolderShadowDrawable; int left; int right; if (mIsRTandLB) { left = (int) (mBezierStart1.x - 1); right = (int) (mBezierStart1.x + f3 + 1); mFolderShadowDrawable = mFolderShadowDrawableLR; } else { left = (int) (mBezierStart1.x - f3 - 1); right = (int) (mBezierStart1.x + 1); mFolderShadowDrawable = mFolderShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { canvas.clipPath(mPath1); } else { canvas.clipPath(mPath1, Region.Op.INTERSECT); } } catch (Exception ignored) { } mPaint.setColorFilter(mColorMatrixFilter); float dis = (float) Math.hypot(mCornerX - mBezierControl1.x, mBezierControl2.y - mCornerY); float f8 = (mCornerX - mBezierControl1.x) / dis; float f9 = (mBezierControl2.y - mCornerY) / dis; mMatrixArray[0] = 1 - 2 * f9 * f9; mMatrixArray[1] = 2 * f8 * f9; mMatrixArray[3] = mMatrixArray[1]; mMatrixArray[4] = 1 - 2 * f8 * f8; mMatrix.reset(); mMatrix.setValues(mMatrixArray); mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y); mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y); canvas.drawBitmap(bitmap, mMatrix, mPaint); mPaint.setColorFilter(null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength)); mFolderShadowDrawable.draw(canvas); canvas.restore(); }
Example 18
Source File: PageWidget.java From BookReader with Apache License 2.0 | 4 votes |
@Override protected void drawCurrentBackArea(Canvas canvas) { int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2; float f1 = Math.abs(i - mBezierControl1.x); int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2; float f2 = Math.abs(i1 - mBezierControl2.y); float f3 = Math.min(f1, f2); mPath1.reset(); mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y); mPath1.lineTo(mTouch.x, mTouch.y); mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y); mPath1.close(); GradientDrawable mFolderShadowDrawable; int left; int right; if (mIsRTandLB) { left = (int) (mBezierStart1.x - 1); right = (int) (mBezierStart1.x + f3 + 1); mFolderShadowDrawable = mFolderShadowDrawableLR; } else { left = (int) (mBezierStart1.x - f3 - 1); right = (int) (mBezierStart1.x + 1); mFolderShadowDrawable = mFolderShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } mPaint.setColorFilter(mColorMatrixFilter); float dis = (float) Math.hypot(mCornerX - mBezierControl1.x, mBezierControl2.y - mCornerY); float f8 = (mCornerX - mBezierControl1.x) / dis; float f9 = (mBezierControl2.y - mCornerY) / dis; mMatrixArray[0] = 1 - 2 * f9 * f9; mMatrixArray[1] = 2 * f8 * f9; mMatrixArray[3] = mMatrixArray[1]; mMatrixArray[4] = 1 - 2 * f8 * f8; mMatrix.reset(); mMatrix.setValues(mMatrixArray); mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y); mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y); canvas.drawBitmap(mCurPageBitmap, mMatrix, mPaint); // canvas.drawBitmap(bitmap, mMatrix, null); mPaint.setColorFilter(null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength)); mFolderShadowDrawable.draw(canvas); canvas.restore(); }
Example 19
Source File: PageWidget.java From nono-android with GNU General Public License v3.0 | 4 votes |
/** * Author : hmg25 Version: 1.0 Description : ���Ʒ���ҳ���� */ private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) { int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2; float f1 = Math.abs(i - mBezierControl1.x); int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2; float f2 = Math.abs(i1 - mBezierControl2.y); float f3 = Math.min(f1, f2); mPath1.reset(); mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y); mPath1.lineTo(mTouch.x, mTouch.y); mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y); mPath1.close(); GradientDrawable mFolderShadowDrawable; int left; int right; if (mIsRTandLB) { left = (int) (mBezierStart1.x - 1); right = (int) (mBezierStart1.x + f3 + 1); mFolderShadowDrawable = mFolderShadowDrawableLR; } else { left = (int) (mBezierStart1.x - f3 - 1); right = (int) (mBezierStart1.x + 1); mFolderShadowDrawable = mFolderShadowDrawableRL; } canvas.save(); canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); mPaint.setColorFilter(mColorMatrixFilter); float dis = (float) Math.hypot(mCornerX - mBezierControl1.x, mBezierControl2.y - mCornerY); float f8 = (mCornerX - mBezierControl1.x) / dis; float f9 = (mBezierControl2.y - mCornerY) / dis; mMatrixArray[0] = 1 - 2 * f9 * f9; mMatrixArray[1] = 2 * f8 * f9; mMatrixArray[3] = mMatrixArray[1]; mMatrixArray[4] = 1 - 2 * f8 * f8; mMatrix.reset(); mMatrix.setValues(mMatrixArray); mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y); mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y); canvas.drawBitmap(bitmap, mMatrix, mPaint); // canvas.drawBitmap(bitmap, mMatrix, null); mPaint.setColorFilter(null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength)); mFolderShadowDrawable.draw(canvas); canvas.restore(); }
Example 20
Source File: SimulationPageAnim.java From a with GNU General Public License v3.0 | 4 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBezierVertex1.x, mBezierVertex1.y); mPath1.lineTo(mBezierVertex2.x, mBezierVertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { canvas.clipPath(mPath1); } else { canvas.clipPath(mPath1, Region.Op.INTERSECT); } //canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception ignored) { } canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }