14/12/2024

Fabrikant Tech

Tech Specialists

The Android Arsenal – Views

The Android Arsenal – Views

RasmView is an Android drawing library it delivers a check out that lets buyers to draw on prime of a bitmap.

Demo

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

Capabilities

  • 8 previously defined brushes, and you can determine your individual.
  • Drawing on best of illustrations or photos.
  • Undo/redo operations.
  • Zooming in/out, rotation & translation.
  • Tailor made qualifications colour.

Obtain

Gradle:

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

Maven:

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

Usage Guidebook

Increase the adhering to to your structure file:


RasmContext

RasmContext lets you to control 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

Altering the brush

You can use the BrushesRepository to get an now outlined brush.

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

The pursuing brushes are already described:

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

Brush shade

Here is how to change the brush coloration:

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

The alpha channel worth is ignored, you can handle alpha by setting brushConfig.stream.

Brush size and other configurations

val brushConfig = rasmContext.brushConfig
brushConfig.size = .5f
brushConfig.movement = .25f
brushConfig.isEraser = real

Tailor made brushes

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

Drawing on a bitmap (your very own graphic).

val imageBitmap = ... //load your bitmap regardless of whether from a URI or means
rasmContext.setRasm(imageBitmap)
rasmView.resetTransformation() 

Acquiring the drawing

val drawingBitmap = rasmContext.exportRasm()

Background shade

rasmContext.setBackgroundColor(Shade.BLACK)

Undo/redo

val rasmState = rasmContext.state
rasmState.undo()
rasmState.redo()

But you do not want to retain your buttons enabled when an undo/redo is not feasible, you can pay attention 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 identified a bug, make sure you open an challenge.

License

Copyright 2022 Raed Mughaus

Licensed below the Apache License, Variation 2. (the "License")
you could not use this file besides in compliance with the License.
You may perhaps attain a copy of the License at

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

Unless of course demanded by relevant legislation or agreed to in crafting, computer software
dispersed beneath the License is distributed on an "AS IS" Basis,
Without WARRANTIES OR Problems OF ANY Sort, both specific or implied.
See the License for the particular language governing permissions and
constraints below the License.