# Welcome

Hi there!

We're delighted you've chosen the FabricJS Drawing & Painting Plugin. This plugin is built on top of a popular JavaScript library called FabricJS.

This plugin was built to enable Bubblers like yourself to build customizable and robust graphics creation functionality into your application.  You can learn more about key use cases in the next section.


# Key Use Cases

This plugin supports a variety of graphics creation functionality and can be used to build a number of different types of applications and features, including:

1. Apps like Canva.com
2. Apps like PowerPoint & Google Slides
3. Visual Moodboard Tools
4. Image Annotation Tools
5. Digital Whiteboards

For more in-depth instructions on how to build some of these types of tools using the plugin, visit the ["Use Cases" section](/use-cases/templates) in the left hand menu.


# Key Features

This plugin enables you to build a robust graphics Canvas on your Bubble web page.  There are hundreds of customizations, workflow actions, workflow events, and custom states you can apply to your own graphics canvas once you've added it to your app.  For more in-depth feature description and how-to, check out the ["Feature Reference" section](/feature-reference/general-settings) on the left.

Below is a list of some key features:

#### General Settings:

* Set Canvas Background Color
* Set Background Image
* Add a Custom Right-Click Context Menu
* Set Aspect Ratio
* [Here's a full list of general settings and how to access them...](/feature-reference/general-settings)

**Workflow Actions (Workflow Tab)**

* Save the Canvas (as PNG)
* Save the Canvas (as Serialization, so you can edit later)
* Add Text, Shape, or Image to Canvas
* Bring an Element Forward
* Send an Element Backwards
* Modify an Element
* Vertically or Horizontally Flip an Element
* [Here's a full list of workflow actions and how to access them...](/feature-reference/workflow-actions)

**Workflow Events (Workflow Tab)**

* Elements Added to the Canvas
* Canvas has been Modified
* Generated a saved Canvas image URL
* Generated a Canvas serialization
* [Here's a full list of workflow events and how to access them...](/feature-reference/workflow-events)

**Exposed States:**

* PNG URL link to the Canvas (for saving it as an image)
* Currently Selected Elements
* Selected Shape - Type, Selected Text Value, Selected Element IDs
* [Here's a full list of exposed states and how to access them...](/feature-reference/exposed-states)


# FAQs

<details>

<summary>How do I place my Canvas in a Repeating-Group?</summary>

You can place your Canvas in a Repeating-Group.  In order to uniquely identify your Canvas (e.g. for events fired by a Canvas) you can enter a Unique ID for your Canvas.  Here, you can utilize the current cell's index number, in order to provide a Unique ID for each Canvas inside of the Repeating-Group:\
![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FB5S00dOHU2VW9dVpnAZU%2Fimage.png?alt=media\&token=e9fceb79-df60-49b6-9770-3d7ca78885ab)

On the workflow tab, you can reference an exposed state, which is "This Canvas's Unique ID". For instance, if you want to initiate a set of workflow actions to perform only when the Canvas in the third Repeating-Group cell has been modified, you would add a condition that looks something like the one below, where the "*This Canvas-Main's Unique ID of Canvas is CanvasUniqueID3*" (assuming you've set up the Unique ID like it looks in the screenshot above):

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2Ff7KMpgu91YjUvDZPNPVY%2Fimage.png?alt=media\&token=2034b1d3-cb8a-4bdc-b6da-8a55593e920a)

</details>

<details>

<summary>I saved a serialized Canvas on Desktop and need to re-open it on Mobile (or vice versa, for responsiveness). How do I make the elements inside smaller?</summary>

See "[Responsiveness](/useful-tips/responsiveness)" section

</details>

<details>

<summary>How do I save my Canvas?</summary>

See "[Saving the Canvas](/canvas-using-the-plugin/saving-the-canvas)" section

</details>

<details>

<summary>How do I download my Canvas?</summary>

See "[Downloading the Canvas](/canvas-using-the-plugin/downloading-the-canvas)" section

</details>


# Getting Started

If you feel like this plugin could be useful for you, we encourage you to subscribe to the monthly plan — subscriptions are pro-rated so giving it a trial is low-risk (i.e. subscribing to the plugin for a few days will cost you a matter of pennies).

Below are the instructions to get started:

### 1.  Install the [FabricJS Drawing & Painting Canvas](https://bubble.io/plugin/drawpaint-and-graphics-canvas-1565920055521x927769972289306600) Plugin

Follow [this link](https://techblocksco.bubbleapps.io/version-test/canvasdemo?debug_mode=true) and install the plugin in a Bubble application

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FjbqYnmKqGs6TcISll4Uu%2Fimage.png?alt=media\&token=5bbc7eb1-a06a-4078-b164-d030ac73b07b)

### 2.  Add the "Canvas Main" element to your page

On the design tab of your Bubble app, add the "Canvas Main" element

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FHUygNoe0apSFvGVWGkmq%2Fimage.png?alt=media\&token=38739583-3606-4c08-99ed-e7e19e804268)

### 3.  Preview the Page!

Voila!  Click "Preview" -- you now have a basic version of the Drawing Canvas Plugin on your page.  You should be able to draw within the bounds of your Canvas on your app's page.

Next, you'll learn how to add general settings, like a background color, background image, and how to change from "Free Draw" mode to "Select", "Draw Shapes", and "Add Text" modes.


# Set up the Background

On the Design tab, for your "Canvas Main element" (see screenshot below), there are several settings you can configure

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FOdyjkMt069XhHDf8CuoT%2Fimage.png?alt=media\&token=9ee241ec-980c-4dce-87b5-e40efcaca744)

Try changing the Background Color or Background Image fields to see how it affects the Canvas in run-mode.  For a full list of the General Settings fields and their descriptions, see the ["General Settings" Reference](/feature-reference/general-settings).

Next, we'll show you how to configure what happens when a user clicks on the Canvas, such as how to change from "Free Draw" mode to "Select", "Draw Shapes", and "Add Text" modes!


# Set up Click Behavior

In order to define what happens when a user click the Canvas, use the "Cursor Click Mode" field (see screenshot below).  This setting determines whether the clicking (and dragging) on the Canvas creates a drawing, a shape, adds text, or is simply used to select elements on the Canvas.

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F6gS3dNYlOZ3IhPFz5EfA%2Fimage.png?alt=media\&token=4edb2595-0972-4e0a-a234-eb16e5b03035)

We typically use conditional statements to allow the user to decide what happens when they click on the Canvas. The conditional statements below refer to a state on the page that allows a user to set up the "Cursor Click Mode" by changing the dropdown's value (instead of using a state, you can also use a dropdown menu here):

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F0NiPFB3ochknrRpEhHFW%2Fimage.png?alt=media\&token=55ff40ad-26ba-4922-bb2b-69bdd3c5fe8a)

Below is a reference to the 4 Click Modes:

### Mode 1: Free Draw/Paint

You access the **Free Draw/Paint** mode's properties on the element's Appearance tab:

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FdUOb5JB0PV3GYtBGazI7%2Fimage.png?alt=media\&token=78d43173-5d22-4232-8cab-29977183689d)

In the example above, we've referred to dynamic values so that the user can define the color and width of the stroke from elements on the page.

### Mode 2: Draw Shape

You access the properties for the **Draw Shape** mode on the element's Appearance tab:

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FEUX8RKBz5vHKfbsB6HWD%2Fimage.png?alt=media\&token=9c5196e0-e659-4ab3-923b-3b5837257063)

In the example above, we've referred to dynamic values so the user can determine the following attributes with the shape they intend to draw onto the Canvas:

1. Shape Color (Fill)
2. Shape Outline Color
3. Shape Outline Width (pixels)
4. Draw Shape Type (options: Rectangle, Triangle, Ellipse, Line)
5. Corner Radius (for Rectangles)

### Mode 3: Add Text

You can access the properties for the **Add Text** mode on the element's Appearance tab:

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F7B3j7nlhaWM6jJ6IRqTm%2Fimage.png?alt=media\&token=6b1c759a-31ff-4c33-8496-3f22611b5eae)

In the example above, we've referred to dynamic values so that the user can determine the following attributes with the shape they intend to draw onto the Canvas:

1. Text Color
2. Text Size
3. Default Text

### Mode 4: Select Elements

When the Cursor Click Mode is set to "Select Elements", users who click on the Canvas in run-mode will not draw anything to the Canvas.  They will only be able to select element(s), move them, and resize them.

&#x20;![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FFErxQMMGEwbgiieamnYk%2Fimage.png?alt=media\&token=79968eb5-a0d5-4382-ae3e-ae4b90224f2c)


# Saving the Canvas

You enable users to save the canvas in two ways:

1. **Save (as PNG to URL):** this creates a PNG image from the Canvas and uploads it to your app's AWS instance so that you have a URL of the image that you can save to your database.
2. **Save (as Serialization):** this is helpful if you want to enable your users to save their progress and, in a later session, reload their Canvas to continue editing (i.e. this option creates a JSON text of your Canvas that you can reload later)

Below are instructions for each save method.  For a live example, [here is a link to an example implementation](https://techblocksco.bubbleapps.io/canvas-saving-demo) of each type of saving.

### Save (as PNG to URL)

Saving the Canvas as a .png requires the following steps:

1. On your Design tab, you'll most likely want some kind of button like "Save Canvas as PNG"\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FTT8Re6PBZ2SwlHJdw1ii%2Fimage.png?alt=media\&token=1876cc73-549b-460b-9720-75b848e5b416)<br>
2. Initiate the workflow action called **Save (as PNG to URL) Canvas-Main A** when a user clicks that button\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FC13t82DTQ3jZ9G9zQ6EG%2Fimage.png?alt=media\&token=196f48c4-6dd3-4c6f-a57c-5319ccd93266)<br>
3. Add a the workflow event called **A Canvas - Main has generated a saved image URL**. This workflow event fires when the .png image of the Canvas has been generated\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F8UnVkEiQ8p7dkQRI57gY%2Fimage.png?alt=media\&token=a9b555ca-078c-41f2-ad16-d0d98dc41b8a)<br>
4. To save your image to the database, add a workflow action to create/edit the database Thing you'd like to use. In the example below, we create a new database Thing called **Canvas - Saved Image Documentation**. For the image field, we refer to a Canvas built-in state called "Drawing's PNG URL":\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FVyGBUmogeOdTcydIZlZ1%2Fimage.png?alt=media\&token=f05d125d-850f-4be8-9463-ad197ddabd4a)
5. Voila! Your Canvas .png file should now be saved to the database. You can refer to the image on the page or use it like you would use any other image in Bubble.

For a live example, see [this editor-mode and run-mode example link](https://techblocksco.bubbleapps.io/canvas-saving-demo).

### Save (as Serialization)

1. On your Design tab, you'll most likely want to add some kind of button like "Save as Serialization"\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FGF5kneZadFClR2uzQz65%2Fimage.png?alt=media\&token=813c0b51-eaa1-4301-9e12-c40d815e2a7a)<br>
2. Add the workflow action called **Save (as Serialization) Canvas-Main A** when a user clicks that button\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FsnVPqA9xrQEtfCGlrsVR%2Fimage.png?alt=media\&token=98026eff-33d5-498d-ae84-fe18806a688e)<br>
3. Add a the workflow event called **A Canvas - Main has generated a serialization**. This workflow event fires when the serialization JSON of the Canvas has been generated\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F7dE3LDgKzSWQjiZ2KOdt%2Fimage.png?alt=media\&token=ecf8c636-d698-4605-b245-399b6c98de3c)<br>
4. To save your Canvas serialization to the database, add a workflow action to create/edit the database Thing you'd like to use. In the example below, we create a new database Thing called **Canvas - Saved Image Documentation**. For the image field, we refer to a Canvas built-in state called "Serialized Canvas":\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FtjjGArtm8lxn2UvucWhV%2Fimage.png?alt=media\&token=74b25bfe-ae9e-4af6-a904-4f49c16d9402)<br>
5. To reload a serialized Canvas, you can add a button on your page and use the **Load Serialized Canvas a Canvas - Main** workflow action:\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FFKLdoTjnwxNcoaU7eVUm%2Fimage.png?alt=media\&token=80182c24-3e00-4ba9-ad69-5d9963df3cc3)<br>
6. Refer to the text field of the Serialized Canvas in the **Serialization** property:\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FlP50VJKzh5z6wZMAwaUq%2Fimage.png?alt=media\&token=097b93d1-2943-4892-8c88-9118d8ce41e8)

For a live example, see [this editor-mode and run-mode example link](https://techblocksco.bubbleapps.io/canvas-saving-demo).


# Downloading the Canvas

Due to limitations with JavaScript's download functionality, you will need to closely follow the following instructions:

1. Add a standard Bubble link element to your page. See [HTML id instructions](/useful-tips/element-html-id-attribute) if you don't know how to do this (this will be your Download button so you should update the style of the link element as needed).
2. Give that link element an HTML id attribute
3. Copy and paste that same HTML id attribute from step #2 into the field titled "HTML id" (see screenshot below)\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FK5FLSoDccGjeJwMr1htQ%2Fimage.png?alt=media\&token=b747e56c-eaa2-4302-b3b5-2f6088273512)
4. Run this workflow action when the link element is visible on the page (e.g. when the page is loaded, or when the group containing the link is visible)


# General Settings

To access the General Settings for the Canvas plugin, add the Canvas Element to your page and click the Element on the design tab.  The Element inspector should show up:

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FpHpnAHA3xs0hq9Nxap2m%2Fimage.png?alt=media\&token=0961bd85-2c8c-46f8-b2c6-2da11abe2027)

Below is a description of each property, how it should be set, and what it does:

<table><thead><tr><th width="150">Property</th><th>Description</th></tr></thead><tbody><tr><td>Selector On?</td><td><strong>Yes/No -</strong> Setting this to "yes" enables users to select, move, resize elements on the Canvas</td></tr><tr><td>Background Color</td><td><strong>Hex or RGBA Color</strong> <strong>(text)</strong> - This is the background color of the Canvas</td></tr><tr><td>Fixed Aspect Ratio</td><td><strong>Number</strong> - Optional: the aspect ratio (Width ÷ Height) of the Canvas if you want it to remain the same as a user resizes the page width (e.g. goes from Mobile to Desktop)</td></tr><tr><td>Backspace: Deletes?</td><td><strong>Yes/No</strong> - Setting this to "yes" enables users to delete elements by selecting an element on the Canvas and pressing "Backspace"</td></tr><tr><td>Context Menu</td><td><strong>Text</strong> - Optional: the HTML ID attribute of the group that holds your custom context menu</td></tr><tr><td>Background Image - Static Image</td><td><strong>Uploaded Image</strong> - Optional: if used, this overrides the background color</td></tr><tr><td>Background Image - Dynamic Image</td><td><strong>Image URL</strong> - Optional: if used, this overrides the background color</td></tr><tr><td>Background Image Scale</td><td><strong>Number</strong> - how much to scale up/down the background image based on its original size. For example, setting this to 0.5 would make it half the height &#x26; width and setting to 2 would double the height &#x26; width</td></tr></tbody></table>


# Workflow Actions

You can access the plugin's list of workflow actions by:

1. Opening the workflow tab (make sure you've already added the Canvas-Main element to your page
2. Add your Trigger event (e.g. when a button is clicked)
3. Add a workflow action
4. Navigate to the "Element Actions" section

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F0c2kILtQ4mMy28zn23rs%2Fimage.png?alt=media\&token=924633ec-77cf-49b4-81be-88a997dedc89)

Below is a list of all of the workflow actions associated with the Canvas-Main element along with a description of what it does and how to use it:

**Workflow Actions (Workflow Tab)**

<table><thead><tr><th width="204.4180355258319">Action Name</th><th width="199.57366547222767">Fields</th><th>Description</th></tr></thead><tbody><tr><td>Save (as PNG to URL)</td><td><ul><li>Image Height (px)</li><li>Image Width (px)</li><li>PNG File Name</li></ul></td><td>Use this workflow action to save a .png image of your canvas to your database. Full instructions <a href="/canvas-using-the-plugin/saving-the-canvas#save-as-png-to-url">here</a>.</td></tr><tr><td>Save (as Serialization)</td><td>N/A</td><td>Use this workflow action to save a JSON that represents your Canvas.  You can then load it to continue editing in another session.  Full instructions <a href="/canvas-using-the-plugin/saving-the-canvas#save-as-serialization">here</a>.</td></tr><tr><td>Download Canvas (sets link to download)</td><td>HTML id Attribute, Name of file</td><td>Due to some Bubble and JavaScript limitations, you'll need to add a link to your Bubble page and closely follow the instructions <a href="/canvas-using-the-plugin/downloading-the-canvas">here</a>.</td></tr><tr><td>Load Serialized Canvas</td><td><ul><li>Serialized Canvas</li><li>Undo/Redo Reset</li></ul></td><td>Load a serialized canvas JSON onto the Canvas. Setting <em>Undo/Redo Reset</em> to "yes" makes it so that the furthest a user can undo is to the point where this canvas was loaded.</td></tr><tr><td>Undo</td><td>N/A</td><td>Undo's the user's last action on the Canvas</td></tr><tr><td>Redo</td><td>N/A</td><td>Redo's the user's last action on the Canvas</td></tr><tr><td>Bring Forward an Element</td><td>N/A</td><td>Brings the selected element(s) forward in the canvas relative to the unselected element(s)</td></tr><tr><td>Send Backwards an Element</td><td>N/A</td><td>Sends the selected element(s) backwards in the canvas relative to the unselected element(s)</td></tr><tr><td>Copy Elements on Canvas</td><td>N/A</td><td>Copies the selected element(s) on the Canvas</td></tr><tr><td>Paste Elements on Canvas</td><td>N/A</td><td>Pastes any copied element(s) on the Canvas</td></tr><tr><td>Add Text to Canvas</td><td><ul><li>Text to Add</li><li>X Location</li><li>Y Location</li><li>Font Size</li><li>Text Color</li></ul></td><td>Add Text Elements to the Canvas programmatically using this action and specify the text, location, font size, and color with the action's properties.</td></tr><tr><td>Add Shape to Canvas</td><td><ul><li>Shape (Rectangle, Ellipse, Triangle)</li><li>X Location</li><li>Y Location</li><li>Height</li><li>Width</li><li>Shape Color (Fill)</li><li>Shape Color (Outline)</li><li>Outline Width</li><li>Corner Roundness</li></ul></td><td>Add Shape Elements to the Canvas programmatically using this action and specify the location, size, and color with the action's properties.</td></tr><tr><td>Add Image to Canvas</td><td><ul><li>Image (static)</li><li>Image (dynamic link) if not using static image</li><li>X Location</li><li>Y Location</li><li>Image Width</li><li>Image Height</li><li>Selectable?</li><li>Unique ID</li></ul></td><td>Add Image Elements to the Canvas programmatically using this action and specify the image, location, size with the action's properties.</td></tr><tr><td>Modify Element</td><td><p><strong>Drawing</strong></p><ul><li>Color</li><li>Stroke Width</li></ul><p><strong>Shape</strong></p><ul><li>Fill Color</li><li>Outline Color</li><li>Outline Width</li></ul><p><strong>Text</strong></p><ul><li>Font Family</li><li>Font Color</li><li>Font Size</li><li>Text Value</li></ul></td><td>Modify the selected element(s) based on their type.  For instance, if a <em>Triangle Shape</em> element is selected, you can modify the fill color, outline color, and outline width using this workflow action.</td></tr><tr><td>Scale All Elements</td><td><ul><li>Multiple (number)</li></ul></td><td>Scale all elements on the canvas (e.g. setting to 2 would double element sizes, setting to 0.5 would half the sizes)</td></tr><tr><td>Clear Canvas</td><td>N/A</td><td>Clears the Canvas of all the Elements</td></tr><tr><td>Vertically Flip Selected Element(s)</td><td>N/A</td><td>Vertically flips selected element(s) on Canvas</td></tr><tr><td>Horizontally Flip Selected Element(s)</td><td>N/A</td><td>Horizontally flips selected element(s) on Canvas</td></tr><tr><td>Remove Selected Element(s) from Canvas</td><td>N/A</td><td>Removes the selected Elements from the Canvas</td></tr><tr><td>Set Cursor Click Mode</td><td>Click Mode ("Free Draw/Paint", "Draw Shape", "Select Elements", "Add Text"</td><td>Set what happens when users click and drag on the Canvas. Note: This overrides the Element Properties (set for the Canvas on the Design Tab).</td></tr><tr><td>Toggle Selector Mode</td><td>Can select? (yes/no field)</td><td>Setting "Can select?" to "no" disables the ability for users to select Elements on the Canvas</td></tr></tbody></table>


# Workflow Events

You can access the plugin's list of workflow events by:

1. Opening the workflow tab (make sure you've already added the Canvas-Main element to your page
2. Click to add a Trigger event
3. Navigate to the "Element" section
4. Select one of the events associated with "A Canvas-Main"

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FBzHojDd1FiMnYZJAR63m%2Fimage.png?alt=media\&token=37a45e7c-da26-4c12-9f9d-f6386fb2818c)

Below is a list of all of the workflow events associated with the Canvas-Main element along with a description of what it does and how to use it.

**Workflow Events (Workflow Tab)**

| Event Name                           | Description                                                                                                                                   |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| A Canvas-Main has been modified      | Fires when the Canvas has been modified in any way                                                                                            |
| A Canvas-Main has deleted an element | Fires when an element has been deleted on the Canvas                                                                                          |
| A Canvas-Main Shape Added            | Fires when a shape has been added to the Canvas                                                                                               |
| A Canvas-Main Text Added             | Fires when a text has been added to the Canvas                                                                                                |
| Generated a saved image URL          | Fires when the saved image URL (.png of the image) is ready ([details here](/canvas-using-the-plugin/saving-the-canvas#save-as-png-to-url))   |
| Generated a serialization            | Fires when the serialization (JSON of the Canvas) is ready ([details here](/canvas-using-the-plugin/saving-the-canvas#save-as-serialization)) |


# Exposed States

This plugin enables you to build a robust graphics canvas on your Bubble web page.  There are hundreds of customizations, workflow events, workflow actions, and custom states you can apply to your own graphics canvas.  Here is a list of several of the key features:

**Exposed States**\
*You can access these states on the design or workflow tab, by referring to the Canvas-Main element's states.*

| State                           | Evaluates To                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Element is Selected?            | **Yes/No** - Yes if an object/element is selected on the Canvas                                                                                                                                                                                                                                                                                   |
| Selected Element Type           | **"drawing", "shape", "text"** - if there is a selected Element on the Canvas, this publishes the Type of element                                                                                                                                                                                                                                 |
| Selected Shape - Type           | **"Rectangle", "Ellipse", "Triangle", "Line"** - If the selected Element is a Shape, this will publish the shape type                                                                                                                                                                                                                             |
| Selected Shape - Fill Color     | **Color** - if the selected Element is a Shape, this publishes the Fill Color of that Shape                                                                                                                                                                                                                                                       |
| Selected Shape - Outline Color  | **Color** - if the selected Element is a Shape, this publishes the Outline Color of that Shape                                                                                                                                                                                                                                                    |
| Selected Shape - Outline Width  | **Color** - if the selected Element is a Shape, this publishes the Outline Width of that Shape                                                                                                                                                                                                                                                    |
| Selected Drawing - Color        | **Color** - if the selected Element is a Drawing, this publishes the Color of that Drawing's stroke                                                                                                                                                                                                                                               |
| Selected Drawing - Stroke Width | **Color** - if the selected Element is a Drawing, this publishes the Width of that Drawing's stroke                                                                                                                                                                                                                                               |
| Selected Text - Font Family     | **Text** - if the selected Element is a Text, this publishes the Font Family of that Text                                                                                                                                                                                                                                                         |
| Selected Text - Font Color      | **Text** - if the selected Element is a Text, this publishes the Font Color of that Text                                                                                                                                                                                                                                                          |
| Selected Text - Font Size       | **Text** - if the selected Element is a Text, this publishes the Font Size of that Text                                                                                                                                                                                                                                                           |
| Selected Text - Text Value      | **Text** - if the selected Element is a Text, this publishes the Value of that Text                                                                                                                                                                                                                                                               |
| Selected Text - Text Value      | **Text** - If the selected Element is a Text, this will publish the text value (i.e. the value inside of the textbox)                                                                                                                                                                                                                             |
| Drawing's PNG URL               | **Text** - The URL of the Canvas's PNG ([details here)](/canvas-using-the-plugin/saving-the-canvas#save-as-png-to-url)                                                                                                                                                                                                                            |
| Serialized Canvas               | **Text** - The JSON of the Serialized Canvas ([details here](/canvas-using-the-plugin/saving-the-canvas#save-as-serialization))                                                                                                                                                                                                                   |
| Selected Element IDs            | **Text** - The text value(s) of the selected Element's unique IDs                                                                                                                                                                                                                                                                                 |
| Number of Undos Available       | <p><strong>Number</strong> - The number of undo's available. When the Canvas is initially loaded, this will be 0. Each user action will increase this value by 1.  <br><br>Note: This setting is helpful if you want to create an undo button on your page and "grey it out" when the user has 0 undo's remaining.</p>                            |
| Number of Redos Available       | <p><strong>Number</strong> - The number of redo's available. When the Canvas is initially loaded, this will be 0. Each time the "<em>undo</em>" action is run will increase this value by 1.  <br><br>Note: This setting is helpful if you want to create an redo button on your page and "grey it out" when the user has 0 redo's remaining.</p> |


# Templates

In order to accelerate your development, you can use our free Drawing & Painting Canvas template and/or copy and paste elements directly from the plugin's demo editor.  Here are the links to both options:

1. [Drawing Canvs Template](https://bubble.io/template/draw-paint-graphics-editor-1621531816404x203314989964722180)
2. [Plugin Demo Editor Page](https://bubble.io/page?version=live\&type=page\&name=canvasdemo\&id=techblocksco\&tab=tabs-1)


# Canva/Visual Moodboard

View this live Bubble app that is a clone of Canva (with a link to the Bubble editor page so you can see how it was built): <https://techblocksco.bubbleapps.io/canva-app>

Below is a step-by-step tutorial for building an app like Canva using the plugin

{% embed url="<https://www.youtube.com/watch?v=EYDzpGaKiEA>" %}


# PowerPoint & Slides

Here is a step-by-step tutorial for building a **PowerPoint/Google Slides Clone**.&#x20;

{% embed url="<https://www.youtube.com/watch?v=6AWsq81bVIM>" %}


# Image Editor

We've built an example Image Editor. You can view the app linked below to see how it was built (click to see the tab named "Example: Image Editor"):

<https://techblocksco.bubbleapps.io/canvasdemo>


# Custom Control Menu

You can add a custom control menu, which appears next to a Canvas element when it is selected. For instance, in the screenshot below, the red "X" appears beside any element when it is selected.

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FHqFWX08IMvMMC9LRdVyV%2Fimage.png?alt=media\&token=50401dc0-30af-4b2e-af47-d76f415ec3c8)

In order to set this up, follow the instructions below.  Here is a link to a [Bubble editor example](https://bubble.io/page?type=page\&name=customcontrol\&id=fabricjs\&test_plugin=1565920055521x927769972289306600_current\&tab=tabs-1).

1. Add the Canvas to your page
2. Add a standard Bubble Group element to your page\ <img src="https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FQO8QpfCKHDtope2yzcWb%2Fimage.png?alt=media&amp;token=e06349c0-0da9-47b8-8a63-4e8d2659a098" alt="" data-size="original">
3. Add a [HTML id attribute](/useful-tips/element-html-id-attribute) to that group
4. Enter that HTML id attribute in "Group HTML id" property on the Canvas element\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FslQAfJOnTOXNdK7xZ9UE%2Fimage.png?alt=media\&token=5b5612c1-1763-41e3-80fc-8aa39ff2cea0)
5. Adjust the X and Y offsets (optional)
6. Within the the group, you can add workflow actions to elements. For instance, when a user clicks the "X", we've set it up so that it deletes the element from the Canvas


# Responsiveness

#### **I saved a serialized Canvas on Desktop and need to re-open it on Mobile (or vice versa, for responsiveness). How do I make the elements inside smaller?**

You can scale your elements larger or smaller by using the "Scale All Elements" workflow action:

![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F9KkzXP18lmqLzWWOnHPS%2Fimage.png?alt=media\&token=bfa9f841-7138-496e-a887-87d9ab81e6d9)

This workflow action is helpful if you need to make your Canvas responsive when serializing it and saving it to the database.  Here are the steps you should follow:

1. When serializing the Canvas, save the Canvas Width in another field associated with that database Thing:\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FB23vVBbtAutm5wZaF27e%2Fimage.png?alt=media\&token=9caebe6e-c602-4249-bb7d-f54d3563e1bd)
2. When loading the Canvas on a new screen size, load the Serialized Canvas from step #1, then use the "Scale All Elements" workflow action to update the size of the Elements in your Canvas based on the current Canvas width (formula is **Current Canvas Width** ÷ **Canvas Width when Serialized**):\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2FWcNeaGBbLV0MX5tsREmw%2Fimage.png?alt=media\&token=b5d5f98f-89f0-4039-8fb4-e6e514e895ac)


# Element HTML id Attribute

In order to enable "Download Canvas", you'll need to add an HTML ID Attribute to a standard Bubble link element.  Here are the instructions to do so:

1. Navigate to your app's "Settings" tab
2. Click the "General" Section
3. Check the box for "Expose the option to add an ID attribute to HTML elements" (see screenshot below)\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F7lo0QUTt0fuU9JXlSePy%2Fimage.png?alt=media\&token=bcd48057-33a0-48df-8173-b34d9d0fc0ba)
4. On the design tab, add a Bubble link element to a page
5. Scroll to the bottom of the Link's element inspector and enter a unique ID attribute (see screenshot below)\
   ![](https://2486055478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOwxFzRfBRMCDtkHUwlsR%2Fuploads%2F4RZeJ7GbpEbN2LixyZkQ%2Fimage.png?alt=media\&token=837e8611-b313-4f0b-ae6b-1449ba8054de)
6. This will be the HTML ID Attribute for the link element you've added to your page!


