Library for drawing app canvas with features like undo redo, color & transperency change, Integrated into your app easily.
Look at it's working demo on Playstore.
- Size , transperancy and color manipulation 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()
- Getter methods to get the current values of the attribute and also the drawing itself.
Watch the explaination on youtube: https://www.youtube.com/watch?v=Dnm3SI_OIko
DrawingApp.demo1.mp4
Step 1. Add this maven dependency to your build.gradle (project) file / settings.gradle for new version
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.1.2'
}
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-200
drawing_view.undo()
drawing_view.redo()
drawing_view.erase(Color.WHITE) // give the color same as the background color
drawing_view.clearDrawingBoard()
//getter methods
val alpha = drawing_view.getBrushAlpha() // returns INT
val brushSize = drawing_view.getBrushSize() // returns INT
val brushColor = drawing_view.getBrushColor() // returns INT
val drawing = drawing_view.getDrawing() // returns ArrayList<CustomPath>(); where CustomPath(var color:Int , var brushThickness:Int, var alpha:Int)
Explanation | Parameter Name | Type | Values |
---|---|---|---|
Set Brush Color | setBrushColor() | color | any color |
Set Brush Alpha | setBrushAlpha() | Int | 0-255 |
Set Brush Size | setSizeForBrush() | Int | 0-200 |
Set eraser color | erase() | color | any color |
This function takes the value from 0-255. You can check it's implementation here:
This function takes any color as an input. You can check it's implementation here:
Link for the color picker: https://github.com/Dhaval2404/ColorPicker
This function takes any value from 0-200 as an input. You can check it's implementation here:
These functions can undo and redo your strokes. You can check it's implementation here:
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:
This functions returns Integer value of alpha of the brush which will be in the range of 0-255.
This function returns Integer value of the size or thickness of the brush.
This function returns Integer value of the color of the brush.
This function returns an entire arraylist of customPath where CustomPath(var color:Int , var brushThickness:Int, var alpha:Int). Here color is the brush color , brushThickness is the width or the size of the brush and alpha is the transperancy. This is useful to store the entire drawing in high resolution or to share it.
If you liked it then show some love by giving a star.
Mihir Shah has made this library and will maintain it.