Coder Social home page Coder Social logo

riccardomoro / freedrawview Goto Github PK

View Code? Open in Web Editor NEW
647.0 647.0 115.0 3.34 MB

A View on which you can freely draw, customizing paint width, alpha and color, and take a screenshot of the content. Useful for note apps, signatures or free hand writing.

Java 100.00%
android android-library canvas custom-view drawing signature

freedrawview's People

Contributors

bizzguy avatar corochann avatar jaytj95 avatar ninadmg avatar riccardomoro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freedrawview's Issues

Set bitmap as background in DrawView

How can I set the bitmap as a background for DrawView? Suppose I drew something, saved somewhere bitmap or file. I transferred this file to another device and I want to continue drawing my drawing. If I could install a background from a bitmap or file, this would solve the problem, but at the moment it can only be installed from resources.

Possible enchancement

Could we perhaps make FreeDrawView an ImageView?
This could be useful when drawing on pictures.
I have tried making FreeDrawView extend ImageView rather than simple view but then setImageBitmap method of ImageView did not work - the background would not change.

Error if setOnPathDrawnListener() is not called

Without calling setOnPathDrawnListener() on the FreeDrawView, I get an error:

java.lang.NullPointerException: Attempt to invoke interface method 'void com.rm.freedrawview.PathDrawnListener.onPathStart()' on a null object reference

Once I call the method, even while leaving the callbacks empty, everything is fine.

getCurrentViewStateAsSerializable() returns soft copy (dynamic mutable state)

Hello RiccardoMoro!

FreeDrawSerializableState#getCurrentViewStateAsSerializable()

returns

new FreeDrawSerializableState(mCanceledPaths, mPaths, getPaintColor(),
                getPaintAlpha(), getPaintWidth(), getResizeBehaviour(),
                mLastDimensionW, mLastDimensionH);

with mCanceledPaths, mPaths as pointers to respective arraylists, such that changes are represented both on the original and the copy.
If thats not intended behaviour, i would suggest returning hard copies.

Thanks for the hard work! Much love.
Huy

Idea for draw mode

If you want to disable/enable draw mode do something like this:

void disableDrawMode(){
			mFreeDrawView.setFocusableInTouchMode(false);

			mFreeDrawView.setFocusable(false);

			mFreeDrawView.setClickable(false);

			mFreeDrawView.setEnabled(false);
		}
		void enableDrawMode(){
			mFreeDrawView.setFocusableInTouchMode(true);

			mFreeDrawView.setFocusable(true);

			mFreeDrawView.setClickable(true);

			mFreeDrawView.setEnabled(true);
		}

Listeners Not Working !

Thanks for this Awesome Work !
I found this two Listeners not working as it has to be !
removePathDrawnListener and setPathRedoUndoCountChangeListener either setting it null manually not making any change.

mFreeDrawView.setOnPathDrawnListener(null);
mFreeDrawView.setPathRedoUndoCountChangeListener(null);

i want to stop drawing when user done with it on button click event.
any ways to do it ?

Set a BitmapShader to the Paint

This library is very useful hopefully you can include a shader so you can paint image tiles from a bitmap into the FreeDrawView. Like the example below.

val shader = BitmapShader(resource,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT)
FreeDrawView.paint.setShader(shader)

getting mSignatureView.getDrawingCache() as null

is there any way to get bitmap of this FreeDrawView
as this listener is also always giving error
mSignatureView.getDrawScreenshot(new FreeDrawView.DrawCreatorListener() { @Override public void onDrawCreated(Bitmap draw) { // The draw Bitmap is the drawn content of the View } @Override public void onDrawCreationError() { // Something went wrong creating the bitmap, should never // happen unless the async task has been canceled } });

width and height must be > 0

When i use getDrawScreenshot() method, i get this error "width and height must be > 0" in here

FreeDrawView.java:743

try {
mBitmap = Bitmap.createBitmap(
mWidth, mHeight, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
} catch (Exception e) {
e.printStackTrace();
cancel(true);
}

        return null;

can you help me?

Is it possible to record the path points of line?

I want to get the path points of lines (ex: [1,1],[2,2],[8,7]....).
It seems Lib doesn't have function like that.
I try to set setOnTouchListener to canvas.
It can return the path point, but canvas can't draw anymore.

If there any suggestion for this situation?

I solved this issue by create a new class extent Lib, and modified the onTouch fucntion.

Support eraser?

Hi, it is nice job. but wanna to know whether support eraser? If not, i feel free to implement it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.