diff --git a/README.md b/README.md index 9f48cb3..e97cc6c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # RollingBeadView -RollingBead is an android library that can make bead (lens) moving effect in Views like ImageViews(as of now). +RollingBead is an android library that can make bead (lens) moving effect in Views like ImageViews(as of now). This is available in two +flavours, i.e, MovingBead and StaticBead. Both can be used as and when required to produce circular bead(lens) effect. # Features - Moving Bead : The library provides enough methods to control movement of moving bead. @@ -91,6 +92,28 @@ imageView.setImageBitmap(rb.dissolveFixedBead(0.93f, 0.46f, 0.2f, true, true)); # Documentation +## static Bead: +* Parameters for moving bead: `RollingBead` + +|Java set methods |Parameters | Description |Range | +|-------------------|----------------|---------------------------------------------------|----------------------| +|generateFixedBead | centerCircle_X | X coordinate of the bead |int(Px) or Float[0,1) | +| | centerCircle_Y | Y coordinate of the bead |int(Px) or Float[0,1) | +| | radius | radius of the bead |int(Px) or Float[0,1) | +| | lens_factor | intensity of deviation of the bead |double[0,∞) and -ve(may cause error)| +| | roundX | should the effect be pronounced round X axis edges|boolean | +| | roundY | should the effect be pronounced round Y axis edges|boolean | +|dissolveFixedBead* | centerCircle_X | X coordinate of the bead |int(Px) or Float[0,1) | +| | centerCircle_Y | Y coordinate of the bead |int(Px) or Float[0,1) | +| | radius | radius of the bead |int(Px) or Float[0,1) | +| | roundX | should the effect be pronounced round X axis edges|boolean | +| | roundY | should the effect be pronounced round Y axis edges|boolean | + +*Or use generateFixedBead with `0.0` as `lens_factor` + +---- + +## moving bead: * Attributes for moving bead: `RollingBeadImageView` |XML attribute |Java set methods |Description |Default Value | @@ -123,21 +146,33 @@ imageView.setImageBitmap(rb.dissolveFixedBead(0.93f, 0.46f, 0.2f, true, true)); ---- -* Attributes for moving bead: `RollingBead` - -|Java set methods |Parameters | Description |Range | -|-------------------|------------------|---------------------------------------------------|----------------------| -|generateFixedBead | centerCircle_X@$ | X coordinate of the bead |int(Px) or Float[0,1) | -| | centerCircle_Y@$ | Y coordinate of the bead |int(Px) or Float[0,1) | -| | radius@$ | radius of the bead |int(Px) or Float[0,1) | -| | lens_factor@ | intensity of deviation of the bead |double[0,∞) and -ve(may cause error)| -| | roundX | should the effect be pronounced round X axis edges|boolean | -| | roundY | should the effect be pronounced round Y axis edges|boolean | -|dissolveFixedBead | centerCircle_X@$ | X coordinate of the bead |int(Px) or Float[0,1) | -| | centerCircle_Y@$ | Y coordinate of the bead |int(Px) or Float[0,1) | -| | radius@$ | radius of the bead |int(Px) or Float[0,1) | -| | roundX | should the effect be pronounced round X axis edges|boolean | -| | roundY | should the effect be pronounced round Y axis edges|boolean | +# Limitations: + +The methods used in the library intensively uses system's resources. Thus encountering some of the vital limitations!!. Do +go through these before using the library: + +## static Bead: +* Static bead function is currently handled on the **UI** thread. It will be improved in the future. Currently you + can make separate thread yourself or make a PR for the same. + +* making `lens_factor` negative squeezes the image, (instead of bulging it), but this might produce error!!. + +## moving bead: +* The entire movingBeadImageView is highly vulnerable to frequent GC event, thus affectingly reducing performance and + disturbing the UI thread notoriously. To counter this, **reduce the radius, movement and increase repetition_Times**. + At the same time smaller image and horizontal orientation will be quiet helpful. + +* When moving forward, moving bead creates a major segment instead of complete circle to reduce calculation. + +* Though moving bead does't disturbs a single pixel after passing, please use `stopRender` when switching the current activity. + +* Following the point above, don't put `set` request consecutively within `repetition_Times` interval. This might severely + damage the input image. + +# Contributions! + +All contributions are welcome and appreciated. Please make a Pull Request or open an issue, if necessary. +This may also include any form of feature enhancement. Every constructive criticism is welcome. # Source: The initial algorithm for generating bead effect was taken from [this repo](https://github.com/ArashPartow/bitmap#simple-example-5---magnifying-lens-distortion) diff --git a/app/src/main/java/com/example/android/rollingbeadview/MainActivity.java b/app/src/main/java/com/example/android/rollingbeadview/MainActivity.java index 1e6e39e..01deafc 100644 --- a/app/src/main/java/com/example/android/rollingbeadview/MainActivity.java +++ b/app/src/main/java/com/example/android/rollingbeadview/MainActivity.java @@ -1,6 +1,5 @@ package com.example.android.rollingbeadview; -import android.graphics.Bitmap; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; @@ -12,7 +11,6 @@ public class MainActivity extends AppCompatActivity { ImageView imageView; RollingBeadImageView mimage; - Bitmap im, cb; RollingBead rb; @Override @@ -23,19 +21,14 @@ protected void onCreate(Bundle savedInstanceState) { // mimage = (RollingBeadImageView) findViewById(R.id.mimage); imageView = (ImageView) findViewById(R.id.imageView); rb = new RollingBead(imageView); - -// im = BitmapFactory.decodeResource(getApplicationContext().getResources(), -// R.drawable.colors); -// cb = im.copy(Bitmap.Config.ARGB_8888, true); } public void test1(View v) { - imageView.setImageBitmap(rb.generateFixedBead(0.93f, 0.46f, 0.2f, 0.0, true, true)); + imageView.setImageBitmap(rb.generateFixedBead(0.93f, 0.46f, 0.2f, 1.0, true, true)); // mimage.setCenterCircle_X(0); // mimage.setOrientationHorizontal(false); -// mimage.bead.dissolveMovingBead(); } public void test2(View v) { @@ -46,7 +39,7 @@ public void test2(View v) { } public void test3(View v) { - imageView.setImageBitmap(rb.generateFixedBead(100, 100, 100, 3.0, true, true)); + imageView.setImageBitmap(rb.generateFixedBead(0.93f, 0.46f, 0.2f, 0.0, true, true)); // mimage.setNumberOfTimes(3); } diff --git a/rollingbeadlibrary/src/main/java/com/example/android/rollingbeadlibrary/RollingBeadImageView.java b/rollingbeadlibrary/src/main/java/com/example/android/rollingbeadlibrary/RollingBeadImageView.java index 407d509..87e142d 100644 --- a/rollingbeadlibrary/src/main/java/com/example/android/rollingbeadlibrary/RollingBeadImageView.java +++ b/rollingbeadlibrary/src/main/java/com/example/android/rollingbeadlibrary/RollingBeadImageView.java @@ -51,9 +51,7 @@ public RollingBeadImageView(Context context) { } public RollingBeadImageView(Context context, @Nullable AttributeSet attrs) { -// super(context, attrs); this(context, attrs, 0); -// Log.i("point rbi54", "RollingBeadImageView "); } public RollingBeadImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { @@ -374,18 +372,6 @@ private void setup() { //returns view bounds private RectF calculateBounds() { -// Log.i("point rbi224", "getPaddingBottom()" + getPaddingBottom()); -// Log.i("point rbi225", "end" + getPaddingEnd()); -// Log.i("point rbi226", "left" + getPaddingLeft()); -// Log.i("point rbi227", "right " + getPaddingRight()); -// Log.i("point rbi228", "start" + getPaddingStart()); -// Log.i("point rbi229", "top" + getPaddingTop()); -// Log.i("point rbi230", "bottom" + getBottom()); -// Log.i("point rbi231", "width" + getWidth()); -// Log.i("point rbi232", "height" + getHeight()); -// Log.i("point rbi233", "getTop" + getTop()); -// Log.i("point rbi234", "getLeft" + getLeft()); -// Log.i("point rbi235", "getRight" + getRight()); return new RectF(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); } @@ -445,7 +431,6 @@ protected void onProgressUpdate(String... values) { protected void onDraw(Canvas canvas) { // Log.i("point rbi183", "ondraw"); if (changedBitmap == null) { -// Log.i("point rbi189", "ondraw problem"); return; } // draw the changed bitmap on the canvas