Skip to content

Commit

Permalink
readme updated, code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-ritik committed Jun 15, 2018
1 parent e22b86a commit 83cf308
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 40 deletions.
67 changes: 51 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
- <b>Moving Bead</b> : The library provides enough methods to control movement of moving bead.
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +11,6 @@
public class MainActivity extends AppCompatActivity {
ImageView imageView;
RollingBeadImageView mimage;
Bitmap im, cb;
RollingBead rb;

@Override
Expand All @@ -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) {
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 83cf308

Please sign in to comment.