Table of Contents
RasmView is an Android drawing library it gives a look at that makes it possible for users to attract on top rated of a bitmap.
Demo
https://www.youtube.com/watch?v=8qYhwjleT_8
Features
- 8 currently described brushes, and you can define your very own.
- Drawing on best of illustrations or photos.
- Undo/redo functions.
- Zooming in/out, rotation & translation.
- Custom background color.
Down load
Gradle:
dependencies
implementation 'com.raedapps:rasmview:1.2.'
Maven:
<dependency>
<groupId>com.raedappsgroupId>
<artifactId>rasmviewartifactId>
<version>1.2.version>
dependency>
Use Guideline
Increase the following to your structure file:
RasmContext
RasmContext
makes it possible for you to manage the brush configuration, undo/redo, reset transformation, and far more. RasmContext
can be accessed from RasmView
:
val rasmView = findViewById<RasmView>(R.id.rasmView)
val rasmContext = rasmView.rasmContext
Shifting the brush
You can use the BrushesRepository
to get an currently described brush.
val brushesRepository = BrushesRepository(resources)
rasmContext.brushConfig = brushesRepository.get(Brush.Marker)
The adhering to brushes are currently outlined:
enum course Brush
Pencil,
Pen,
Calligraphy,
AirBrush,
Marker,
HardEraser,
SoftEraser,
Brush coloration
Below is how to transform the brush shade:
rasmContext.brushColor = Coloration.Red
rasmContext.brushColor = 0xff2187bb.toInt() //ARGB
The alpha channel worth is ignored, you can control alpha by environment brushConfig.stream
.
Brush sizing and other configurations
val brushConfig = rasmContext.brushConfig
brushConfig.sizing = .5f
brushConfig.move = .25f
brushConfig.isEraser = correct
Tailor made brushes
val myStampBitmap = ...
val customBrushConfig = BrushConfig()
customBrushConfig.stamp = BrushStamp.BitmapStamp(myStampBitmap)
customBrushConfig.sizing = .25f
customBrushConfig.spacing = .1f
rasmContext.brushConfig = customBrushConfig
Drawing on a bitmap (your possess impression).
val imageBitmap = ... //load your bitmap regardless of whether from a URI or methods
rasmContext.setRasm(imageBitmap)
rasmView.resetTransformation()
Getting the drawing
val drawingBitmap = rasmContext.exportRasm()
Track record colour
rasmContext.setBackgroundColor(Colour.BLACK)
Undo/redo
val rasmState = rasmContext.point out
rasmState.undo()
rasmState.redo()
But you do not want to maintain your buttons enabled when an undo/redo is not feasible, you can hear to point out updates:
undoButton.setOnClickListener
rasmState.undo()
redoButton.setOnClickListener
rasmState.redo()
rasmState.addOnStateChangedListener
undoButton.isEnabled = rasmState.canCallUndo()
redoButton.isEnabled = rasmState.canCallRedo()
undoButton.isEnabled = rasmState.canCallUndo()
redoButton.isEnabled = rasmState.canCallRedo()
Clearing the drawing
Enabling rotation
rasmContext.rotationEnabled = legitimate
Resetting the transformation
rasmView.resetTransformation()
If you observed a bug, remember to open up an challenge.
License
Copyright 2022 Raed Mughaus
Accredited underneath the Apache License, Version 2. (the "License")
you might not use this file other than in compliance with the License.
You might get hold of a copy of the License at
http://www.apache.org/licenses/LICENSE-2.
Until expected by applicable regulation or agreed to in composing, program
dispersed below the License is dispersed on an "AS IS" Basis,
Without the need of WARRANTIES OR Problems OF ANY Variety, possibly specific or implied.
See the License for the precise language governing permissions and
limits beneath the License.