1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

experiments with curl animation

This commit is contained in:
Nikolay Pultsin 2011-03-27 04:09:33 +01:00
parent d656861327
commit ab10872b12
5 changed files with 50 additions and 12 deletions

View file

@ -512,7 +512,7 @@
<node name="none" value="Scroll with no animation"/> <node name="none" value="Scroll with no animation"/>
<node name="slide" value="Slide animation"/> <node name="slide" value="Slide animation"/>
<node name="shift" value="Shift animation"/> <node name="shift" value="Shift animation"/>
<node name="paper3d" value="3D animation"/> <node name="curl" value="Curl animation"/>
</node> </node>
<node name="horizontal" value="Horizontal scrolling"> <node name="horizontal" value="Horizontal scrolling">
<node name="summaryOn" value="Scroll pages horizontally"/> <node name="summaryOn" value="Scroll pages horizontally"/>

View file

@ -10,4 +10,4 @@
# Project target. # Project target.
target=android-8 target=android-8
java.encoding=utf-8 java.encoding=utf-8
proguard.config=proguard.cfg #proguard.config=proguard.cfg

View file

@ -40,7 +40,7 @@ abstract public class ZLView {
public static final int PAGE_BOTTOM = 4; public static final int PAGE_BOTTOM = 4;
public enum Animation { public enum Animation {
none, slide, shift, paper3d none, slide, shift, curl
} }
public abstract Animation getAnimationType(); public abstract Animation getAnimationType();

View file

@ -74,9 +74,9 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
try { try {
final Bitmap fileBitmap = final Bitmap fileBitmap =
new BitmapFactory().decodeStream(wallpaperFile.getInputStream()); new BitmapFactory().decodeStream(wallpaperFile.getInputStream());
if (doMirror) {
final int w = fileBitmap.getWidth(); final int w = fileBitmap.getWidth();
final int h = fileBitmap.getHeight(); final int h = fileBitmap.getHeight();
if (doMirror) {
final Bitmap wallpaper = Bitmap.createBitmap(2 * w, 2 * h, fileBitmap.getConfig()); final Bitmap wallpaper = Bitmap.createBitmap(2 * w, 2 * h, fileBitmap.getConfig());
for (int i = 0; i < w; ++i) { for (int i = 0; i < w; ++i) {
for (int j = 0; j < h; ++j) { for (int j = 0; j < h; ++j) {
@ -91,6 +91,21 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
} else { } else {
ourWallpaper = fileBitmap; ourWallpaper = fileBitmap;
} }
long r = 0, g = 0, b = 0;
for (int i = 0; i < w; ++i) {
for (int j = 0; j < h; ++j) {
int color = fileBitmap.getPixel(i, j);
r += color & 0xFF0000;
g += color & 0xFF00;
b += color & 0xFF;
}
}
r /= w * h;
g /= w * h;
b /= w * h;
r >>= 16;
g >>= 8;
ourFillColor = Color.rgb((int)r, (int)g, (int)b);
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
@ -111,6 +126,7 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
@Override @Override
public void clear(ZLColor color) { public void clear(ZLColor color) {
myFillPaint.setColor(ZLAndroidColorUtil.rgb(color)); myFillPaint.setColor(ZLAndroidColorUtil.rgb(color));
ourFillColor = myFillPaint.getColor();
myCanvas.drawRect(0, 0, myWidth + myScrollbarWidth, myHeight, myFillPaint); myCanvas.drawRect(0, 0, myWidth + myScrollbarWidth, myHeight, myFillPaint);
} }
@ -185,23 +201,32 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
myTextPaint.setUnderlineText(underline); myTextPaint.setUnderlineText(underline);
} }
@Override
public void setTextColor(ZLColor color) { public void setTextColor(ZLColor color) {
myTextPaint.setColor(ZLAndroidColorUtil.rgb(color)); myTextPaint.setColor(ZLAndroidColorUtil.rgb(color));
} }
@Override
public void setLineColor(ZLColor color, int style) { public void setLineColor(ZLColor color, int style) {
// TODO: use style // TODO: use style
myLinePaint.setColor(ZLAndroidColorUtil.rgb(color)); myLinePaint.setColor(ZLAndroidColorUtil.rgb(color));
} }
@Override
public void setLineWidth(int width) { public void setLineWidth(int width) {
myLinePaint.setStrokeWidth(width); myLinePaint.setStrokeWidth(width);
} }
@Override
public void setFillColor(ZLColor color, int style) { public void setFillColor(ZLColor color, int style) {
// TODO: use style // TODO: use style
myFillPaint.setColor(ZLAndroidColorUtil.rgb(color)); myFillPaint.setColor(ZLAndroidColorUtil.rgb(color));
} }
private static int ourFillColor;
static int getFillColor() {
return ourFillColor;
}
public int getWidth() { public int getWidth() {
return myWidth; return myWidth;
} }

View file

@ -32,6 +32,7 @@ import org.geometerplus.zlibrary.ui.android.util.ZLAndroidKeyUtil;
public class ZLAndroidWidget extends View implements View.OnLongClickListener { public class ZLAndroidWidget extends View implements View.OnLongClickListener {
private final Paint myPaint = new Paint(); private final Paint myPaint = new Paint();
private final Paint myEdgePaint = new Paint();
private Bitmap myMainBitmap; private Bitmap myMainBitmap;
private Bitmap mySecondaryBitmap; private Bitmap mySecondaryBitmap;
private boolean mySecondaryBitmapIsUpToDate; private boolean mySecondaryBitmapIsUpToDate;
@ -151,7 +152,13 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
); );
break; break;
case slide: case slide:
case paper3d: canvas.drawBitmap(
mySecondaryBitmap,
0, 0,
myPaint
);
break;
case curl:
canvas.drawBitmap( canvas.drawBitmap(
mySecondaryBitmap, mySecondaryBitmap,
0, 0, 0, 0,
@ -188,13 +195,19 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
} }
} }
break; break;
case paper3d: case curl:
{ {
myPaint.setColor(Color.rgb(127, 127, 127)); myEdgePaint.setColor(ZLAndroidPaintContext.getFillColor());
final int x = 100; myEdgePaint.setAntiAlias(true);
final int y = 100; myEdgePaint.setStyle(Paint.Style.FILL);
canvas.drawLine(0, h, w - x, h - y, myPaint); myEdgePaint.setShadowLayer(25, 5, 5, 0x99000000);
canvas.drawLine(w, 0, w - x, h - y, myPaint); final int x = w - shift;
final int y = 250;
final Path path = new Path();
path.moveTo(w - x * 4 / 3, h);
path.lineTo(w - x, h - y);
path.lineTo(w, h - y * 4 / 3);
canvas.drawPath(path, myEdgePaint);
break; break;
} }
} }