From bdea31ec93be496a89063ba8b80dd27c9582022a Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 19 Feb 2020 17:24:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/read/page/delegate/SimulationPageDelegate.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index de6eb2abe..d05dff850 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -25,10 +25,13 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi private var mBezierEnd1 = PointF() // 另一条贝塞尔曲线 + // 贝塞尔曲线起始点 private val mBezierStart2 = PointF() - + // 贝塞尔曲线控制点 private val mBezierControl2 = PointF() + // 贝塞尔曲线顶点 private val mBezierVertex2 = PointF() + // 贝塞尔曲线结束点 private var mBezierEnd2 = PointF() private var mMiddleX = 0f @@ -497,6 +500,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi mBezierControl1.x = mMiddleX - (mCornerY - mMiddleY) * (mCornerY - mMiddleY) / (mCornerX - mMiddleX) mBezierControl1.y = mCornerY.toFloat() + mBezierControl2.x = mCornerX.toFloat() mBezierControl2.y = if ((mCornerY - mMiddleY).toInt() == 0) { mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / 0.1f @@ -511,6 +515,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi if (mBezierStart1.x < 0 || mBezierStart1.x > viewWidth) { if (mBezierStart1.x < 0) mBezierStart1.x = viewWidth - mBezierStart1.x + val f1: Float = abs(mCornerX - touchX) val f2: Float = viewWidth * f1 / mBezierStart1.x touchX = abs(mCornerX - f2) @@ -532,11 +537,14 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi } mBezierStart2.x = mCornerX.toFloat() mBezierStart2.y = mBezierControl2.y - (mCornerY - mBezierControl2.y) / 2 + mTouchToCornerDis = hypot(touchX - mCornerX, touchY - mCornerY) + mBezierEnd1 = getCross(PointF(touchX, touchY), mBezierControl1, mBezierStart1, mBezierStart2) mBezierEnd2 = getCross(PointF(touchX, touchY), mBezierControl2, mBezierStart1, mBezierStart2) + mBezierVertex1.x = (mBezierStart1.x + 2 * mBezierControl1.x + mBezierEnd1.x) / 4 mBezierVertex1.y = (2 * mBezierControl1.y + mBezierStart1.y + mBezierEnd1.y) / 4 mBezierVertex2.x = (mBezierStart2.x + 2 * mBezierControl2.x + mBezierEnd2.x) / 4