mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
curl implementation works for all 4 screen corners
This commit is contained in:
parent
8d414fa9a1
commit
e405d15633
1 changed files with 38 additions and 23 deletions
|
@ -207,8 +207,6 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
myScrollingSpeed *= 1.5;
|
myScrollingSpeed *= 1.5;
|
||||||
}
|
}
|
||||||
final int size = myScrollHorizontally ? w : h;
|
|
||||||
int shift = getScrollingShift() < 0 ? getScrollingShift() + size : getScrollingShift() - size;
|
|
||||||
|
|
||||||
getAnimationProvider().draw(
|
getAnimationProvider().draw(
|
||||||
canvas,
|
canvas,
|
||||||
|
@ -219,33 +217,48 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (view.getAnimationType()) {
|
switch (view.getAnimationType()) {
|
||||||
case none:
|
|
||||||
case slide:
|
|
||||||
case shift:
|
|
||||||
break;
|
|
||||||
case curl:
|
case curl:
|
||||||
{
|
{
|
||||||
if (doStopScrolling && myScrollingBound != 0) {
|
if (doStopScrolling && myScrollingBound != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
final int cornerX = myStartX > w / 2 ? w : 0;
|
||||||
|
final int cornerY = myStartY > h / 2 ? h : 0;
|
||||||
|
final int oppositeX = Math.abs(w - cornerX);
|
||||||
|
final int oppositeY = Math.abs(h - cornerY);
|
||||||
final int x, y;
|
final int x, y;
|
||||||
if (myScrollHorizontally) {
|
if (myScrollHorizontally) {
|
||||||
x = - getScrollingShift();
|
x = Math.max(1, Math.min(w - 1, myEndX));
|
||||||
y = x * h / w;
|
if (cornerY == 0) {
|
||||||
|
y = Math.max(1, Math.min(h / 2, myEndY));
|
||||||
} else {
|
} else {
|
||||||
y = - getScrollingShift();
|
y = Math.max(h / 2, Math.min(h - 1, myEndY));
|
||||||
x = y * w / h;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
y = Math.max(1, Math.min(h - 1, myEndY));
|
||||||
|
if (cornerX == 0) {
|
||||||
|
x = Math.max(1, Math.min(w / 2, myEndX));
|
||||||
|
} else {
|
||||||
|
x = Math.max(w / 2, Math.min(w - 1, myEndX));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final int dX = Math.abs(x - cornerX);
|
||||||
|
final int dY = Math.abs(y - cornerY);
|
||||||
|
|
||||||
|
final int x1 = cornerX == 0
|
||||||
|
? (dY * dY / dX + dX) / 2
|
||||||
|
: cornerX - (dY * dY / dX + dX) / 2;
|
||||||
|
final int y1 = cornerY == 0
|
||||||
|
? (dX * dX / dY + dY) / 2
|
||||||
|
: cornerY - (dX * dX / dY + dY) / 2;
|
||||||
|
|
||||||
final int x1 = x > 0 ? w - (y * y / x + x) / 2 : w;
|
|
||||||
final int y1 = y > 0 ? h - (x * x / y + y) / 2 : h;
|
|
||||||
final Path fgPath = new Path();
|
final Path fgPath = new Path();
|
||||||
fgPath.moveTo(x1, h);
|
fgPath.moveTo(x1, cornerY);
|
||||||
fgPath.lineTo(w - x, h - y);
|
fgPath.lineTo(x, y);
|
||||||
fgPath.lineTo(w, y1);
|
fgPath.lineTo(cornerX, y1);
|
||||||
fgPath.lineTo(w, 0);
|
fgPath.lineTo(cornerX, oppositeY);
|
||||||
fgPath.lineTo(0, 0);
|
fgPath.lineTo(oppositeX, oppositeY);
|
||||||
fgPath.lineTo(0, h);
|
fgPath.lineTo(oppositeX, cornerY);
|
||||||
canvas.clipPath(fgPath);
|
canvas.clipPath(fgPath);
|
||||||
canvas.drawBitmap(
|
canvas.drawBitmap(
|
||||||
myMainBitmap,
|
myMainBitmap,
|
||||||
|
@ -254,18 +267,20 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
);
|
);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
|
|
||||||
if (shift > 0 && shift < size) {
|
final int size = myScrollHorizontally ? w : h;
|
||||||
|
int shift = getScrollingShift() < 0 ? getScrollingShift() + size : getScrollingShift() - size;
|
||||||
|
//if (shift > 0 && shift < size) {
|
||||||
myEdgePaint.setColor(ZLAndroidPaintContext.getFillColor());
|
myEdgePaint.setColor(ZLAndroidPaintContext.getFillColor());
|
||||||
myEdgePaint.setAntiAlias(true);
|
myEdgePaint.setAntiAlias(true);
|
||||||
myEdgePaint.setStyle(Paint.Style.FILL);
|
myEdgePaint.setStyle(Paint.Style.FILL);
|
||||||
myEdgePaint.setShadowLayer(25, 5, 5, 0x99000000);
|
myEdgePaint.setShadowLayer(25, 5, 5, 0x99000000);
|
||||||
|
|
||||||
final Path path = new Path();
|
final Path path = new Path();
|
||||||
path.moveTo(x1, h);
|
path.moveTo(x1, cornerY);
|
||||||
path.lineTo(w - x, h - y);
|
path.lineTo(x, y);
|
||||||
path.lineTo(w, y1);
|
path.lineTo(cornerX, y1);
|
||||||
canvas.drawPath(path, myEdgePaint);
|
canvas.drawPath(path, myEdgePaint);
|
||||||
}
|
//}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue