GoDraw Developer's Guide
GODRAW DEVELOPERS GUIDE
GoDraw lets you draw on top of images or alternatively you can draw on an empty transparent canvas. If you want a colored backdrop to draw on just use an image file with that color as the background.
GoDraw works with PNGs and JPEGs. It does not work with PDFs or any other image files. Images are first converted to a GoDraw document and then sent to the GoDraw editor. Both of these things, conversion, and sending to the editor are accomplished by using GoDraw’s Script API. See below for more information on GoDraw Documents and the Script API.
Your task, as the developer of a GoDraw powered FileMaker application, eventually comes down to writing a single FileMaker script. That script connects the fields you want to store you drawing in to the GoDraw Editor. That script will end up following something close to the series of steps.
- Call Scripts in the Editor API to setup things like fonts, colors, and favorite images
- Optionally call a script in the Drawing API to create a GoDraw document, giving it an image or Width and Height.
- Call a script in the Drawing API to send the GoDraw document to the editor
- Respond to a save and call Scripts in the Drawing API to get the result image and document.
See below for more information on the Drawing API and Script API.
A GoDraw document, sometimes just called a “document”, is text based file format that stores all the information about a drawing. Its not really a “file format” as it is never stored on a disk, but rather it is stored in a text field in your Filemaker database. GoDraw creates and edits GoDraw Documents. If you want to draw on top of an image you have to first convert that image into a GoDraw Document. You do that by calling a GoDraw script and giving it the image you want to convert. You get back a GoDraw document in the Script Result that you can send to the editor using the Script API discussed below.
When a document is “saved” you get back a new GoDraw Document that includes all the changes. A GoDraw document remains editable. You can send it back to the editor as often as you want. Each of the drawing objects remains separately editable.
In addition to the GoDraw Document, the GoDraw editor also produces and saves a PNG file that you can store in a container field. This file is only an image file, it doesn’t contain any of the drawing data anymore. The drawing has been flattened into a single layer.
GoDraw Script API
GoDraw exposes all of its functionality and configuration options as Script calls. You can think of these scripts as the GoDraw API. You call those scripts to tell GoDraw what to do. It doesn’t matter if you have embedded GoDraw into your own file or if GoDraw is remaining in its own file. You still do the same thing. You call the GoDraw scripts, in your own file or in the GoDraw.fmp12 file.
In the download, there are two files. Each file demonstrates the same functionality. The only difference between the two is that one of them, the GoDraw Example.fmp12, doesn’t have any of the GoDraw functionality in it. It uses GoDraw.fmp12 to do all the GoDraw stuff. In both cases, the exact same Scripts are called. The GoDraw Script API is the same.
The Scripts that make up the API are organized into two folders, the Editor API, and the Drawing API. Scripts in the Editor API are used to configure the editor. You can set what fonts are available, the title of the Drawing Window, the colors in the color picker, the images that show up in the Favorites tab, that kind of thing. The Editor API has to do with the Drawing Editor, not the drawings themselves
The Scripts in the Drawing API are used to send GoDraw Documents and image into the editor for editing, and retrieving the edited documents and images from the editor for storage. These are the scripts you call to create your GoDraw Documents, and start editing them.
Take a look at the script, “Draw On An Image” in the GoDraw Example.fmp12 file. That script makes a series of calls that setup the editor and then send a document to the editor for editing. It then pauses and waits for the user to finish editing. When the user “saves” the document, the script continues and retrieves the Saved Document from the editor so it can be stored wherever you like.