-
- All Implemented Interfaces:
public final class SketchbookControllerSketchbookController interacts with Sketchbook and it allows you to control the canvas and all of the components with it.
-
-
Field Summary
Fields Modifier and Type Field Description private final PaintcurrentPaintprivate final State<Color>currentPaintColorprivate final State<Boolean>isEraseModeprivate final State<Boolean>canUndoprivate final State<Boolean>canRedo
-
Constructor Summary
Constructors Constructor Description SketchbookController()
-
Method Summary
Modifier and Type Method Description final PaintgetCurrentPaint()final State<Color>getCurrentPaintColor()MutableState of the current color of the Paint. final State<Boolean>isEraseMode()Indicates whether erase mode or not. final State<Boolean>getCanUndo()Indicates can execute undo or not. final State<Boolean>getCanRedo()Indicates can execute redo or not. final UnitsetBackgroundColor(Color color)Sets a background color. final UnitsetImageBitmap(ImageBitmap bitmap)Sets an ImageBitmap to draw on the canvas as a background. final UnitsetSelectedColorIndex(Integer index)Sets an index of the selected color. final UnitsetPaint(Paint paint)Sets a new Paint. final UnitsetPaintAlpha(Float alpha)Sets an alpha to the drawPaint. final UnitsetPaintColor(Color color)Sets a Color to the drawPaint. final UnitsetPaintStrokeWidth(Float strokeWidth)Sets a stroke width to the drawPaint. final UnitsetPaintShader(Shader shader)Sets a Shader to the drawPaint. final UnitsetLinearShader(List<Color> colors)Sets a color list as a linear shader to the paint. final UnitsetRainbowShader()Sets a rainbow shader to the paint. final UnitsetPaintingStyle(PaintingStyle paintingStyle)Sets a PaintingStyle to the drawPaint. final UnitsetPathEffect(PathEffect pathEffect)Sets a PathEffect to the drawPaint. final UnitaddDrawPath(Path path)Draws a Path with the current Paint. final UnitaddDrawPath(Path path, Paint paint)Draws a Path with the current Paint. final Unitundo()Executes undo the drawn path if possible. final Unitredo()Executes redo the drawn path if possible. final UnitsetEraseMode(Boolean isEraseMode)Sets the erase mode or not. final UnitsetEraseRadius(Float eraseRadius)Sets the radius size of the erase circle. final UnittoggleEraseMode()Toggles the erase mode. final UnitclearPaths()Clear the drawn paths and redo paths on canvas.. final UnitclearImageBitmap()Clear the image bitmap. final Unitclear()Clear drawn paths and the bitmap image. final ImageBitmapgetSketchbookBitmap()Returns the current Sketchbook's bitmap. -
-
Method Detail
-
getCurrentPaint
final Paint getCurrentPaint()
-
getCurrentPaintColor
final State<Color> getCurrentPaintColor()
MutableState of the current color of the Paint.
-
isEraseMode
final State<Boolean> isEraseMode()
Indicates whether erase mode or not.
-
getCanUndo
final State<Boolean> getCanUndo()
Indicates can execute undo or not.
-
getCanRedo
final State<Boolean> getCanRedo()
Indicates can execute redo or not.
-
setBackgroundColor
final Unit setBackgroundColor(Color color)
Sets a background color.
-
setImageBitmap
final Unit setImageBitmap(ImageBitmap bitmap)
Sets an ImageBitmap to draw on the canvas as a background.
-
setSelectedColorIndex
final Unit setSelectedColorIndex(Integer index)
Sets an index of the selected color.
-
setPaintAlpha
final Unit setPaintAlpha(Float alpha)
Sets an alpha to the drawPaint.
-
setPaintColor
final Unit setPaintColor(Color color)
Sets a Color to the drawPaint.
-
setPaintStrokeWidth
final Unit setPaintStrokeWidth(Float strokeWidth)
Sets a stroke width to the drawPaint.
-
setPaintShader
final Unit setPaintShader(Shader shader)
Sets a Shader to the drawPaint.
-
setLinearShader
final Unit setLinearShader(List<Color> colors)
Sets a color list as a linear shader to the paint.
-
setRainbowShader
final Unit setRainbowShader()
Sets a rainbow shader to the paint.
-
setPaintingStyle
final Unit setPaintingStyle(PaintingStyle paintingStyle)
Sets a PaintingStyle to the drawPaint.
-
setPathEffect
final Unit setPathEffect(PathEffect pathEffect)
Sets a PathEffect to the drawPaint.
-
addDrawPath
final Unit addDrawPath(Path path)
-
addDrawPath
final Unit addDrawPath(Path path, Paint paint)
-
setEraseMode
final Unit setEraseMode(Boolean isEraseMode)
Sets the erase mode or not.
- Parameters:
isEraseMode- Flag to set erase mode.
-
setEraseRadius
final Unit setEraseRadius(Float eraseRadius)
Sets the radius size of the erase circle.
- Parameters:
eraseRadius- Radius of the erase circle.
-
toggleEraseMode
final Unit toggleEraseMode()
Toggles the erase mode.
-
clearPaths
final Unit clearPaths()
Clear the drawn paths and redo paths on canvas..
-
clearImageBitmap
final Unit clearImageBitmap()
Clear the image bitmap.
-
getSketchbookBitmap
final ImageBitmap getSketchbookBitmap()
Returns the current Sketchbook's bitmap.
-
-
-
-