Language:
Configure Brush
VideoEditor SDK supports several configuration options for the BrushToolPanel
allowing flexible adaptation to different needs and use cases.
Set available tools#
By default, all available brush tools are enabled. For this example only a couple are enabled.
Default brush tool color#
The default color of the brush stroke is white. If you can anticipate that your use case requires a different default color you can do so using the setDefaultBrushColor()
method.
Set available colors#
The default color palette provides multiple colors. Here, we only provide a small selection of colors as might be sensible for an annotation use case.
Default brush size#
Similarly, the size of the brush is set at 5% relative to the smaller side of the video by default. In our example, we change it to 8%.
File:
class VideoBrushConfiguration(private val activity: AppCompatActivity) : Example(activity) {override fun invoke() {// In this example, we do not need access to the Uri(s) after the editor is closed// so we pass false in the constructorval settingsList = VideoEditorSettingsList(false)// Set the source as the Uri of the video to be loaded.configure<LoadSettings> {it.source = activity.resourceUri(R.raw.skater)}settingsList.configure<UiConfigBrush> {// By default all available brush tools are enabled.// For this example only a couple are enabled.it.optionList.set(listOf(BrushColorOption(BrushToolPanel.OPTION_COLOR, Color.TRANSPARENT),BrushOption(BrushToolPanel.OPTION_SIZE,ly.img.android.pesdk.ui.brush.R.string.pesdk_brush_button_size,ImageSource.create(ly.img.android.pesdk.ui.R.drawable.imgly_icon_option_align_resize))))// By default the default color for the brush stroke is white// For this example the default color is set to blackit.setDefaultBrushColor(Color.BLACK)// By default the editor provides a variety of different colors to customize the color of the brush stroke// For this example only a small selection of colors is enabledit.setBrushColorList(ColorItem(ly.img.android.pesdk.ui.R.string.pesdk_common_title_whiteColor, ColorAsset(-0x1)),ColorItem(ly.img.android.pesdk.ui.R.string.pesdk_common_title_blackColor, ColorAsset(-0x1000000)),ColorItem(ly.img.android.pesdk.ui.R.string.pesdk_common_title_redColor, ColorAsset(-0x18afb0)))}settingsList.configure<BrushSettings> {// By default the default brush size is set to 5% of the smaller side of the video// For this example, we change it to 8%it.brushSize = 0.08f}// Start the video editor using VideoEditorBuilder// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODEVideoEditorBuilder(activity).setSettingsList(settingsList).startActivityForResult(activity, EDITOR_REQUEST_CODE)// Release the SettingsList once donesettingsList.release()}override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {intent ?: returnif (requestCode == EDITOR_REQUEST_CODE) {// Wrap the intent into an EditorSDKResultval result = EditorSDKResult(intent)when (result.resultStatus) {EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")EditorSDKResult.Status.EXPORT_DONE -> showMessage("Result saved at ${result.resultUri}")else -> {}}}}}