CanvasLayers Extension Guide for Niotron
Overview
CanvasLayers
is a custom extension for Niotron that enhances the functionality of the standard Canvas component. This guide will explain how to integrate and utilize CanvasLayers in your Niotron projects.
MEDIA
FILES
- AIX: com.bosonshiggs.canvaslayers.aix (60.9 KB)
- AIA: Wait!
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
-
SetCanvas(Canvas canvas): Assigns a canvas component for drawing.
-
SetAnchorComponent(ArrangementComponent, Number, Number, Number, Number, Number): Sets up a view component to anchor the layer picker with custom settings.
-
AddLayer(Text, boolean, Number): Adds a new layer to the canvas with an option for alpha channel support.
-
RemoveLayer(): Removes the active layer from the canvas and activates the layer below it.
-
ClearCanvas(): Clears the active layer.
-
SetActiveLayer(Text): Sets the specified layer as the active layer for drawing.
-
DrawPixelOnActiveLayer(Number, Number, Number, Number): Draws a square pixel on the active layer.
-
DrawPointOnActiveLayer(Number, Number, Number, Number): Draws a point on the active layer.
-
DrawLineOnActiveLayer(Number, Number, Number, Number, Number, Number): Draws a line on the active layer.
-
DrawWithShinyBrushOnActiveLayer(Number, Number, Number, Number, Number, Number): Draws with a shiny brush on the active layer.
-
DrawGrid(Number, Number): Draws a removable square grid on a special top layer.
-
RemoveGrid(): Removes the grid layer.
-
Undo(): Undoes the last action on the active layer.
-
Redo(): Redoes the last undone action on the active layer.
-
GetLayerInfo(): Returns information about the layers as a YailList.
-
RenameLayer(Text, Text): Renames a specified layer.
-
Erase(Number, Number, Number): Erases on the active layer.
-
FloodFill(Number, Number, Number, Number): Fills an area on the active layer with a specified color.
-
FloodFillScanline(Number, Number, Number, Number): Fills an area on the active layer with a specified color using the Scanline FloodFill algorithm.
-
GetTotalMemoryUsed(): Returns the total memory used by the extension in Kbytes.
-
AddImageToActiveLayer(@Asset Text): Loads an image from a path and adds it to the active layer.
-
MoveLayerDown(Text): Moves the specified layer down in the order.
-
MoveLayerUp(Text): Moves the specified layer up in the order.
-
ShowLayerPickerWithDelay(): Shows the layer picker after making the anchor component visible.
-
ShowAlertDialog(Text, Text, Number, boolean, boolean): Shows an alert dialog with custom settings.
-
ShowLayerSelectionDialog(Text, Number, Number, Number, boolean, boolean, Text): Shows a dialog with two dropdown menus for layer selection.
-
ShowTextInputDialog(Text, Text, Number, Number, Number, Text, Text, boolean, boolean, boolean, Text): Shows a dialog with a text input.
-
RoundCorners(ArrangementComponent, Number, Number, Number, Number, Number, Number, boolean, boolean): Rounds the corners of a visual component and adjusts colors.
-
RoundCornersMetallic(ArrangementComponent, Number) Number, Number, Number, boolean, boolean): Applies a metallic effect to the corners of a visual component.
-
ZoomInActiveLayer(Number): Zooms in the active layer.
-
ZoomOutActiveLayer(Number): Zooms out the active layer.
-
ZoomInAtPoint(Number, Number, Number): Zooms in the active layer at a specific point.
-
ZoomOutAtPoint(Number, Number, Number): Zooms out the active layer at a specific point.
-
SetCanvasMonitoring(Canvas): Sets up canvas monitoring.
-
ExportLayerToPNG(Text, Text): Exports a specified layer to a PNG file.
-
AdjustBrightness(Text, Number): Adjusts the brightness of the specified layer.
-
CreateLayerFromImage(Text, @Asset Text): Creates a new layer from an existing image.
-
SaveLayersToSeparatePDFPages(Text): Saves each layer as a separate page in a PDF file.
-
SaveAllLayersToOnePDFPage(Text): Saves all layers into a single page of a PDF file.
-
ConvertToPixelArt(): Converts the active layer to pixel art.
-
ResizeLayer(Text, Number, Number): Resizes a specific layer.
-
ConvertLayerToGrayscale(Text): Converts a layer to grayscale.
-
ApplyBlurToLayer(Text, Number): Applies a blur to the
layer.
-
ApplyBlurAtPoint(Text, Number, Number, Number, Number): Applies a blur at a specific point of the layer.
-
CombineLayers(Text, Text, Text): Combines two layers using the specified merge type.
-
StartSelection(Number, Number): Starts selection on the canvas.
-
UpdateSelection(Number, Number): Updates the selection on the canvas.
-
EndSelection(Text): Finalizes the selection on the canvas.
-
CutSelectedArea(): Cuts the selected area from the active layer and copies it to the clipboard.
-
CopySelectedArea(): Copies the selected area to the active canvas.
-
PasteCopiedArea(Number, Number): Pastes the copied area to a specified point on the active canvas.
-
StartLine(Number, Number, Number, Number): Starts a new line on the canvas.
-
DrawLine(): Draws the line on the active layer.
-
UpdateLine(Number, Number): Updates the line on the canvas with an end point.
-
StartArrow(Number, Number, Number, Number): Starts a new arrow on the canvas.
-
UpdateArrow(Number, Number): Updates the arrow on the canvas with a period.
-
DrawArrow(): Draws the arrow on the active layer.
-
GetActiveLayerName(): Returns the name of the active layer.
Property
-
CanvasWidth(Number): Sets or gets the width of the canvas.
-
CanvasHeight(Number): Sets or gets the height of the canvas.
-
OffsetX(Number): Sets or gets the X-coordinate offset.
-
OffsetY(Number): Sets or gets the Y-coordinate offset.
-
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 ShowTextInputDialogString type
: Optional text to differentiate different text entries
CanvasSizeChanged(Number width, int height)
Triggered when the Canvas size changes.
- Parameters:
width
: New widthheight
: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. Support and updates will be provided for a payment of $5.00.
- To donate, click here!
Conclusion
The CanvasLayers extension for Niotron provides powerful capabilities for layer-based drawing and manipulation, greatly enhancing the potential for creative and interactive app development.