DrawingCanvas
Library for drawing app canvas
Features
- Size , transperancy and color manupulation of brush -- Using setSizeForBrush(), setBrushAlpha() and setBrushColor() respectively
- Undo and Redo fucntionality available -- Using undo() and redo() respectively
- Using erase() function to match the background color to the brush color
- Clear canvas feature -- Using clearDrawingBoard()
Demo
Watch the explaination on youtube: https://www.youtube.com/watch?v=Dnm3SI_OIko
DrawingApp.demo1.mp4
How to use
You can refer to this Video:
OR Follow these steps:
Step 1. Add this maven dependency to your build.gradle (project) file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency to your build.gradle (app) file
dependencies {
implementation 'com.github.Miihir79:DrawingCanvas:1.0.3'
}
Step 3. Add the XML code
<com.mihir.drawingcanvas.drawingView
android:id="@+id/drawing_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.mihir.drawingcanvas.drawingView>
Step 4. Refrence the canvas in XML to use it's functions
drawing_view.setBrushAlpha(120)// values from 0-255
drawing_view.setBrushColor(R.color.white)
drawing_view.setSizeForBrush(12) // takes value from 0-35
drawing_view.undo()
drawing_view.redo()
drawing_view.redo(Color.WHITE) // give the color same as the background color
drawing_view.clearDrawingBoard()
Demo of all the functions
setBrushAlpha
This function takes the value from 0-255. You can check it's implementation here:
setBrushColor
This function takes any color as an input. You can check it's implementation here:
setSizeForBrush
This function takes any value from 0-35 as an input. You can check it's implementation here:
undo and redo
These functions can undo and redo your strokes. You can check it's implementation here:
clearDrawingBoard
This function clears all the strokes and clear the drawing board. But carefully you wont be able to undo this change! You can check it's implementation here:
That's it!
If you liked it then show some love by giving a star.
Author and contributions:
I, Mihir Shah has made this library and will maintain it. All contributions are welcomed!