|
|
@ -468,21 +468,23 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
|
|
|
|
|
|
|
|
mMiddleX = (mTouchX + mCornerX) / 2 |
|
|
|
mMiddleX = (mTouchX + mCornerX) / 2 |
|
|
|
mMiddleY = (mTouchY + mCornerY) / 2 |
|
|
|
mMiddleY = (mTouchY + mCornerY) / 2 |
|
|
|
|
|
|
|
|
|
|
|
mBezierControl1.x = |
|
|
|
mBezierControl1.x = |
|
|
|
mMiddleX - (mCornerY - mMiddleY) * (mCornerY - mMiddleY) / (mCornerX - mMiddleX) |
|
|
|
mMiddleX - (mCornerY - mMiddleY) * (mCornerY - mMiddleY) / (mCornerX - mMiddleX) |
|
|
|
mBezierControl1.y = mCornerY.toFloat() |
|
|
|
mBezierControl1.y = mCornerY.toFloat() |
|
|
|
|
|
|
|
|
|
|
|
mBezierControl2.x = mCornerX.toFloat() |
|
|
|
mBezierControl2.x = mCornerX.toFloat() |
|
|
|
mBezierControl2.y = if ((mCornerY - mMiddleY).toInt() == 0) { |
|
|
|
|
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / 0.1f |
|
|
|
val f4 = mCornerY - mMiddleY |
|
|
|
|
|
|
|
if (f4 == 0f) { |
|
|
|
|
|
|
|
mBezierControl2.y = mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / 0.1f |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
mBezierControl2.y = |
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / (mCornerY - mMiddleY) |
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / (mCornerY - mMiddleY) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mBezierStart1.x = mBezierControl1.x - (mCornerX - mBezierControl1.x) / 2 |
|
|
|
mBezierStart1.x = mBezierControl1.x - (mCornerX - mBezierControl1.x) / 2 |
|
|
|
mBezierStart1.y = mCornerY.toFloat() |
|
|
|
mBezierStart1.y = mCornerY.toFloat() |
|
|
|
//固定左边上下两个点 |
|
|
|
|
|
|
|
|
|
|
|
// 固定左边上下两个点 |
|
|
|
if (mTouchX > 0 && mTouchX < viewWidth) { |
|
|
|
if (mTouchX > 0 && mTouchX < viewWidth) { |
|
|
|
if (mBezierStart1.x < 0 || mBezierStart1.x > viewWidth) { |
|
|
|
if (mBezierStart1.x < 0 || mBezierStart1.x > viewWidth) { |
|
|
|
if (mBezierStart1.x < 0) |
|
|
|
if (mBezierStart1.x < 0) |
|
|
@ -491,6 +493,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
val f1 = abs(mCornerX - mTouchX) |
|
|
|
val f1 = abs(mCornerX - mTouchX) |
|
|
|
val f2 = viewWidth * f1 / mBezierStart1.x |
|
|
|
val f2 = viewWidth * f1 / mBezierStart1.x |
|
|
|
mTouchX = abs(mCornerX - f2) |
|
|
|
mTouchX = abs(mCornerX - f2) |
|
|
|
|
|
|
|
|
|
|
|
val f3 = abs(mCornerX - mTouchX) * abs(mCornerY - mTouchY) / f1 |
|
|
|
val f3 = abs(mCornerX - mTouchX) * abs(mCornerY - mTouchY) / f1 |
|
|
|
mTouchY = abs(mCornerY - f3) |
|
|
|
mTouchY = abs(mCornerY - f3) |
|
|
|
|
|
|
|
|
|
|
@ -502,9 +505,13 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
mBezierControl1.y = mCornerY.toFloat() |
|
|
|
mBezierControl1.y = mCornerY.toFloat() |
|
|
|
|
|
|
|
|
|
|
|
mBezierControl2.x = mCornerX.toFloat() |
|
|
|
mBezierControl2.x = mCornerX.toFloat() |
|
|
|
mBezierControl2.y = if ((mCornerY - mMiddleY).toInt() == 0) { |
|
|
|
|
|
|
|
|
|
|
|
val f5 = mCornerY - mMiddleY |
|
|
|
|
|
|
|
if (f5 == 0f) { |
|
|
|
|
|
|
|
mBezierControl2.y = |
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / 0.1f |
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / 0.1f |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
mBezierControl2.y = |
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / (mCornerY - mMiddleY) |
|
|
|
mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / (mCornerY - mMiddleY) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -514,12 +521,19 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
mBezierStart2.x = mCornerX.toFloat() |
|
|
|
mBezierStart2.x = mCornerX.toFloat() |
|
|
|
mBezierStart2.y = mBezierControl2.y - (mCornerY - mBezierControl2.y) / 2 |
|
|
|
mBezierStart2.y = mBezierControl2.y - (mCornerY - mBezierControl2.y) / 2 |
|
|
|
|
|
|
|
|
|
|
|
mTouchToCornerDis = hypot(mTouchX - mCornerX, mTouchY - mCornerY) |
|
|
|
mTouchToCornerDis = hypot( |
|
|
|
|
|
|
|
(mTouchX - mCornerX).toDouble(), |
|
|
|
|
|
|
|
(mTouchY - mCornerY).toDouble() |
|
|
|
|
|
|
|
).toFloat() |
|
|
|
|
|
|
|
|
|
|
|
mBezierEnd1 = |
|
|
|
mBezierEnd1 = getCross( |
|
|
|
getCross(PointF(mTouchX, mTouchY), mBezierControl1, mBezierStart1, mBezierStart2) |
|
|
|
PointF(mTouchX, mTouchY), mBezierControl1, mBezierStart1, |
|
|
|
mBezierEnd2 = |
|
|
|
mBezierStart2 |
|
|
|
getCross(PointF(mTouchX, mTouchY), mBezierControl2, mBezierStart1, mBezierStart2) |
|
|
|
) |
|
|
|
|
|
|
|
mBezierEnd2 = getCross( |
|
|
|
|
|
|
|
PointF(mTouchX, mTouchY), mBezierControl2, mBezierStart1, |
|
|
|
|
|
|
|
mBezierStart2 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
mBezierVertex1.x = (mBezierStart1.x + 2 * mBezierControl1.x + mBezierEnd1.x) / 4 |
|
|
|
mBezierVertex1.x = (mBezierStart1.x + 2 * mBezierControl1.x + mBezierEnd1.x) / 4 |
|
|
|
mBezierVertex1.y = (2 * mBezierControl1.y + mBezierStart1.y + mBezierEnd1.y) / 4 |
|
|
|
mBezierVertex1.y = (2 * mBezierControl1.y + mBezierStart1.y + mBezierEnd1.y) / 4 |
|
|
|