Drawing API planning

Events happening in the community are now at Drupal community events on www.drupal.org.
snufkin's picture

I am right now planning the drawing API. Since you, developers are the ones who will primarily use this API, I decided to do this outlining publicly. If you have any comments, ideas of how you would find it easier to use later on, please share it, and if its well founded, i will do my best to incorporate it into the module.

Drawing API in shape of the Forms API

As earlier indicated the Drawing API (DAPI) is being planned in a bit analogous to the form API (FAPI). The usage I imagined would be similar to those of constructing a form on a page: shapes are defined, altered via a special function (analogous to hook_form_alter), and these altering functions are called from the render function.

Workflow

The workflow of constructing and displaying a complex structure of objects would look like this:

  1. user calls drawing_get_canvas($canvas_id)
  2. drawing_get_canvas() collects the elements referred in it, and positions them accordingly to the settings
    (NOTE: this is the same as in FAPI we would omit the default element collecting (hook_elements() ) step, because you always want to use custom shapes, if only because of their positions, you will need a drawing_shape_alter)
  3. when the elements are collected, drawing_shape_alter defines their attributes. There will be no default values to attributes, since size, positions are custom anyway.
  4. After this themeing is commencing, i will use the theme function already in core, that enables us to theme shapes in the usual _, phptemlate_ or theme_ fashion.
  5. drawing_get_canvas() returns the complete XML structure, we only need to print it now

Jealous of the nice diagram in the Pro Drupal Dev book, i tried to create my own:

This is the concept so far. Assigning id's to objects, such as canvases and shapes will allow unique modifications later such as AJAX calls, changing theming, accessing the shapes on the canvas effectively.

AttachmentSize
workflow.png16.85 KB

Comments

Heya snufkin please see this

sime's picture

Heya snufkin please see this post:
http://groups.drupal.org/node/4545

Not only is embedding relevant to svg, but I'd like your opinion about how I'm tackling a FAPI-like process.

Side note: regarding "DAPI", this might be premature. Stick to "Drawing API" because there was, for example, talk of extending/adding to Forms API and calling it Data API or Drupal API. I've not idea how likely that is, but thought I'd best put it out there.

Some general

sime's picture

Some general pondering....

It's a bit ironic. My early references to fapi for SVG SoC proposal were mainly a pointer to make sure the applicant took some time to understand it and the benefits of it (eg benefits like form_alter). However, with your recent posts about it, I looked again at what I was doing with flash embedding and realised that I was not leveraging FAPI at all.

Even if you make something look like FAPI, it will probably be more acceptable. If you use stuff like '#property' then you are able to start using core functions like element_children(). If you create a hook_api_alter(), you make many friends :)

Graphing & SVG

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week