The Android Arsenal – Views

Dhanisa Mashilfa

RasmView is an Android drawing library it delivers a see that allows consumers to draw on best of a bitmap.

Demo

https://www.youtube.com/observe?v=8qYhwjleT_8

Characteristics

  • 8 previously described brushes, and you can determine your personal.
  • Drawing on major of illustrations or photos.
  • Undo/redo operations.
  • Zooming in/out, rotation & translation.
  • Tailor made background shade.

Download

Gradle:

dependencies 
  implementation 'com.raedapps:rasmview:1.2.'

Maven:

<dependency>
  <groupId>com.raedappsgroupId>
  <artifactId>rasmviewartifactId>
  <version>1.2.version>
dependency>

Usage Guideline

Increase the next to your format file:


RasmContext

RasmContext will allow you to handle 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 presently outlined brush.

val brushesRepository = BrushesRepository(means)
rasmContext.brushConfig = brushesRepository.get(Brush.Marker)

The next brushes are now described:

enum course Brush 
    Pencil,
    Pen,
    Calligraphy,
    AirBrush,
    Marker,
    HardEraser,
    SoftEraser,

Brush coloration

Listed here is how to change the brush coloration:

rasmContext.brushColor = Coloration.Pink
rasmContext.brushColor = 0xff2187bb.toInt() //ARGB

The alpha channel price is disregarded, you can management alpha by setting brushConfig.stream.

Brush measurement and other configurations

val brushConfig = rasmContext.brushConfig
brushConfig.dimension = .5f
brushConfig.stream = .25f
brushConfig.isEraser = legitimate

Custom brushes

val myStampBitmap = ...
val customBrushConfig = BrushConfig()
customBrushConfig.stamp = BrushStamp.BitmapStamp(myStampBitmap)
customBrushConfig.size = .25f
customBrushConfig.spacing = .1f
rasmContext.brushConfig = customBrushConfig

Drawing on a bitmap (your very own image).

val imageBitmap = ... //load your bitmap whether or not from a URI or sources
rasmContext.setRasm(imageBitmap)
rasmView.resetTransformation() 

Receiving the drawing

val drawingBitmap = rasmContext.exportRasm()

Track record coloration

rasmContext.setBackgroundColor(Colour.BLACK)

Undo/redo

val rasmState = rasmContext.point out
rasmState.undo()
rasmState.redo()

But you do not want to keep your buttons enabled when an undo/redo is not possible, you can listen to state 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 = genuine

Resetting the transformation

rasmView.resetTransformation()

If you located a bug, please open an challenge.

License

Copyright 2022 Raed Mughaus

Accredited underneath the Apache License, Version 2. (the "License")
you could not use this file besides in compliance with the License.
You may get a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.

Unless demanded by relevant law or agreed to in writing, software
distributed underneath the License is dispersed on an "AS IS" Foundation,
With no WARRANTIES OR Conditions OF ANY Type, either specific or implied.
See the License for the unique language governing permissions and
restrictions underneath the License.

Next Post

Reddit, FTX Partnership Allows Redditors to Buy Crypto on the Platform

Users may perhaps now buy Ethereum on Reddit. Employing FTX’s payment system, they may possibly regulate their blockchain-based mostly community points. FTX Announced Reddit End users May Handle Blockchain-Based mostly Local community Factors Through a relationship with FTX, the cryptocurrency trade run by billionaire Sam Bankman-Fried, Reddit now enables buyers to […]
Reddit, FTX Partnership Allows Redditors to Buy Crypto on the Platform