[FREE] CanvasLayers - a layer editor for Canvas

CanvasLayers Extension Guide for Kodular Creator

Overview

CanvasLayers is a custom extension for Kodular Creator that enhances the functionality of the standard Canvas component. This guide will explain how to integrate and utilize CanvasLayers in your Kodular Creator projects.

MEDIA


APK DEMO

  • This APK is part of my new work for the Play Store

testesGerais.apk (7.8 MB)

FILES

Key Features

The CanvasLayers extension offers a variety of methods to manipulate layers on a Canvas, such as adding, removing, and editing layers, as well as drawing and clearing content.

Methods

Certainly, here’s a detailed explanation of all blocks in the CanvasLayers:

Simple Function

  1. SetCanvas(Canvas canvas): Assigns a canvas component for drawing.

  2. SetAnchorComponent(ArrangementComponent, Number, Number, Number, Number, Number): Sets up a view component to anchor the layer picker with custom settings.

  3. AddLayer(Text, boolean, Number): Adds a new layer to the canvas with an option for alpha channel support.

  4. RemoveLayer(): Removes the active layer from the canvas and activates the layer below it.

  5. ClearCanvas(): Clears the active layer.

  6. SetActiveLayer(Text): Sets the specified layer as the active layer for drawing.

  7. DrawPixelOnActiveLayer(Number, Number, Number, Number): Draws a square pixel on the active layer.

  8. DrawPointOnActiveLayer(Number, Number, Number, Number): Draws a point on the active layer.

  9. DrawLineOnActiveLayer(Number, Number, Number, Number, Number, Number): Draws a line on the active layer.

  10. DrawWithShinyBrushOnActiveLayer(Number, Number, Number, Number, Number, Number): Draws with a shiny brush on the active layer.

  11. DrawGrid(Number, Number): Draws a removable square grid on a special top layer.

  12. RemoveGrid(): Removes the grid layer.

  13. Undo(): Undoes the last action on the active layer.

  14. Redo(): Redoes the last undone action on the active layer.

  15. GetLayerInfo(): Returns information about the layers as a YailList.

  16. RenameLayer(Text, Text): Renames a specified layer.

  17. Erase(Number, Number, Number): Erases on the active layer.

  18. FloodFill(Number, Number, Number, Number): Fills an area on the active layer with a specified color.

  19. FloodFillScanline(Number, Number, Number, Number): Fills an area on the active layer with a specified color using the Scanline FloodFill algorithm.

  20. GetTotalMemoryUsed(): Returns the total memory used by the extension in Kbytes.

  21. AddImageToActiveLayer(@Asset Text): Loads an image from a path and adds it to the active layer.

  22. MoveLayerDown(Text): Moves the specified layer down in the order.

  23. MoveLayerUp(Text): Moves the specified layer up in the order.

  24. ShowLayerPickerWithDelay(): Shows the layer picker after making the anchor component visible.

  25. ShowAlertDialog(Text, Text, Number, boolean, boolean): Shows an alert dialog with custom settings.

  26. ShowLayerSelectionDialog(Text, Number, Number, Number, boolean, boolean, Text): Shows a dialog with two dropdown menus for layer selection.

  27. ShowTextInputDialog(Text, Text, Number, Number, Number, Text, Text, boolean, boolean, boolean, Text): Shows a dialog with a text input.

  28. RoundCorners(ArrangementComponent, Number, Number, Number, Number, Number, Number, boolean, boolean): Rounds the corners of a visual component and adjusts colors.

  29. RoundCornersMetallic(ArrangementComponent, Number) Number, Number, Number, boolean, boolean): Applies a metallic effect to the corners of a visual component.

  30. ZoomInActiveLayer(Number): Zooms in the active layer.

  31. ZoomOutActiveLayer(Number): Zooms out the active layer.

  32. ZoomInAtPoint(Number, Number, Number): Zooms in the active layer at a specific point.

  33. ZoomOutAtPoint(Number, Number, Number): Zooms out the active layer at a specific point.

  34. SetCanvasMonitoring(Canvas): Sets up canvas monitoring.

  35. ExportLayerToPNG(Text, Text): Exports a specified layer to a PNG file.

  36. AdjustBrightness(Text, Number): Adjusts the brightness of the specified layer.

  37. CreateLayerFromImage(Text, @Asset Text): Creates a new layer from an existing image.

  38. SaveLayersToSeparatePDFPages(Text): Saves each layer as a separate page in a PDF file.

  39. SaveAllLayersToOnePDFPage(Text): Saves all layers into a single page of a PDF file.

  40. ConvertToPixelArt(): Converts the active layer to pixel art.

  41. ResizeLayer(Text, Number, Number): Resizes a specific layer.

  42. ConvertLayerToGrayscale(Text): Converts a layer to grayscale.

  43. ApplyBlurToLayer(Text, Number): Applies a blur to the

layer.

  1. ApplyBlurAtPoint(Text, Number, Number, Number, Number): Applies a blur at a specific point of the layer.

  2. CombineLayers(Text, Text, Text): Combines two layers using the specified merge type.

  3. StartSelection(Number, Number): Starts selection on the canvas.

  4. UpdateSelection(Number, Number): Updates the selection on the canvas.

  5. EndSelection(Text): Finalizes the selection on the canvas.

  6. CutSelectedArea(): Cuts the selected area from the active layer and copies it to the clipboard.

  7. CopySelectedArea(): Copies the selected area to the active canvas.

  8. PasteCopiedArea(Number, Number): Pastes the copied area to a specified point on the active canvas.

  9. StartLine(Number, Number, Number, Number): Starts a new line on the canvas.

  10. DrawLine(): Draws the line on the active layer.

  11. UpdateLine(Number, Number): Updates the line on the canvas with an end point.

  12. StartArrow(Number, Number, Number, Number): Starts a new arrow on the canvas.

  13. UpdateArrow(Number, Number): Updates the arrow on the canvas with a period.

  14. DrawArrow(): Draws the arrow on the active layer.

  15. GetActiveLayerName(): Returns the name of the active layer.

Property

  1. CanvasWidth(Number): Sets or gets the width of the canvas.

  2. CanvasHeight(Number): Sets or gets the height of the canvas.

  3. OffsetX(Number): Sets or gets the X-coordinate offset.

  4. OffsetY(Number): Sets or gets the Y-coordinate offset.

  5. NumberOfLayers(): Gets the number of layers created.

Each of these functions and properties is designed to manipulate the canvas and its layers in specific ways, whether changing properties of the canvas, adding or modifying layers, or even interacting with UI and events. The properties typically include setters and getters for various attributes of the canvas, while the functions perform operations on the canvas layers.

Events

LayerSaved(Text filePath)

Triggered when a layer is saved.

  • Parameters:
    • String filePath: Path of the saved file.

ReportError(Text errorMessage)

Reports an error.

  • Parameters:
    • String errorMessage: Error message.

OnLayerSelected(Text layerName)

Triggered when a layer is selected.

  • Parameters:
    • String layerName: Name of the selected layer.

OnLayerLongPressed(Text layerName)

Triggered on a long press on a layer.

  • Parameters:
    • String layerName: Name of the long-pressed layer.

OnOutsidePicker()

Triggered when selected outside the selection area.

  • Parameters:
    • None

TextEntered(Text text, String type)

Triggered when text is entered in the input dialog.

  • Parameters:
    • String text: Text entered in ShowTextInputDialog
    • String type: Optional text to differentiate different text entries

CanvasSizeChanged(Number width, int height)

Triggered when the Canvas size changes.

  • Parameters:
    • width: New width
    • height:New height

LayersSelected(Text layer1, String layer2, String type)

Triggered when two layers are selected from the dialog.

  • Parameters:
    • layer1: Layer 1 selected in Show Layer Selection Dialog().
    • layer2: Layer 2 selected in Show Layer Selection Dialog().
    • type: Optional text to differentiate different entries

AreaCopied()

Triggered when an area is successfully copied.

  • Parameters:
    • None

AreaCut()

Triggered when an area is successfully cut.

  • Parameters:
    • None

OnEndSelection(Text type)

Triggered when an area is successfully cut.

  • Parameters:
    • type: Optional text to differentiate different entries

SUPPORT

AIX has been released completely free. Private support will be provided for a payment of $5.00.

Conclusion

The CanvasLayers extension for Kodular Creator provides powerful capabilities for layer-based drawing and manipulation, greatly enhancing the potential for creative and interactive app development.

7 Likes

@Passos_0213 Congratulations on your work and great knowledge in creating extensions.

2 Likes

Thank You :brazil:

2 Likes

Nice extension :astonished:

4 Likes

These are all the blocks available and there will be others. I’m developing it to help my painting app.

1 Like

NEW VERSION

I hope you like the project and support it financially. At the end of the campaign, the extension will be available for free forever.

2 Likes

NEWS

AIX has been released completely free. Private support will be provided for a payment of $5.00.

2 Likes

There is no logic in providing extension for free and then charging for support.
You just can’t abide your own topic.
The moment you publish post about your extension in community, you become bound to reply whatever question is asked in that thread.

1 Like

I refer to private support. I don’t have free time to provide private support to everyone. Another thing is the common doubts that can be resolved here in the community.

2 Likes

Your call.
I can give suggestion only.

2 Likes

I understand your suggestion, I believe there was some interference in communication.

2 Likes

Wait for version 2!

3 Likes

I’ve been waiting for the .aia file for a while now, when will you put it up there so we’ve got something to refer to?; since you said you’re not going to provide the Kodular Community support for no cost? Don’t get me wrong—it’s a great extension you’ve contributed to the Kodular community for Completely free! Though, please do upload the aia file, or at-least show a couple code snippets to make it easier to use the extension!

2 Likes

I thought I added the AIA file. I will provide the file. You can ask via this chat for free. Payment is only for private messages or to jump the queue.

Oh, alright. I’m sorry for the misunderstanding in that case.

Have you uploaded the .aia file? I don’t see it yet. I’ve tried refreshing the page a couple of times; still see nothing.

1 Like

I’ll send it as soon as I turn on my laptop.

1 Like

Alright, thank you! I really appreciate how quickly you’ve been responding!

1 Like

See this AIA created for MIT App Inventor

CanvasLayers.aia (84.8 KB)

2 Likes

Alright, thank you!